Skip to content

Commit 117d6d8

Browse files
authored
Merge pull request #295 from fingerprintjs/ci/fix-rc-e2e-tests
ci: make release test pipeline use commit with tag INTER-924
2 parents 750ca3b + b50d55b commit 117d6d8

File tree

5 files changed

+141
-16
lines changed

5 files changed

+141
-16
lines changed

.github/workflows/e2e_test_for_prs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: Run e2e for topic branch
1+
name: Run AWS E2E for topic branch
2+
23
on:
34
pull_request:
5+
branches:
6+
- rc
47

58
jobs:
69
check-changed-files:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check AWS E2E for releases and pre-releases
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-commit-with-tag-and-old-tests:
10+
runs-on: ubuntu-20.04
11+
name: Check latest commit with tag and its checks
12+
steps:
13+
- name: 'Install latest node version'
14+
uses: actions/setup-node@v4
15+
16+
- name: Git clone
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Check latest commit with tag
21+
id: latest_commit_with_test
22+
run: |
23+
diff=$(git log origin/$GITHUB_BASE_REF..HEAD --oneline --format="%H")
24+
echo "diff=$diff"
25+
latestCommitWithTag=''
26+
for commit in $diff; do
27+
echo "checking commit $commit for tag"
28+
tag=$(git tag --points-at "$commit")
29+
if [[ -n "$tag" ]]; then
30+
latestCommitWithTag=$commit
31+
break
32+
fi
33+
done
34+
echo "latestCommitWithTag=$latestCommitWithTag"
35+
echo "latestCommitWithTag=$latestCommitWithTag" >> $GITHUB_OUTPUT
36+
if [[ -z "$latestCommitWithTag" ]]; then
37+
echo "no tag has found. Skipping..."
38+
fi
39+
40+
- name: Poll checks from GitHub
41+
if: steps.latest_commit_with_test.outputs.latestCommitWithTag != ''
42+
run: node scripts/checkCommitStatusForE2E.mjs
43+
env:
44+
COMMIT_SHA: ${{ steps.latest_commit_with_test.outputs.latestCommitWithTag }}
45+
GITHUB_REPOSITORY: ${{ github.repository }}

.github/workflows/e2e_test_for_releases.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
name: AWS E2E for releases and pre-releases
1+
name: Run AWS E2E for releases and pre-releases
22

33
on:
44
workflow_dispatch:
55
push:
66
tags:
77
- v*
8-
paths-ignore:
9-
- '**.md'
10-
- 'cloudformation/*.yml'
11-
12-
permissions:
13-
id-token: write # This is required for requesting the JWT
14-
contents: read # This is required for actions/checkout
158

169
jobs:
1710
run-e2e-for-releases-and-pre-releases:
11+
permissions:
12+
id-token: write # This is required for requesting the JWT
13+
contents: read # This is required for actions/checkout
1814
name: Run e2e for releases and pre-releases
1915
runs-on: ubuntu-latest
2016
steps:
2117
- name: Git clone
2218
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
2321
- name: configure AWS credentials
2422
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 #v4.0.2
2523
with:
2624
role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}}
2725
aws-region: ${{vars.AWS_E2E_REGION}}
2826
- name: Trigger AWS CodePipeline
2927
run: |
30-
codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_RC_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text)
28+
commit=${{ github.sha }}
29+
tag=$(git tag --points-at "$commit")
30+
echo "Running tests for tag: $tag and commit SHA: $commit"
31+
codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_RC_CODEPIPELINE_NAME}} --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=$commit --query 'pipelineExecutionId' --output text)
3132
echo "Pipeline execution ID: $codepipeline_execution_id"
3233
echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV
3334
- name: Poll Pipeline Status
@@ -52,3 +53,13 @@ jobs:
5253
fi
5354
5455
done
56+
- name: Output Pipeline Link
57+
if: always()
58+
run: |
59+
region=${{ vars.AWS_E2E_REGION }}
60+
pipeline_name=${{ vars.AWS_E2E_RC_CODEPIPELINE_NAME }}
61+
execution_id=${{ env.codepipeline_execution_id }}
62+
pipeline_url="https://${region}.console.aws.amazon.com/codesuite/codepipeline/pipelines/${pipeline_name}/executions/${execution_id}?region=${region}"
63+
echo "AWS CodePipeline Execution URL: $pipeline_url"
64+
echo "## AWS CodePipeline Execution Link" >> $GITHUB_STEP_SUMMARY
65+
echo "[$pipeline_url]($pipeline_url)" >> $GITHUB_STEP_SUMMARY

