Skip to content

Commit 454fcfd

Browse files
committed
ci: restructure e2e tests
1 parent 5ea4433 commit 454fcfd

File tree

6 files changed

+61
-122
lines changed

6 files changed

+61
-122
lines changed

.github/workflows/e2e_test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: AWS E2E
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- rc
9+
paths-ignore:
10+
- '**.md'
11+
- 'cloudformation/*.yml'
12+
13+
permissions:
14+
id-token: write # This is required for requesting the JWT
15+
contents: read # This is required for actions/checkout
16+
17+
jobs:
18+
RunE2E:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Git clone
22+
uses: actions/checkout@v4
23+
- name: configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}}
27+
aws-region: ${{secrets.AWS_E2E_REGION}}
28+
- name: Trigger AWS CodePipeline
29+
run: |
30+
codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{secrets.AWS_E2E_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text)
31+
echo "Pipeline execution ID: $codepipeline_execution_id"
32+
echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV
33+
- name: Poll Pipeline Status
34+
id: poll-status
35+
run: |
36+
while true; do
37+
sleep 30
38+
39+
status=$(aws codepipeline get-pipeline-execution \
40+
--pipeline-name ${{secrets.AWS_E2E_CODEPIPELINE_NAME}} \
41+
--pipeline-execution-id ${{ env.codepipeline_execution_id }} \
42+
--query 'pipelineExecution.status' --output text)
43+
44+
echo "Current pipeline status: $status"
45+
46+
if [[ "$status" == "Succeeded" ]]; then
47+
echo "Pipeline execution succeeded!"
48+
exit 0
49+
elif [[ "$status" == "Failed" ]]; then
50+
echo "Pipeline execution failed!"
51+
exit 1
52+
fi
53+
54+
done

buildspec-e2e-rc.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
version: 0.2
2-
env:
3-
secrets-manager:
4-
GITHUB_TOKEN: "fpjs-dev-cloudfront-secrets:GITHUB_TOKEN"
2+
53
phases:
64
install:
75
runtime-versions:
@@ -12,14 +10,6 @@ phases:
1210
- echo $CODEBUILD_SOURCE_VERSION
1311
- echo $CODEBUILD_BUILD_ID
1412
- echo $CODEBUILD_PUBLIC_BUILD_URL
15-
- |
16-
curl \
17-
-X POST \
18-
-H "Accept: application/vnd.github+json" \
19-
-H "Authorization: Bearer $GITHUB_TOKEN"\
20-
-H "X-GitHub-Api-Version: 2022-11-28" \
21-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_ID \
22-
-d "{\"state\":\"pending\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/$AWS_ACCOUNT_ID/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests for release are running\",\"context\":\"e2e-release\"}"
2313
- ls -a
2414
- curl -fsSL https://get.pulumi.com | sh
2515
- export PATH=$PATH:$HOME/.pulumi/bin
@@ -31,37 +21,15 @@ phases:
3121
pre_build:
3222
commands:
3323
- pwd
34-
- pulumi version
24+
- pulumi version
3525
- cd e2e/infra/lambda && pulumi stack init e2e && pulumi stack select e2e && cd ../../..
3626
- cd e2e/infra/cloudfront && pulumi stack init e2e && pulumi stack select e2e && cd ../../..
3727
- cd e2e/infra && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../..
38-
finally:
39-
- |
40-
if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then
41-
curl \
42-
-X POST \
43-
-H "Accept: application/vnd.github+json" \
44-
-H "Authorization: Bearer $GITHUB_TOKEN"\
45-
-H "X-GitHub-Api-Version: 2022-11-28" \
46-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_ID \
47-
-d "{\"state\":\"error\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/$AWS_ACCOUNT_ID/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests for release failed during the pre-build step\",\"context\":\"e2e-release\"}"
48-
fi
4928
build:
5029
commands:
5130
- ls -a
5231
- cd e2e/tests && pnpm test
5332
finally:
5433
- cd ../..
55-
- echo $CODEBUILD_BUILD_SUCCEEDING
5634
- echo $COMMIT_ID
57-
- export STATUS=$(sh ./e2e/scripts/get-codebuild-status.sh)
58-
- echo $STATUS
59-
- |
60-
curl \
61-
-X POST \
62-
-H "Accept: application/vnd.github+json" \
63-
-H "Authorization: Bearer $GITHUB_TOKEN"\
64-
-H "X-GitHub-Api-Version: 2022-11-28" \
65-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_ID \
66-
-d "{\"state\":\"$STATUS\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/$AWS_ACCOUNT_ID/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests for release finished\",\"context\":\"e2e-release\"}"
6735
- cd e2e/infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../..

