-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use github api scripts to wait for tests
- Loading branch information
Showing
2 changed files
with
60 additions
and
12 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 |
---|---|---|
|
@@ -14,13 +14,37 @@ jobs: | |
wait-for-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Wait for unit tests to succeed | ||
uses: lewagon/[email protected] | ||
- uses: actions/github-script@v6 | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: 'run-unit-tests' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-interval: 10 | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const { owner, repo } = context.repo; | ||
const ref = context.sha; | ||
while (true) { | ||
const { data: checks } = await github.rest.checks.listForRef({ | ||
owner, | ||
repo, | ||
ref, | ||
check_name: 'run-unit-tests' | ||
}); | ||
if (checks.check_runs.length > 0) { | ||
const status = checks.check_runs[0].status; | ||
const conclusion = checks.check_runs[0].conclusion; | ||
if (status === 'completed') { | ||
if (conclusion === 'success') { | ||
console.log('Tests passed!'); | ||
break; | ||
} else { | ||
throw new Error('Tests failed!'); | ||
} | ||
} | ||
} | ||
await new Promise(r => setTimeout(r, 10000)); | ||
} | ||
docker: | ||
needs: wait-for-tests | ||
|
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 |
---|---|---|
|
@@ -14,13 +14,37 @@ jobs: | |
wait-for-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Wait for unit tests to succeed | ||
uses: lewagon/[email protected] | ||
- uses: actions/github-script@v6 | ||
with: | ||
ref: ${{ github.ref }} | ||
check-name: 'run-unit-tests' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-interval: 10 | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const { owner, repo } = context.repo; | ||
const ref = context.sha; | ||
while (true) { | ||
const { data: checks } = await github.rest.checks.listForRef({ | ||
owner, | ||
repo, | ||
ref, | ||
check_name: 'run-unit-tests' | ||
}); | ||
if (checks.check_runs.length > 0) { | ||
const status = checks.check_runs[0].status; | ||
const conclusion = checks.check_runs[0].conclusion; | ||
if (status === 'completed') { | ||
if (conclusion === 'success') { | ||
console.log('Tests passed!'); | ||
break; | ||
} else { | ||
throw new Error('Tests failed!'); | ||
} | ||
} | ||
} | ||
await new Promise(r => setTimeout(r, 10000)); | ||
} | ||
docker: | ||
needs: wait-for-tests | ||
|