buildspec-e2e-rc.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ phases:
1515
- export PATH=$PATH:$HOME/.pulumi/bin
1616
- pulumi version
1717
- pnpm install
18-
- cd e2e/tests && npx playwright install --with-deps && cd ../..
18+
- cd e2e/tests && npx playwright install --with-deps && cd -
1919
- pnpm -C e2e/website install && pnpm -C e2e/website build
2020
- UNPACK_TO_DIST=true node scripts/downloadGithubRelease.mjs
2121
pre_build:
2222
commands:
2323
- pwd
2424
- pulumi version
25-
- cd e2e/infra/lambda && pulumi stack init e2e && pulumi stack select e2e && cd ../../..
26-
- cd e2e/infra/cloudfront && pulumi stack init e2e && pulumi stack select e2e && cd ../../..
27-
- cd e2e/infra && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd ../..
25+
- cd e2e/infra/lambda && pulumi stack init e2e && pulumi stack select e2e && cd -
26+
- cd e2e/infra/cloudfront && pulumi stack init e2e && pulumi stack select e2e && cd -
27+
- cd e2e/infra && pnpm run lambda:up && pnpm run lambda:export && pnpm run cloudfront:up && pnpm run cloudfront:export && cd -
2828
build:
2929
commands:
3030
- ls -a
3131
- cd e2e/tests && pnpm test
3232
finally:
33-
- cd ../..
33+
- cd -
3434
- echo $COMMIT_ID
35-
- cd e2e/infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd ../..
35+
- cd e2e/infra && pnpm cloudfront:destroy && pnpm lambda:destroy && cd -
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const commitSHA = process.env.COMMIT_SHA
2+
const gitHubRepo = process.env.GITHUB_REPOSITORY
3+
4+
const apiURL = `repos/${gitHubRepo}/commits/${commitSHA}/check-runs`
5+
const fullURL = `https://api.github.com/${apiURL}`
6+
7+
const E2E_TEST_NAME = "Run e2e for releases and pre-releases"
8+
const POLL_WAIT_DURATION = 30_000
9+
10+
function checkEnv() {
11+
if (!commitSHA) {
12+
throw new Error("env var COMMIT_SHA not found.")
13+
}
14+
15+
console.log(`COMMIT_SHA=${commitSHA}`)
16+
17+
if (!gitHubRepo) {
18+
throw new Error("env var GITHUB_REPOSITORY not found.")
19+
}
20+
21+
console.log(`GITHUB_REPOSITORY=${gitHubRepo}`)
22+
}
23+
24+
async function wait(ms) {
25+
return new Promise(resolve => setTimeout(resolve, ms))
26+
}
27+
28+
async function findCheckRun() {
29+
const response = await fetch(fullURL)
30+
if (!response.ok) {
31+
throw new Error(`request to GitHub failed with HTTP ${response.status}.`)
32+
}
33+
34+
const responseBody = await response.json()
35+
console.log(`# of check runs: ${responseBody.check_runs.length}`)
36+
return responseBody.check_runs.find(r => r.name === E2E_TEST_NAME)
37+
}
38+
39+
async function main() {
40+
checkEnv()
41+
42+
while (true) {
43+
const checkRun = await findCheckRun()
44+
if (checkRun) {
45+
const conclusion = checkRun.conclusion
46+
console.log(`conclusion=${conclusion}`)
47+
if (conclusion === "success") {
48+
break
49+
}
50+
51+
if (conclusion === "failure") {
52+
throw new Error("e2e test has failed. Exiting")
53+
}
54+
}
55+
56+
await wait(POLL_WAIT_DURATION)
57+
}
58+
59+
console.log("e2e test has passed! Exiting")
60+
}
61+
62+
63+
main().catch((err) => {
64+
console.error(err)
65+
process.exit(1)
66+
})

0 commit comments

Comments
 (0)