buildspec-e2e.yml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
version: 0.2
2-
env:
3-
secrets-manager:
4-
GITHUB_TOKEN: "fpjs-dev-cloudfront-secrets:GITHUB_TOKEN"
2+
53
phases:
64
install:
75
runtime-versions:
@@ -12,14 +10,6 @@ phases:
1210
- echo $COMMIT_SHA
1311
- echo $CODEBUILD_BUILD_ID
1412
- echo $CODEBUILD_PUBLIC_BUILD_URL
15-
- |
16-
curl \
17-
-X POST \
18-
-H "Accept: application/vnd.github+json" \
19-
-H "Authorization: Bearer $GITHUB_TOKEN"\
20-
-H "X-GitHub-Api-Version: 2022-11-28" \
21-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
22-
-d "{\"state\":\"pending\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests are running\",\"context\":\"e2e\"}"
2313
- ls -a
2414
- curl -fsSL https://get.pulumi.com | sh
2515
- export PATH=$PATH:$HOME/.pulumi/bin
@@ -35,33 +25,11 @@ phases:
3525
- cd infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
3626
- cd infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
3727
- cd infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../
38-
finally:
39-
- |
40-
if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then
41-
curl \
42-
-X POST \
43-
-H "Accept: application/vnd.github+json" \
44-
-H "Authorization: Bearer $GITHUB_TOKEN"\
45-
-H "X-GitHub-Api-Version: 2022-11-28" \
46-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
47-
-d "{\"state\":\"error\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests failed during the pre-build step\",\"context\":\"e2e\"}"
48-
fi
4928
build:
5029
commands:
5130
- ls -a
5231
- cd tests && pnpm test
5332
finally:
5433
- cd ../
55-
- echo $CODEBUILD_BUILD_SUCCEEDING
5634
- echo $COMMIT_SHA
57-
- export STATUS=$(sh ./scripts/get-codebuild-status.sh)
58-
- echo $STATUS
59-
- |
60-
curl \
61-
-X POST \
62-
-H "Accept: application/vnd.github+json" \
63-
-H "Authorization: Bearer $GITHUB_TOKEN"\
64-
-H "X-GitHub-Api-Version: 2022-11-28" \
65-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
66-
-d "{\"state\":\"$STATUS\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"E2E tests finished\",\"context\":\"e2e\"}"
6735
- cd infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../

