Skip to content

Commit 9f93e28

Browse files
authored
Merge branch 'master' into bfops/pnpm-install-instruction
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2 parents 0011f56 + fc784fd commit 9f93e28

799 files changed

Lines changed: 81872 additions & 16475 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.

.cargo/config.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@ rustflags = ["--cfg", "tokio_unstable"]
33

44
[alias]
55
bump-versions = "run -p upgrade-version --"
6+
7+
[target.x86_64-pc-windows-msvc]
8+
# Use a different linker. Otherwise, the build fails with some obscure linker error that
9+
# seems to be a result of us producing a massive PDB file.
10+
# I (@bfops) tried a variety of other link options besides switching linkers, but this
11+
# seems to be the only thing that worked.
12+
linker = "lld-link"
13+
# Without this, the linker complains that libc functions are undefined -
14+
# it probably signals to rustc and lld-link that libucrt should be included.
15+
rustflags = ["-Ctarget-feature=+crt-static"]

.env.sample

Lines changed: 0 additions & 2 deletions
This file was deleted.

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Directory environment using https://direnv.net/ and https://github.com/nix-community/nix-direnv.
2+
use flake

.github/workflows/ci.yml

Lines changed: 84 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,28 @@ on:
1313

1414
name: CI
1515

16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number || format('sha-{0}', github.sha) }}
18+
cancel-in-progress: true
19+
1620
jobs:
1721
docker_smoketests:
1822
name: Smoketests
1923
strategy:
2024
matrix:
25+
runner: [spacetimedb-new-runner, windows-latest]
2126
include:
22-
- { runner: spacetimedb-runner, smoketest_args: --docker }
23-
- { runner: windows-latest, smoketest_args: --no-build-cli }
24-
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
2535
runs-on: ${{ matrix.runner }}
36+
container: ${{ matrix.container }}
37+
2638
steps:
2739
- name: Find Git ref
2840
env:
@@ -44,10 +56,25 @@ jobs:
4456
- uses: actions/setup-dotnet@v4
4557
with:
4658
global-json-file: global.json
59+
60+
# nodejs and pnpm are required for the typescript quickstart smoketest
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: 18
65+
66+
- uses: pnpm/action-setup@v4
67+
with:
68+
run_install: true
69+
4770
- name: Install psql (Windows)
4871
if: runner.os == 'Windows'
4972
run: choco install psql -y --no-progress
5073
shell: powershell
74+
- name: Start Docker daemon
75+
if: runner.os == 'Linux'
76+
run: /usr/local/bin/start-docker.sh
77+
5178
- name: Build and start database (Linux)
5279
if: runner.os == 'Linux'
5380
run: docker compose up -d
@@ -58,12 +85,6 @@ jobs:
5885
$ErrorActionPreference = 'Stop'
5986
$PSNativeCommandUseErrorActionPreference = $true
6087
61-
# Use a different linker. Otherwise, the build fails with some obscure linker error that
62-
# seems to be a result of us producing a massive PDB file.
63-
# I (@bfops) tried a variety of other link options besides switching linkers, but this
64-
# seems to be the only thing that worked.
65-
$env:RUSTFLAGS='-Clinker=lld-link'
66-
6788
cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
6889
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
6990
cd modules
@@ -73,18 +94,22 @@ jobs:
7394
- uses: actions/setup-python@v5
7495
with: { python-version: '3.12' }
7596
if: runner.os == 'Windows'
76-
- name: Install psycopg2
77-
run: python -m pip install psycopg2-binary
97+
- name: Install python deps
98+
run: python -m pip install psycopg2-binary xmltodict
7899
- name: Run smoketests
79100
# Note: clear_database and replication only work in private
80-
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication
101+
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
81102
- name: Stop containers (Linux)
82103
if: always() && runner.os == 'Linux'
83104
run: docker compose down
84105

85106
test:
86107
name: Test Suite
87-
runs-on: spacetimedb-runner
108+
runs-on: spacetimedb-new-runner
109+
container:
110+
image: localhost:5000/spacetimedb-ci:latest
111+
options: >-
112+
--privileged
88113
steps:
89114
- name: Find Git ref
90115
env:
@@ -109,15 +134,32 @@ jobs:
109134
with:
110135
global-json-file: global.json
111136

137+
- name: Set up Node.js
138+
uses: actions/setup-node@v4
139+
with:
140+
node-version: 18
141+
142+
- uses: pnpm/action-setup@v4
143+
with:
144+
run_install: true
145+
112146
- name: Create /stdb dir
113147
run: |
114148
sudo mkdir /stdb
115149
sudo chmod 777 /stdb
116150
151+
- name: Build typescript module sdk
152+
working-directory: crates/bindings-typescript
153+
run: pnpm build
154+
117155
- name: Run cargo test
118156
#Note: Unreal tests will be run separately
119157
run: cargo test --all -- --skip unreal
120158

