File tree 4 files changed +28
-15
lines changed
helpers/integration-tests
4 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ jobs:
31
31
- script : npm run test-staging && node helpers/integration-tests/index.js
32
32
displayName : ' Analyze staging with webhint'
33
33
condition : and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
34
- - bash : |
35
- az login --service-principal -u $AZURE_SERVICE_PRINCIPAL -p $AZURE_SERVICE_PRINCIPAL_PASSWORD --tenant $AZURE_TENANT
36
- az webapp deployment slot swap -g webhint-web -n sonarwhal --slot staging
34
+ - task : AzureAppServiceManage@0
37
35
displayName : ' Swap into production'
38
36
condition : and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
39
- env:
40
- AZURE_SERVICE_PRINCIPAL: $(AZURE_SERVICE_PRINCIPAL)
41
- AZURE_SERVICE_PRINCIPAL_PASSWORD: $(AZURE_SERVICE_PRINCIPAL_PASSWORD)
42
- AZURE_TENANT: $(AZURE_TENANT)
37
+ inputs :
38
+ azureSubscription : ' webhint-web'
39
+ Action : ' Swap Slots'
40
+ WebAppName : ' sonarwhal'
41
+ ResourceGroupName : ' webhint-web'
42
+ SourceSlot : ' staging'
43
43
- bash : |
44
44
curl https://www.google.com/ping?sitemap=https://webhint.io/sitemap.xml
45
45
curl https://www.bing.com/ping?sitemap=https://webhint.io/sitemap.xml
Original file line number Diff line number Diff line change @@ -8,9 +8,9 @@ const runIntegrationTests = async () => {
8
8
9
9
try {
10
10
for ( const test of [ runStaticTests , runScannerTest ] ) {
11
- const errorFound = await test ( ) ;
11
+ const success = await test ( ) ;
12
12
13
- if ( errorFound ) {
13
+ if ( ! success ) {
14
14
error = true ;
15
15
}
16
16
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const runScannerTest = async () => {
22
22
} ! => Status: ${ response . status ( ) } `
23
23
) ;
24
24
25
- return response . status ( ) ! == 200 ;
25
+ return response . status ( ) = == 200 ;
26
26
} catch ( error ) {
27
27
console . error ( '🚨 Something went wrong while executing Puppeteer: ' , error ) ;
28
28
await browser . close ( ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ const staticURLsToVerify = [
7
7
'https://sonarwhal-staging.azurewebsites.net/docs/user-guide/hints/'
8
8
] ;
9
9
10
+ const backOffTime = 5000 ;
11
+ const maxRetries = 3 ;
12
+
13
+ const delay = ( ms ) => {
14
+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
15
+ } ;
16
+
10
17
const runPuppeteer = async ( url ) => {
11
18
const browser = await puppeteer . launch ( ) ;
12
19
@@ -32,17 +39,23 @@ const runPuppeteer = async (url) => {
32
39
} ;
33
40
34
41
const runStaticTests = async ( ) => {
35
- let errorFound = false ;
42
+ let success = true ;
43
+ let retryCount = 0 ;
44
+ let resultStatus = null ;
36
45
37
46
for ( const url of staticURLsToVerify ) {
38
- const resultStatus = await runPuppeteer ( url ) ;
47
+ resultStatus = await runPuppeteer ( url ) ;
39
48
40
- if ( resultStatus !== 200 ) {
41
- errorFound = true ;
49
+ while ( resultStatus !== 200 && retryCount < maxRetries ) {
50
+ console . log ( 'Test failed, retrying... Attempt #' + ( ++ retryCount ) ) ;
51
+ await delay ( backOffTime * retryCount ) ;
52
+ resultStatus = await runPuppeteer ( url ) ;
42
53
}
54
+
55
+ success = success && resultStatus === 200 ;
43
56
}
44
57
45
- return errorFound ;
58
+ return success ;
46
59
} ;
47
60
48
61
module . exports = { runStaticTests } ;
You can’t perform that action at this time.
0 commit comments