-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: split rc e2e release into 2 workflows and migrate some of the cod…
…e to nodejs
- Loading branch information
1 parent
fe0fc54
commit fe530a1
Showing
4 changed files
with
122 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: AWS E2E for topic branch | ||
name: Run AWS E2E for topic branch | ||
|
||
on: | ||
pull_request: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Check AWS E2E for releases and pre-releases | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check-commit-with-tag-and-old-tests: | ||
runs-on: ubuntu-20.04 | ||
name: Check latest commit with tag and its checks | ||
steps: | ||
- name: 'Install latest node version' | ||
uses: actions/setup-node@v4 | ||
|
||
- name: Git clone | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check latest commit with tag | ||
id: latest_commit_with_test | ||
run: | | ||
diff=$(git log origin/$GITHUB_BASE_REF..HEAD --oneline --format="%H") | ||
echo "diff=$diff" | ||
latestCommitWithTag='' | ||
for commit in $diff; do | ||
echo "checking commit $commit for tag" | ||
tag=$(git tag --points-at "$commit") | ||
if [[ -n "$tag" ]]; then | ||
latestCommitWithTag=$commit | ||
break | ||
fi | ||
done | ||
echo "latestCommitWithTag=$latestCommitWithTag" | ||
echo "latestCommitWithTag=$latestCommitWithTag" >> $GITHUB_OUTPUT | ||
if [[ -z "$latestCommitWithTag" ]]; then | ||
echo "no tag has found. Skipping..." | ||
fi | ||
- name: Poll checks from GitHub | ||
if: steps.latest_commit_with_test.outputs.latestCommitWithTag != '' | ||
run: node scripts/checkCommitStatusForE2E.mjs | ||
env: | ||
COMMIT_SHA: ${{ steps.latest_commit_with_test.outputs.latestCommitWithTag }} | ||
GITHUB_REPOSITORY: ${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const commitSHA = process.env.COMMIT_SHA | ||
const gitHubRepo = process.env.GITHUB_REPOSITORY | ||
|
||
const apiURL = `repos/${gitHubRepo}/commits/${commitSHA}/check-runs` | ||
const fullURL = `https://api.github.com/${apiURL}` | ||
|
||
const E2E_TEST_NAME = "Run e2e for releases and pre-releases" | ||
const POLL_WAIT_DURATION = 30_000 | ||
|
||
function checkEnv() { | ||
if (!commitSHA) { | ||
throw new Error("env var COMMIT_SHA not found.") | ||
} | ||
|
||
console.log(`COMMIT_SHA=${commitSHA}`) | ||
|
||
if (!gitHubRepo) { | ||
throw new Error("env var GITHUB_REPOSITORY not found.") | ||
} | ||
|
||
console.log(`GITHUB_REPOSITORY=${gitHubRepo}`) | ||
} | ||
|
||
async function wait(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)) | ||
} | ||
|
||
async function findCheckRun() { | ||
const response = await fetch(fullURL) | ||
if (!response.ok) { | ||
throw new Error(`request to GitHub failed with HTTP ${response.status}.`) | ||
} | ||
|
||
const responseBody = await response.json() | ||
console.log(`# of check runs: ${responseBody.check_runs.length}`) | ||
return responseBody.check_runs.find(r => r.name === E2E_TEST_NAME) | ||
} | ||
|
||
async function main() { | ||
checkEnv() | ||
|
||
while (true) { | ||
const checkRun = await findCheckRun() | ||
if (checkRun) { | ||
const conclusion = checkRun.conclusion | ||
console.log(`conclusion=${conclusion}`) | ||
if (conclusion === "success") { | ||
break | ||
} | ||
|
||
if (conclusion === "failure") { | ||
throw new Error("e2e test has failed. Exiting") | ||
} | ||
} | ||
|
||
await wait(POLL_WAIT_DURATION) | ||
} | ||
|
||
console.log("e2e test has passed! Exiting") | ||
} | ||
|
||
|
||
main().catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |