|
1 | 1 |
|
2 | 2 | # This is also the same script that runs on Github via the Github Action configured in .github/workflows - there, the
|
3 | 3 | # DEVHUB_SFDX_URL.txt file is populated in a build step
|
4 |
| -$testInvocation = 'sfdx force:apex:test:run -n "RollupTests, RollupEvaluatorTests, RollupFieldInitializerTests, RollupCalculatorTests, RollupIntegrationTests, RollupFlowBulkProcessorTests" -c -d ./tests/apex -r json -w 20' |
| 4 | +$testInvocation = 'sfdx force:apex:test:run -n "RollupTests, RollupEvaluatorTests, RollupFieldInitializerTests, RollupCalculatorTests, RollupIntegrationTests, RollupFlowBulkProcessorTests" -c -d ./tests/apex -r human -w 20' |
5 | 5 |
|
6 | 6 | function Start-Tests() {
|
7 | 7 | # Run tests
|
8 | 8 | Write-Output "Starting test run ..."
|
9 |
| - $testOutput = Invoke-Expression $testInvocation | ConvertFrom-Json |
10 |
| - Write-Output $testOutput.result.summary |
11 |
| - Write-Output $testOutput.result.tests |
12 |
| - if(0 -ne $testOutput.status) { |
13 |
| - throw $testOutput |
14 |
| - } |
15 |
| - Write-Output "Tests finished running successfully" |
| 9 | + Invoke-Expression $testInvocation |
16 | 10 | }
|
17 | 11 |
|
18 | 12 | function Reset-SFDX-Json() {
|
@@ -47,26 +41,34 @@ $scratchOrgAllotment = ((sfdx force:limits:api:display --json | ConvertFrom-Json
|
47 | 41 | Write-Output "Total remaining scratch orgs for the day: $scratchOrgAllotment"
|
48 | 42 | Write-Output "Test command to use: $testInvocation"
|
49 | 43 |
|
| 44 | +$shouldDeployToSandbox = $false |
| 45 | + |
50 | 46 | if($scratchOrgAllotment -gt 0) {
|
51 | 47 | Write-Output "Beginning scratch org creation"
|
52 |
| - $userNameHasBeenSet = $true |
53 | 48 | # Create Scratch Org
|
54 | 49 | try {
|
55 |
| - sfdx force:org:create -f config/project-scratch-def.json -a apex-rollup-scratch-org -s -d 1 |
56 |
| - # Deploy |
57 |
| - Write-Output 'Pushing source to scratch org ...' |
58 |
| - sfdx force:source:push |
59 |
| - # Run tests |
60 |
| - Start-Tests |
61 |
| - Write-Output "Scratch org tests finished running with success: $?" |
62 |
| - # Delete scratch org |
63 |
| - sfdx force:org:delete -p -u apex-rollup-scratch-org |
| 50 | + $scratchOrgCreateMessage = sfdx force:org:create -f config/project-scratch-def.json -a apex-rollup-scratch-org -s -d 1 |
| 51 | + # Sometimes SFDX lies (UTC date problem?) about the number of scratch orgs remaining in a given day |
| 52 | + # The other issue is that this doesn't throw, so we have to test the response message ourselves |
| 53 | + if($scratchOrgCreateMessage -eq 'The signup request failed because this organization has reached its active scratch org limit') { |
| 54 | + throw $1 |
| 55 | + } |
| 56 | + $userNameHasBeenSet = $true |
| 57 | + # Deploy |
| 58 | + Write-Output 'Pushing source to scratch org ...' |
| 59 | + sfdx force:source:push |
| 60 | + # Run tests |
| 61 | + Start-Tests |
| 62 | + Write-Output "Scratch org tests finished running with success: $?" |
| 63 | + # Delete scratch org |
| 64 | + sfdx force:org:delete -p -u apex-rollup-scratch-org |
64 | 65 | } catch {
|
65 | 66 | Write-Output "There was an issue with scratch org creation, continuing ..."
|
66 |
| - Reset-SFDX-Json |
67 |
| - throw 'Error!' |
| 67 | + $shouldDeployToSandbox = $true |
68 | 68 | }
|
69 |
| -} else { |
| 69 | +} |
| 70 | + |
| 71 | +if($shouldDeployToSandbox) { |
70 | 72 | Write-Output "No scratch orgs remaining, running tests on sandbox"
|
71 | 73 |
|
72 | 74 | try {
|
|
0 commit comments