buildspec-mock-e2e.yml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
version: 0.2
2-
env:
3-
secrets-manager:
4-
GITHUB_TOKEN: "fpjs-dev-cloudfront-secrets:GITHUB_TOKEN"
2+
53
phases:
64
install:
75
runtime-versions:
@@ -14,14 +12,6 @@ phases:
1412
- echo $VERSION
1513
- echo $CODEBUILD_BUILD_ID
1614
- echo $CODEBUILD_PUBLIC_BUILD_URL
17-
- |
18-
curl \
19-
-X POST \
20-
-H "Accept: application/vnd.github+json" \
21-
-H "Authorization: Bearer $GITHUB_TOKEN"\
22-
-H "X-GitHub-Api-Version: 2022-11-28" \
23-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
24-
-d "{\"state\":\"pending\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests are running\",\"context\":\"mock-e2e\"}"
2515
- ls -a
2616
- curl -fsSL https://get.pulumi.com | sh
2717
- export PATH=$PATH:$HOME/.pulumi/bin
@@ -38,32 +28,10 @@ phases:
3828
- cd infra/lambda && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
3929
- cd infra/cloudfront && pnpm install && pulumi stack init e2e && pulumi stack select e2e && cd ../../
4030
- cd infra && pnpm install && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../
41-
finally:
42-
- |
43-
if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then
44-
curl \
45-
-X POST \
46-
-H "Accept: application/vnd.github+json" \
47-
-H "Authorization: Bearer $GITHUB_TOKEN"\
48-
-H "X-GitHub-Api-Version: 2022-11-28" \
49-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
50-
-d "{\"state\":\"error\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests failed during the pre-build step\",\"context\":\"mock-e2e\"}"
51-
fi
5231
build:
5332
commands:
5433
- ts-node ./scripts/mockTests.ts --project=tsconfig.json
5534
finally:
56-
- echo $CODEBUILD_BUILD_SUCCEEDING
5735
- echo $COMMIT_SHA
58-
- export STATUS=$(sh ./scripts/get-codebuild-status.sh)
59-
- echo $STATUS
60-
- |
61-
curl \
62-
-X POST \
63-
-H "Accept: application/vnd.github+json" \
64-
-H "Authorization: Bearer $GITHUB_TOKEN"\
65-
-H "X-GitHub-Api-Version: 2022-11-28" \
66-
https://api.github.com/repos/fingerprintjs/fingerprint-pro-cloudfront-integration/statuses/$COMMIT_SHA \
67-
-d "{\"state\":\"$STATUS\",\"target_url\":\"https://us-east-1.console.aws.amazon.com/codesuite/codebuild/projects/fpjs-dev-cloudfront-lambda-e2e-mock-tests/build/$CODEBUILD_BUILD_ID/?region=us-east-1\",\"description\":\"Mock E2E Tests finished\",\"context\":\"mock-e2e\"}"
6836
- cd infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../
6937

e2e/scripts/get-codebuild-status.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/downloadGithubRelease.mjs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { fileURLToPath } from 'url'
44
import Zip from 'adm-zip'
55

66
const config = {
7-
token: process.env.GITHUB_TOKEN,
87
owner: 'fingerprintjs',
98
repo: 'fingerprint-pro-cloudfront-integration',
109
}
@@ -31,7 +30,7 @@ async function main() {
3130
return
3231
}
3332

34-
const zip = await downloadReleaseAsset(asset.url, config.token)
33+
const zip = await downloadReleaseAsset(asset.url)
3534

3635
if (process.env.UNPACK_TO_DIST) {
3736
new Zip(zip).extractAllTo(path.resolve(dirname, '../dist'), true)
@@ -40,10 +39,6 @@ async function main() {
4039
}
4140
}
4241

43-
function bearer(token) {
44-
return `Bearer ${token}`
45-
}
46-
4742
async function getGitHubRelease() {
4843
const commitId = process.env.COMMIT_ID
4944

@@ -95,25 +90,16 @@ async function getLatestGitHubRelease() {
9590
}
9691

9792
async function doGitHubGetRequest(url) {
98-
const response = await fetch(url, {
99-
headers: config.token
100-
? {
101-
Authorization: bearer(config.token),
102-
}
103-
: undefined,
104-
})
93+
const response = await fetch(url)
10594

10695
return await response.json()
10796
}
10897

109-
async function downloadReleaseAsset(url, token) {
98+
async function downloadReleaseAsset(url) {
11099
const headers = {
111100
Accept: 'application/octet-stream',
112101
'User-Agent': 'fingerprint-pro-cloudfront-integration',
113102
}
114-
if (token) {
115-
headers['Authorization'] = bearer(token)
116-
}
117103

118104
console.info('Downloading release asset...', url)
119105

0 commit comments

Comments
 (0)