Skip to content

Commit 1a82585

Browse files
authored
Merge branch 'master' into tyler/clear-on-conflict
2 parents b4e3458 + 47ac2b9 commit 1a82585

315 files changed

Lines changed: 10000 additions & 16264 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ jobs:
2222
name: Smoketests
2323
strategy:
2424
matrix:
25+
runner: [spacetimedb-new-runner, windows-latest]
2526
include:
26-
- { runner: spacetimedb-runner, smoketest_args: --docker }
27-
- { runner: windows-latest, smoketest_args: --no-build-cli }
28-
runner: [ spacetimedb-runner, windows-latest ]
27+
- runner: spacetimedb-new-runner
28+
smoketest_args: --docker
29+
container:
30+
image: localhost:5000/spacetimedb-ci:latest
31+
options: --privileged
32+
- runner: windows-latest
33+
smoketest_args: --no-build-cli
34+
container: null
2935
runs-on: ${{ matrix.runner }}
36+
container: ${{ matrix.container }}
37+
3038
steps:
3139
- name: Find Git ref
3240
env:
@@ -63,6 +71,10 @@ jobs:
6371
if: runner.os == 'Windows'
6472
run: choco install psql -y --no-progress
6573
shell: powershell
74+
- name: Start Docker daemon
75+
if: runner.os == 'Linux'
76+
run: /usr/local/bin/start-docker.sh
77+
6678
- name: Build and start database (Linux)
6779
if: runner.os == 'Linux'
6880
run: docker compose up -d
@@ -93,7 +105,11 @@ jobs:
93105

94106
test:
95107
name: Test Suite
96-
runs-on: spacetimedb-runner
108+
runs-on: spacetimedb-new-runner
109+
container:
110+
image: localhost:5000/spacetimedb-ci:latest
111+
options: >-
112+
--privileged
97113
steps:
98114
- name: Find Git ref
99115
env:
@@ -140,8 +156,9 @@ jobs:
140156
#Note: Unreal tests will be run separately
141157
run: cargo test --all -- --skip unreal
142158

159+
# The fallocate tests have been flakely when running in parallel
143160
- name: Run fallocate tests
144-
run: cargo test -p spacetimedb-durability --features fallocate
161+
run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1
145162

146163
- name: Check that the test outputs are up-to-date
147164
run: bash tools/check-diff.sh
@@ -157,7 +174,11 @@ jobs:
157174

158175
lints:
159176
name: Lints
160-
runs-on: spacetimedb-runner
177+
runs-on: spacetimedb-new-runner
178+
container:
179+
image: localhost:5000/spacetimedb-ci:latest
180+
options: >-
181+
--privileged
161182
steps:
162183
- name: Checkout sources
163184
uses: actions/checkout@v3
@@ -196,7 +217,11 @@ jobs:
196217
197218
wasm_bindings:
198219
name: Build and test wasm bindings
199-
runs-on: spacetimedb-runner
220+
runs-on: spacetimedb-new-runner
221+
container:
222+
image: localhost:5000/spacetimedb-ci:latest
223+
options: >-
224+
--privileged
200225
steps:
201226
- uses: actions/checkout@v3
202227

@@ -221,7 +246,11 @@ jobs:
221246

222247
publish_checks:
223248
name: Check that packages are publishable
224-
runs-on: ubuntu-latest
249+
runs-on: spacetimedb-new-runner
250+
container:
251+
image: localhost:5000/spacetimedb-ci:latest
252+
options: >-
253+
--privileged
225254
permissions: read-all
226255
steps:
227256
- uses: actions/checkout@v3
@@ -231,11 +260,12 @@ jobs:
231260
venv/bin/pip3 install argparse toml
232261
- name: Run checks
233262
run: |
263+
set -ueo pipefail
234264
FAILED=0
235-
# This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh
236-
ROOTS=(bindings sdk cli standalone)
237-
for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do
238-
if ! venv/bin/python3 tools/crate-publish-checks.py "crates/$crate"; then
265+
ROOTS=(spacetimedb spacetimedb-sdk)
266+
CRATES=$(venv/bin/python3 tools/find-publish-list.py --recursive --directories --quiet "${ROOTS[@]}")
267+
for crate_dir in $CRATES; do
268+
if ! venv/bin/python3 tools/crate-publish-checks.py "${crate_dir}"; then
239269
FAILED=$(( $FAILED + 1 ))
240270
fi
241271
done
@@ -288,7 +318,7 @@ jobs:
288318
name: Unreal Engine Tests
289319
# This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use
290320
# a custom runner.
291-
runs-on: spacetimedb-runner
321+
runs-on: spacetimedb-new-runner
292322
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
293323
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
294324
container:
@@ -367,13 +397,17 @@ jobs:
367397
368398
cd "$GITHUB_WORKSPACE/sdks/unreal"
369399
cargo --version
370-
cargo test
400+
cargo test -- --test-threads=1
371401
'
372402
373403
cli_docs:
374404
name: Check CLI docs
375405
permissions: read-all
376-
runs-on: ubuntu-latest
406+
runs-on: spacetimedb-new-runner
407+
container:
408+
image: localhost:5000/spacetimedb-ci:latest
409+
options: >-
410+
--privileged
377411
steps:
378412
- name: Find Git ref
379413
env:

.github/workflows/csharp-test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ concurrency:
1212

1313
jobs:
1414
unity-testsuite:
15-
runs-on: spacetimedb-runner
15+
runs-on: spacetimedb-new-runner
16+
container:
17+
image: localhost:5000/spacetimedb-ci:latest
18+
options: >-
19+
--privileged
20+
--cgroupns=host
1621
# Cancel any previous testsuites running on the same PR and/or ref.
1722
concurrency:
1823
group: unity-test-${{ github.event.pull_request.number || github.ref }}
@@ -81,7 +86,7 @@ jobs:
8186
cargo install --force --path crates/cli --locked --message-format=short
8287
cargo install --force --path crates/standalone --locked --message-format=short
8388
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
84-
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
89+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
8590
env:
8691
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
8792
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
@@ -157,6 +162,9 @@ jobs:
157162
key: Unity-${{ github.head_ref }}
158163
restore-keys: Unity-
159164

165+
# We need this to support "Docker in Docker"
166+
- name: Start Docker daemon
167+
run: /usr/local/bin/start-docker.sh
160168
- name: Run Unity tests
161169
uses: game-ci/unity-test-runner@v4
162170
with:

.github/workflows/discord-posts.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
if: github.event.pull_request.merged == true &&
1111
github.event.pull_request.base.ref == 'master'
1212
env:
13-
CHECK_NAME: Internal Tests
1413
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1514
steps:
1615
- name: Set up GitHub CLI
@@ -21,34 +20,51 @@ jobs:
2120
sudo apt-get update
2221
sudo apt-get install -y gh
2322
24-
- name: Fetch Check Run Results
25-
run: |
26-
RESULT="$(gh pr checks "${{github.event.pull_request.html_url}}" --json 'workflow,state' |
27-
jq -r ".[] | select(.workflow==\"${CHECK_NAME}\").state")"
28-
29-
if [ -z "$RESULT" ]; then
30-
RESULT="The check did not run!"
31-
fi
32-
33-
echo "CHECK_RESULT=${RESULT}" >> $GITHUB_ENV
34-
3523
- name: Send Discord notification
3624
env:
3725
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
3826
PR_TITLE: ${{ github.event.pull_request.title }}
3927
PR_NUMBER: ${{ github.event.pull_request.number }}
4028
PR_URL: ${{ github.event.pull_request.html_url }}
41-
CHECK_RESULT: ${{ env.CHECK_RESULT }}
4229
MENTION_ON_FAILURE: ${{ secrets.DEV_OPS_ROLE_ID }}
30+
DISCORD_USER_MAP: ${{ secrets.DISCORD_USER_MAP }}
4331
run: |
4432
message="PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](<${PR_URL}>)"
45-
message+=$'\n'
46-
message+="${CHECK_NAME} result: ${CHECK_RESULT}"
4733
# Note that anything besides success is treated as a failure (e.g. if the check did not run at all, or if it is still pending).
48-
if [[ "${CHECK_RESULT}" != "SUCCESS" ]]; then
34+
FAILED_CHECKS="$(
35+
gh pr checks "${{github.event.pull_request.html_url}}" \
36+
--json 'workflow,state,name' |
37+
jq '.[]
38+
| select(.workflow != "Discord notifications")
39+
| select(.state != "SUCCESS" and .state != "NEUTRAL")
40+
' |
41+
jq -r '"\(.workflow) / \(.name): \(.state)"'
42+
)"
43+
44+
# Lookup PR author's Discord ID from the provided JSON map (if any)
45+
author_discord_id="$(
46+
jq -r \
47+
--arg u "${{ github.event.pull_request.user.login }}" \
48+
'.[$u] // empty' \
49+
<<<"${DISCORD_USER_MAP}"
50+
)"
51+
if [ -z "${author_discord_id}" ]; then
52+
echo "Warning: PR author not found not found in USER_LOOKUP_JSON"
53+
fi
54+
55+
message+=$'\n'
56+
if [[ -z "${FAILED_CHECKS}" ]]; then
57+
message+='All checks passed.'
58+
else
59+
message+="${FAILED_CHECKS}"
60+
message+=$'\n'
4961
# This uses special Discord syntax for pinging a particular role.
5062
# Note the '&' - this is the difference between pinging a *role* and pinging a *person*.
51-
message+=" (cc <@&${MENTION_ON_FAILURE}>)"
63+
message+=" (cc <@&${MENTION_ON_FAILURE}>"
64+
if [[ -n "${author_discord_id}" ]]; then
65+
message+=" <@${author_discord_id}>"
66+
fi
67+
message+=")"
5268
fi
5369
# Use `jq` to construct the json data blob in the format required by the webhook.
5470
data="$(jq --null-input --arg msg "$message" '.content=$msg')"

