Skip to content

Commit 5e824fc

Browse files
ps863qhanam
andauthored
cd: Add smoke tests for CJS and ES modules (#395)
Co-authored-by: Quinn Hanam <[email protected]> --------- Co-authored-by: Quinn Hanam <[email protected]>
1 parent db07c99 commit 5e824fc

File tree

25 files changed

+1541
-18
lines changed

25 files changed

+1541
-18
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
PRE_OR_POST_RELEASE=$1
2+
MODULE_TYPE=$2
3+
4+
5+
if [ "$PRE_OR_POST_RELEASE" = "PRE" ]; then
6+
if [ "$MODULE_TYPE" = "NPM-ES" ]; then
7+
cd smoke/smoke-test-application-NPM-ES
8+
npm uninstall aws-rum-web
9+
npm run clean
10+
npm install
11+
npm install /home/runner/work/aws-rum-web/aws-rum-web #Install locally
12+
npm run build
13+
elif [ "$MODULE_TYPE" = "NPM-CJS" ]; then
14+
cd smoke/smoke-test-application-NPM-CJS
15+
npm uninstall aws-rum-web
16+
npm run clean
17+
npm install
18+
npm install $(npm pack /home/runner/work/aws-rum-web/aws-rum-web | tail -1) #Install locally
19+
npm run build
20+
else
21+
echo "Not a valid module type"
22+
fi
23+
elif [ "$PRE_OR_POST_RELEASE" = "POST" ]; then
24+
25+
if [ "$MODULE_TYPE" = "NPM-ES" ]; then
26+
cd smoke/smoke-test-application-NPM-ES
27+
npm uninstall aws-rum-web
28+
npm run clean
29+
npm install
30+
npm install aws-rum-web #Install latest released direct from NPM
31+
npm run build
32+
elif [ "$MODULE_TYPE" = "NPM-CJS" ]; then
33+
cd smoke/smoke-test-application-NPM-CJS
34+
npm uninstall aws-rum-web
35+
npm run clean
36+
npm install
37+
npm install aws-rum-web #Install latest released direct from NPM
38+
npm run build
39+
else
40+
echo "Not a valid module type"
41+
fi
42+
else
43+
echo "No valid option. Please provide PRE OR POST"
44+
fi
45+
46+
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# App monitor details
12
MONITOR_ID=$1
23
REGION=$2
34
GUEST_ARN=$3
@@ -6,6 +7,17 @@ ENDPOINT=$5
67
CDN=$6
78
VERSION=$(npm pkg get version | sed 's/"//g')/cwr.js
89
CDN+=${VERSION}
10+
INSTALL_METHOD=$7
11+
12+
if [ "$INSTALL_METHOD" = "CDN" ]; then
913
awk '{sub(/\$MONITOR_ID/,MONITOR_ID);sub(/\$REGION/,REGION);sub(/\$CDN/,CDN);sub(/\$GUEST_ARN/,GUEST_ARN);sub(/\$IDENTITY_POOL/,IDENTITY_POOL);sub(/\$ENDPOINT/,ENDPOINT);}1' \
10-
MONITOR_ID="'$MONITOR_ID'" REGION="'$REGION'" CDN="'$CDN'" GUEST_ARN="'$GUEST_ARN'" IDENTITY_POOL="'$IDENTITY_POOL'" ENDPOINT="'$ENDPOINT'" app/smoke.html
11-
14+
MONITOR_ID="'$MONITOR_ID'" REGION="'$REGION'" CDN="'$CDN'" GUEST_ARN="'$GUEST_ARN'" IDENTITY_POOL="'$IDENTITY_POOL'" ENDPOINT="'$ENDPOINT'" smoke/smoke-test-application-CDN/smoke.html
15+
elif [ "$INSTALL_METHOD" = "NPM_ES" ]; then
16+
awk '{sub(/\$MONITOR_ID/,MONITOR_ID);sub(/\$REGION/,REGION);sub(/\$CDN/,CDN);sub(/\$GUEST_ARN/,GUEST_ARN);sub(/\$IDENTITY_POOL/,IDENTITY_POOL);sub(/\$ENDPOINT/,ENDPOINT);}1' \
17+
MONITOR_ID="'$MONITOR_ID'" REGION="'$REGION'" CDN="'$CDN'" GUEST_ARN="'$GUEST_ARN'" IDENTITY_POOL="'$IDENTITY_POOL'" ENDPOINT="'$ENDPOINT'" smoke/smoke-test-application-NPM-ES/src/loader-npm-rum.ts
18+
elif [ "$INSTALL_METHOD" = "NPM_CJS" ]; then
19+
awk '{sub(/\$MONITOR_ID/,MONITOR_ID);sub(/\$REGION/,REGION);sub(/\$CDN/,CDN);sub(/\$GUEST_ARN/,GUEST_ARN);sub(/\$IDENTITY_POOL/,IDENTITY_POOL);sub(/\$ENDPOINT/,ENDPOINT);}1' \
20+
MONITOR_ID="'$MONITOR_ID'" REGION="'$REGION'" CDN="'$CDN'" GUEST_ARN="'$GUEST_ARN'" IDENTITY_POOL="'$IDENTITY_POOL'" ENDPOINT="'$ENDPOINT'" smoke/smoke-test-application-NPM-CJS/src/loader-npm-rum.ts
21+
else
22+
echo "No valid installation method input"
23+
fi
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
bucket=$1
2-
key=smoke-$(npm pkg get version | sed 's/"//g').html
3-
aws s3api put-object --bucket $bucket --key "$key" --body processed_smoke.html --content-type "text/html"
2+
version=$(npm pkg get version | sed 's/"//g')
3+
4+
# CDN
5+
aws s3api put-object --bucket $bucket --key "smoke-$version.html" --body processed_smoke.html --content-type "text/html"
6+
7+
# NPM ES
8+
aws s3api put-object --bucket $bucket --key "npm/es/$version/smoke.html" --body smoke/smoke-test-application-NPM-ES/app/smoke.html --content-type "text/html"
9+
aws s3api put-object --bucket $bucket --key "npm/es/$version/loader_npm_rum_tmp.js" --body smoke/smoke-test-application-NPM-ES/build/dev/loader_npm_rum_tmp.js --content-type application/x-javascript
10+
11+
# NPM CJS
12+
aws s3api put-object --bucket $bucket --key "npm/cjs/$version/smoke.html" --body smoke/smoke-test-application-NPM-CJS/app/smoke.html --content-type "text/html"
13+
aws s3api put-object --bucket $bucket --key "npm/cjs/$version/loader_npm_rum_tmp.js" --body smoke/smoke-test-application-NPM-CJS/build/dev/loader_npm_rum_tmp.js --content-type application/x-javascript

.github/workflows/cd.yaml

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,37 @@ jobs:
6767
6868
curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value' > $AWS_WEB_IDENTITY_TOKEN_FILE
6969
70-
- name: Update Smoke Test Application
71-
id: update-smoke-test
70+
- name: Update Smoke Test Application - CDN
71+
id: update-smoke-test-cdn
7272
run: |
7373
chmod u+x .github/scripts/update_smoke_test.sh
74-
.github/scripts/update_smoke_test.sh ${{ secrets.SMOKE_MONITOR }} ${{ secrets.SMOKE_REGION }} ${{ secrets.SMOKE_ARN }} ${{ secrets.SMOKE_IDENTITY }} ${{ secrets.CONFIG_ENDPOINT }} ${{ secrets.CDN }} >> processed_smoke.html
74+
.github/scripts/update_smoke_test.sh ${{ secrets.SMOKE_MONITOR }} ${{ secrets.SMOKE_REGION }} ${{ secrets.SMOKE_ARN }} ${{ secrets.SMOKE_IDENTITY }} ${{ secrets.CONFIG_ENDPOINT }} ${{ secrets.CDN }} "CDN" >> processed_smoke.html
7575
76-
- name: Upload Smoke Test to CloudFront
76+
- name: Update Smoke Test Application - NPM/ES
77+
id: update-smoke-test-npm-es
78+
run: |
79+
chmod u+x .github/scripts/update_smoke_test.sh
80+
.github/scripts/update_smoke_test.sh ${{ secrets.SMOKE_MONITOR }} ${{ secrets.SMOKE_REGION }} ${{ secrets.SMOKE_ARN }} ${{ secrets.SMOKE_IDENTITY }} ${{ secrets.CONFIG_ENDPOINT }} ${{ secrets.CDN }} "NPM_ES" >> smoke/smoke-test-application-NPM-ES/src/loader-npm-rum-tmp.ts
81+
82+
- name: Update Smoke Test Application - NPM/CJS
83+
id: update-smoke-test-npm-cjs
84+
run: |
85+
chmod u+x .github/scripts/update_smoke_test.sh
86+
.github/scripts/update_smoke_test.sh ${{ secrets.SMOKE_MONITOR }} ${{ secrets.SMOKE_REGION }} ${{ secrets.SMOKE_ARN }} ${{ secrets.SMOKE_IDENTITY }} ${{ secrets.CONFIG_ENDPOINT }} ${{ secrets.CDN }} "NPM_CJS" >> smoke/smoke-test-application-NPM-CJS/src/loader-npm-rum-tmp.ts
87+
88+
- name: Build Smoke Test Application - NPM/ES
89+
id: build-npm-es-application-pre-release
90+
run: |
91+
chmod u+x .github/scripts/build_npm_applications.sh
92+
.github/scripts/build_npm_applications.sh "PRE" "NPM-ES"
93+
94+
- name: Build Smoke Test Application - NPM/CJS
95+
id: build-npm-cjs-application-pre-release
96+
run: |
97+
chmod u+x .github/scripts/build_npm_applications.sh
98+
.github/scripts/build_npm_applications.sh "PRE" "NPM-CJS"
99+
100+
- name: Upload Smoke Tests to CloudFront
77101
id: upload-smoke-test
78102
run: |
79103
chmod u+x .github/scripts/upload_smoke_test.sh
@@ -82,19 +106,76 @@ jobs:
82106
- name: Install PlayWright
83107
run: npx playwright install --with-deps chromium
84108

85-
- name: Run Smoke Test
109+
- name: Run Smoke Test (NPM ES)
110+
env:
111+
URL: ${{ secrets.SMOKE_URL }}
112+
MONITOR: ${{ secrets.SMOKE_MONITOR }}
113+
ENDPOINT: ${{ secrets.SMOKE_ENDPOINT }}
114+
NAME: ${{ secrets.SMOKE_MONITOR_NAME }}
115+
INSTALL_METHOD: 'NPM-ES'
116+
run: npm run smoke:headless
117+
timeout-minutes: 10
118+
119+
- name: Fetch AWS Credentials for Smoke Test
120+
run: |
121+
export AWS_ROLE_ARN=${{ secrets.SMOKE_TEST_ROLE }}
122+
export AWS_WEB_IDENTITY_TOKEN_FILE=/tmp/awscreds
123+
export AWS_DEFAULT_REGION=us-east-1
124+
125+
echo AWS_WEB_IDENTITY_TOKEN_FILE=$AWS_WEB_IDENTITY_TOKEN_FILE >> $GITHUB_ENV
126+
echo AWS_ROLE_ARN=$AWS_ROLE_ARN >> $GITHUB_ENV
127+
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION >> $GITHUB_ENV
128+
129+
curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value' > $AWS_WEB_IDENTITY_TOKEN_FILE
130+
131+
- name: Run Smoke Test (NPM CJS)
132+
env:
133+
URL: ${{ secrets.SMOKE_URL }}
134+
MONITOR: ${{ secrets.SMOKE_MONITOR }}
135+
ENDPOINT: ${{ secrets.SMOKE_ENDPOINT }}
136+
NAME: ${{ secrets.SMOKE_MONITOR_NAME }}
137+
INSTALL_METHOD: 'NPM-CJS'
138+
run: npm run smoke:headless
139+
timeout-minutes: 10
140+
141+
- name: Fetch AWS Credentials for Smoke Test
142+
run: |
143+
export AWS_ROLE_ARN=${{ secrets.SMOKE_TEST_ROLE }}
144+
export AWS_WEB_IDENTITY_TOKEN_FILE=/tmp/awscreds
145+
export AWS_DEFAULT_REGION=us-east-1
146+
147+
echo AWS_WEB_IDENTITY_TOKEN_FILE=$AWS_WEB_IDENTITY_TOKEN_FILE >> $GITHUB_ENV
148+
echo AWS_ROLE_ARN=$AWS_ROLE_ARN >> $GITHUB_ENV
149+
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION >> $GITHUB_ENV
150+
151+
curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value' > $AWS_WEB_IDENTITY_TOKEN_FILE
152+
153+
- name: Run Smoke Test (CDN)
86154
env:
87155
URL: ${{ secrets.SMOKE_URL }}
88156
MONITOR: ${{ secrets.SMOKE_MONITOR }}
89157
ENDPOINT: ${{ secrets.SMOKE_ENDPOINT }}
90158
NAME: ${{ secrets.SMOKE_MONITOR_NAME }}
159+
INSTALL_METHOD: 'CDN'
91160
run: npm run smoke:headless
92161

93162
- name: Publish to NPM
94163
run: npm publish
95164
env:
96165
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
97166

167+
- name: Build Smoke Test Application - NPM/ES (Post NPM Release)
168+
id: build-npm-es-application-post-release
169+
run: |
170+
chmod u+x .github/scripts/build_npm_applications.sh
171+
.github/scripts/build_npm_applications.sh "POST" "NPM-ES"
172+
173+
- name: Build Smoke Test Application - NPM/CJS (Post NPM Release)
174+
id: build-npm-cjs-application-post-release
175+
run: |
176+
chmod u+x .github/scripts/build_npm_applications.sh
177+
.github/scripts/build_npm_applications.sh "POST" "NPM-CJS"
178+
98179
- name: Create GitHub Release
99180
id: create_release
100181
uses: actions/create-release@v1

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ coverage
55
src/events
66
package-lock.json
77
docs/
8-
.vscode
8+
.vscode

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
"postinteg:local:nightwatch:firefox": "kill $(lsof -t -i:8080)",
5757
"smoke:local:headless": "cross-env URL=$URL MONITOR_ID=$MONITOR ENDPOINT=$ENDPOINT NAME=$NAME VERSION=$npm_package_version npx playwright test --config=playwright.local.config.ts",
5858
"smoke:local": "cross-env URL=$URL MONITOR_ID=$MONITOR ENDPOINT=$ENDPOINT NAME=$NAME VERSION=$npm_package_version npx playwright test --config=playwright.local.config.ts --headed",
59-
"smoke": "cross-env URL=$URL MONITOR_ID=$MONITOR ENDPOINT=$ENDPOINT NAME=$NAME VERSION=$npm_package_version npx playwright test --config=playwright.config.ts --headed",
60-
"smoke:headless": "cross-env URL=$URL MONITOR_ID=$MONITOR ENDPOINT=$ENDPOINT NAME=$NAME VERSION=$npm_package_version npx playwright test --config=playwright.config.ts",
59+
"smoke:headless": "cross-env URL=$URL MONITOR_ID=$MONITOR ENDPOINT=$ENDPOINT NAME=$NAME VERSION=$npm_package_version INSTALL_METHOD=$INSTALL_METHOD npx playwright test --config=playwright.config.ts",
6160
"prepare": "husky install"
6261
},
6362
"devDependencies": {

playwright.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
// @ts-check
33
const { devices } = require('@playwright/test');
44

5-
const config = {
5+
var config = {
66
forbidOnly: !!process.env.CI,
77
reporter: 'list',
88
workers: process.env.CI ? 4 : undefined,
9-
testDir: 'src/__smoke-test__',
9+
testDir:
10+
process.env.INSTALL_METHOD === 'CDN'
11+
? 'src/__smoke-test__'
12+
: 'src/__smoke-test-npm__',
1013
retries: process.env.CI ? 2 : 2,
1114
timeout: 300000,
1215
use: {

0 commit comments

Comments
 (0)