-
Notifications
You must be signed in to change notification settings - Fork 642
CI - Move Internal Tests to GitHub
#3436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4f641b5
[bfops/internal-tests]: empty commit to allow PR creation
bfops d916aa6
[bfops/internal-tests]: WIP
bfops cb206b7
[bfops/internal-tests]: WIP
bfops c1f3a5c
[bfops/internal-tests]: permissions
bfops 7d68bc3
[bfops/internal-tests]: fix
bfops 4fdb184
[bfops/internal-tests]: foo
bfops 46ca40d
[bfops/internal-tests]: tweak
bfops 5703185
[bfops/internal-tests]: fix
bfops bf571ac
[bfops/internal-tests]: print
bfops 5908d80
[bfops/internal-tests]: [REVERT THIS TEST COMMIT] Bump versions to 1.7.0
bfops fec3cfc
[bfops/internal-tests]: revert test commit
bfops 1fc167e
Merge branch 'master' into bfops/internal-tests
bfops 62e739d
[bfops/internal-tests]: [REVERT THIS TEST COMMIT] Bump versions to 1.7.0
bfops 84c017d
[bfops/internal-tests]: revert test commit
bfops 0782765
[bfops/internal-tests]: minor tweak
bfops 0127c35
[bfops/internal-tests]: tweaks
bfops c1ad81f
[bfops/internal-tests]: update discord post job
bfops 51a03a6
[bfops/internal-tests]: [REVERT THIS TEST COMMIT] reduce timeout
bfops cb7edaa
[bfops/internal-tests]: revert test commit
bfops 0ec9626
[bfops/internal-tests]: date filter
bfops 3d861b8
[bfops/internal-tests]: resolve TODO
bfops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,105 @@ | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| name: Internal Tests | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| run-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
bfops marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
|
||
| - name: Print current ref and sha | ||
| run: | | ||
| echo "github.ref=${{ github.ref }}" | ||
| echo "github.sha=${{ github.sha }}" | ||
|
|
||
| - name: Trigger and wait for Internal Tests | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} | ||
| script: | | ||
| const targetOwner = 'clockworklabs'; | ||
| const targetRepo = 'SpacetimeDBPrivate'; | ||
| const workflowId = 'internal-tests.yml'; | ||
| const targetRef = 'master'; | ||
| const publicRef = context.sha; | ||
| const preDispatch = new Date().toISOString(); | ||
|
|
||
| // Dispatch the workflow in the target repository | ||
| await github.rest.actions.createWorkflowDispatch({ | ||
| owner: targetOwner, | ||
| repo: targetRepo, | ||
| workflow_id: workflowId, | ||
| ref: targetRef, | ||
| inputs: { public_ref: publicRef } | ||
| }); | ||
|
|
||
| const sleep = (ms) => new Promise(r => setTimeout(r, ms)); | ||
|
|
||
| // Wait for workflow to be kicked off | ||
| await sleep(30000); | ||
|
|
||
| // Find the dispatched run by name | ||
| let runId = null; | ||
| for (let attempt = 0; attempt < 20 && !runId; attempt++) { // up to ~10 minutes to locate the run | ||
| const runsResp = await github.rest.actions.listWorkflowRuns({ | ||
| owner: targetOwner, | ||
| repo: targetRepo, | ||
| workflow_id: workflowId, | ||
| event: 'workflow_dispatch', | ||
| branch: targetRef, | ||
| per_page: 50, | ||
| }); | ||
|
|
||
| const expectedName = `Internal Tests [${publicRef}]`; | ||
| const candidates = runsResp.data.workflow_runs | ||
| .filter(r => r.name === expectedName && new Date(r.created_at) >= new Date(preDispatch)) | ||
| .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | ||
|
|
||
| if (candidates.length > 0) { | ||
| runId = candidates[0].id; | ||
| break; | ||
| } | ||
| await sleep(30000); | ||
| } | ||
|
|
||
| if (!runId) { | ||
| core.setFailed('Failed to locate dispatched run in the private repository.'); | ||
| return; | ||
| } | ||
|
|
||
| // Provide direct link and context prior to waiting | ||
| const runUrl = `https://github.com/${targetOwner}/${targetRepo}/actions/runs/${runId}`; | ||
| core.info(`View run: ${runUrl}`); | ||
| core.info('Waiting for workflow result...'); | ||
|
|
||
| // Wait for completion | ||
| let conclusion = null; | ||
| for (let attempt = 0; attempt < 240; attempt++) { // up to ~2 hours | ||
| const runResp = await github.rest.actions.getWorkflowRun({ | ||
| owner: targetOwner, | ||
| repo: targetRepo, | ||
| run_id: runId | ||
| }); | ||
| const { status, conclusion: c } = runResp.data; | ||
| if (status === 'completed') { | ||
| conclusion = c || 'success'; | ||
| break; | ||
| } | ||
| await sleep(30000); | ||
| } | ||
|
|
||
| if (!conclusion) { | ||
| core.setFailed('Timed out waiting for private workflow to complete.'); | ||
bfops marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| core.info(`Private workflow conclusion: ${conclusion}`); | ||
| if (conclusion !== 'success') { | ||
| core.setFailed(`Private workflow failed with conclusion: ${conclusion}`); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.