159+
# The fallocate tests have been flakely when running in parallel
160+
- name: Run fallocate tests
161+
run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1
162+
121163
- name: Check that the test outputs are up-to-date
122164
run: bash tools/check-diff.sh
123165

@@ -132,7 +174,11 @@ jobs:
132174

133175
lints:
134176
name: Lints
135-
runs-on: spacetimedb-runner
177+
runs-on: spacetimedb-new-runner
178+
container:
179+
image: localhost:5000/spacetimedb-ci:latest
180+
options: >-
181+
--privileged
136182
steps:
137183
- name: Checkout sources
138184
uses: actions/checkout@v3
@@ -171,7 +217,11 @@ jobs:
171217
172218
wasm_bindings:
173219
name: Build and test wasm bindings
174-
runs-on: spacetimedb-runner
220+
runs-on: spacetimedb-new-runner
221+
container:
222+
image: localhost:5000/spacetimedb-ci:latest
223+
options: >-
224+
--privileged
175225
steps:
176226
- uses: actions/checkout@v3
177227

@@ -196,7 +246,11 @@ jobs:
196246

197247
publish_checks:
198248
name: Check that packages are publishable
199-
runs-on: ubuntu-latest
249+
runs-on: spacetimedb-new-runner
250+
container:
251+
image: localhost:5000/spacetimedb-ci:latest
252+
options: >-
253+
--privileged
200254
permissions: read-all
201255
steps:
202256
- uses: actions/checkout@v3
@@ -206,11 +260,12 @@ jobs:
206260
venv/bin/pip3 install argparse toml
207261
- name: Run checks
208262
run: |
263+
set -ueo pipefail
209264
FAILED=0
210-
# This definition of ROOTS and invocation of find-publish-list.py is copied from publish-crates.sh
211-
ROOTS=(bindings sdk cli standalone)
212-
for crate in $(venv/bin/python3 tools/find-publish-list.py --recursive --quiet "${ROOTS[@]}"); do
213-
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
214269
FAILED=$(( $FAILED + 1 ))
215270
fi
216271
done
@@ -263,7 +318,9 @@ jobs:
263318
name: Unreal Engine Tests
264319
# 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
265320
# a custom runner.
266-
runs-on: spacetimedb-runner
321+
runs-on: spacetimedb-new-runner
322+
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
323+
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
267324
container:
268325
image: ghcr.io/epicgames/unreal-engine:dev-5.6
269326
credentials:
@@ -340,13 +397,17 @@ jobs:
340397
341398
cd "$GITHUB_WORKSPACE/sdks/unreal"
342399
cargo --version
343-
cargo test
400+
cargo test -- --test-threads=1
344401
'
345402
346403
cli_docs:
347404
name: Check CLI docs
348405
permissions: read-all
349-
runs-on: ubuntu-latest
406+
runs-on: spacetimedb-new-runner
407+
container:
408+
image: localhost:5000/spacetimedb-ci:latest
409+
options: >-
410+
--privileged
350411
steps:
351412
- name: Find Git ref
352413
env:

.github/workflows/csharp-test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ on:
66
- master
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
unity-testsuite:
11-
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
1221
# Cancel any previous testsuites running on the same PR and/or ref.
1322
concurrency:
1423
group: unity-test-${{ github.event.pull_request.number || github.ref }}
@@ -77,7 +86,7 @@ jobs:
7786
cargo install --force --path crates/cli --locked --message-format=short
7887
cargo install --force --path crates/standalone --locked --message-format=short
7988
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
80-
ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
89+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
8190
env:
8291
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
8392
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
@@ -153,6 +162,9 @@ jobs:
153162
key: Unity-${{ github.head_ref }}
154163
restore-keys: Unity-
155164

165+
# We need this to support "Docker in Docker"
166+
- name: Start Docker daemon
167+
run: /usr/local/bin/start-docker.sh
156168
- name: Run Unity tests
157169
uses: game-ci/unity-test-runner@v4
158170
with:
@@ -167,4 +179,4 @@ jobs:
167179
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
168180
# Skip if this is an external contribution.
169181
# The license secrets will be empty, so the step would fail anyway.
170-
if: ${{ !github.event.pull_request.head.repo.fork }}
182+
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}

.github/workflows/discord-posts.yml

Lines changed: 34 additions & 18 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 'name,state' |
27-
jq -r ".[] | select(.name==\"${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: |
44-
message="PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](${PR_URL})"
45-
message+=$'\n'
46-
message+="${CHECK_NAME} result: ${CHECK_RESULT}"
32+
message="PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](<${PR_URL}>)"
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+
'try .[$u] catch 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/docs-check-links.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)