.github/workflows/internal-tests.yml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ jobs:
1818
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
1919
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
2020
runs-on: ubuntu-latest
21+
env:
22+
TARGET_OWNER: clockworklabs
23+
TARGET_REPO: SpacetimeDBPrivate
2124
steps:
22-
- name: Trigger and wait for Internal Tests
25+
- id: dispatch
26+
name: Trigger tests
2327
uses: actions/github-script@v7
2428
with:
2529
github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }}
2630
script: |
27-
const targetOwner = 'clockworklabs';
28-
const targetRepo = 'SpacetimeDBPrivate';
29-
const workflowId = 'internal-tests.yml';
31+
const workflowId = 'ci.yml';
3032
const targetRef = 'master';
33+
const targetOwner = process.env.TARGET_OWNER;
34+
const targetRepo = process.env.TARGET_REPO;
3135
// Use the ref for pull requests because the head sha is brittle (github does some extra dance where it merges in master).
3236
const publicRef = (context.eventName === 'pull_request') ? context.payload.pull_request.head.ref : context.sha;
3337
const preDispatch = new Date().toISOString();
@@ -48,12 +52,10 @@ jobs:
4852
4953
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
5054
51-
// Wait for workflow to be kicked off
52-
await sleep(30000);
53-
5455
// Find the dispatched run by name
5556
let runId = null;
5657
for (let attempt = 0; attempt < 20 && !runId; attempt++) { // up to ~10 minutes to locate the run
58+
await sleep(5000);
5759
const runsResp = await github.rest.actions.listWorkflowRuns({
5860
owner: targetOwner,
5961
repo: targetRepo,
@@ -63,7 +65,7 @@ jobs:
6365
per_page: 50,
6466
});
6567
66-
const expectedName = `Internal Tests [${publicRef}]`;
68+
const expectedName = `CI [public_ref=${publicRef}]`;
6769
const candidates = runsResp.data.workflow_runs
6870
.filter(r => r.name === expectedName && new Date(r.created_at) >= new Date(preDispatch))
6971
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
@@ -72,7 +74,6 @@ jobs:
7274
runId = candidates[0].id;
7375
break;
7476
}
75-
await sleep(30000);
7677
}
7778
7879
if (!runId) {
@@ -83,9 +84,23 @@ jobs:
8384
// Provide direct link and context prior to waiting
8485
const runUrl = `https://github.com/${targetOwner}/${targetRepo}/actions/runs/${runId}`;
8586
core.info(`View run: ${runUrl}`);
86-
core.info('Waiting for workflow result...');
8787
88-
// Wait for completion
88+
core.setOutput('run_id', String(runId));
89+
core.setOutput('run_url', runUrl);
90+
91+
- name: Wait for Internal Tests to complete
92+
uses: actions/github-script@v7
93+
with:
94+
github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }}
95+
script: |
96+
const targetOwner = process.env.TARGET_OWNER;
97+
const targetRepo = process.env.TARGET_REPO;
98+
const runId = Number(`${{ steps.dispatch.outputs.run_id }}`);
99+
const runUrl = `${{ steps.dispatch.outputs.run_url }}`;
100+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
101+
102+
core.info(`Waiting for workflow result... ${runUrl}`);
103+
89104
let conclusion = null;
90105
for (let attempt = 0; attempt < 240; attempt++) { // up to ~2 hours
91106
const runResp = await github.rest.actions.getWorkflowRun({
@@ -110,3 +125,24 @@ jobs:
110125
if (conclusion !== 'success') {
111126
core.setFailed(`Private workflow failed with conclusion: ${conclusion}`);
112127
}
128+
129+
- name: Cancel invoked run if workflow cancelled
130+
if: ${{ cancelled() }}
131+
uses: actions/github-script@v7
132+
with:
133+
github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }}
134+
script: |
135+
const targetOwner = process.env.TARGET_OWNER;
136+
const targetRepo = process.env.TARGET_REPO;
137+
const runId = Number(`${{ steps.dispatch.outputs.run_id }}`);
138+
if (!runId) {
139+
core.warning('No run_id available to cancel.');
140+
return;
141+
}
142+
core.info(`Cancelling private workflow run ${runId} in ${targetOwner}/${targetRepo}...`);
143+
await github.rest.actions.cancelWorkflowRun({
144+
owner: targetOwner,
145+
repo: targetRepo,
146+
run_id: runId,
147+
});
148+
core.info('Cancellation requested.');

0 commit comments

Comments
 (0)