-
Notifications
You must be signed in to change notification settings - Fork 680
Translate smoketests from Python to Rust #4102
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
base: master
Are you sure you want to change the base?
Changes from all commits
921c76b
0df9a8b
8ddcdc9
7cc8e95
d830e22
b3de380
2d996f3
1db4180
bea9069
6373735
60cba8d
afb0a71
4f4aede
dafa004
8b6506b
447413b
c18ff5c
95308f2
ed2735e
fdba9e5
09b53de
017a744
8ebf8e6
17cfed7
03bbd19
828cc2d
157a814
f658b20
b8c31a9
da951e9
9835e1e
70bae5b
61cf2b8
a2db6af
ab70631
bd146c5
147f273
ba1f992
3c69f75
0f343aa
27be9ed
bfa3dcc
87f318c
4e7fee2
5a8107f
4ad3112
db95efd
c45e567
fcec6ee
9b47a1b
363f921
236b3d7
5b82570
0f67c82
fa54086
b5d01f3
bd0bb66
38deed2
ed86600
7414be7
42f679e
add5eff
73d2209
8fe5ac5
c5499c4
5266d58
833dc98
7385262
45af2bd
c1f53e9
7674202
06669e5
ee141de
bfc0252
c86854d
dad9b5e
017f42d
7f29dfc
45498b6
7790028
fe717bf
1a4ebcc
6d59cb1
46e63e4
941438a
6a47135
89a76f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,107 @@ concurrency: | |
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| docker_smoketests: | ||
| smoketests: | ||
| needs: [lints] | ||
| name: Smoketests | ||
| strategy: | ||
| matrix: | ||
| runner: [spacetimedb-new-runner, windows-latest] | ||
| include: | ||
| - runner: spacetimedb-new-runner | ||
| container: | ||
| image: localhost:5000/spacetimedb-ci:latest | ||
| options: --privileged | ||
| - runner: windows-latest | ||
| container: null | ||
| runs-on: ${{ matrix.runner }} | ||
| container: ${{ matrix.container }} | ||
| timeout-minutes: 120 | ||
| env: | ||
| CARGO_TARGET_DIR: ${{ github.workspace }}/target | ||
| steps: | ||
| - name: Find Git ref | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| shell: bash | ||
| run: | | ||
| PR_NUMBER="${{ github.event.inputs.pr_number || null }}" | ||
| if test -n "${PR_NUMBER}"; then | ||
| GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" | ||
| else | ||
| GIT_REF="${{ github.ref }}" | ||
| fi | ||
| echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ env.GIT_REF }} | ||
| - uses: dsherret/rust-toolchain-file@v1 | ||
| - name: Cache Rust dependencies | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: ${{ github.workspace }} | ||
| shared-key: spacetimedb | ||
| cache-on-failure: false | ||
| cache-all-crates: true | ||
| cache-workspace-crates: true | ||
| prefix-key: v1 | ||
|
|
||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| global-json-file: global.json | ||
|
|
||
| # nodejs and pnpm are required for the typescript quickstart smoketest | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 18 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: true | ||
|
|
||
| - name: Install psql (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install psql -y --no-progress | ||
| shell: powershell | ||
|
|
||
| - name: Update dotnet workloads | ||
| if: runner.os == 'Windows' | ||
| run: | | ||
| # Fail properly if any individual command fails | ||
| $ErrorActionPreference = 'Stop' | ||
| $PSNativeCommandUseErrorActionPreference = $true | ||
|
|
||
| cd modules | ||
| # the sdk-manifests on windows-latest are messed up, so we need to update them | ||
| dotnet workload config --update-mode manifests | ||
| dotnet workload update | ||
|
|
||
| # This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a. | ||
| # ChatGPT suspects that this could be due to different build invocations using the same target dir, | ||
| # and this makes sense to me because we only see it in this job where we mix `cargo build -p` with | ||
| # `cargo build --manifest-path` (which apparently build different dependency trees). | ||
| # However, we've been unable to fix it so... /shrug | ||
| - name: Check v8 outputs | ||
| shell: bash | ||
| run: | | ||
| find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true | ||
| if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then | ||
| echo "Could not find v8 output file librusty_v8.a; rebuilding manually." | ||
| cargo clean -p v8 || true | ||
| cargo build -p v8 | ||
| fi | ||
cloutiertyler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Install cargo-nextest | ||
| uses: taiki-e/install-action@nextest | ||
|
|
||
| - name: Run smoketests | ||
| run: cargo ci smoketests | ||
|
|
||
| smoketests-python: | ||
| needs: [lints] | ||
| name: Smoketests (Python Legacy) | ||
| strategy: | ||
| matrix: | ||
| runner: [spacetimedb-new-runner, windows-latest] | ||
|
|
@@ -92,8 +190,10 @@ jobs: | |
| if: runner.os == 'Windows' | ||
| run: choco install psql -y --no-progress | ||
| shell: powershell | ||
|
|
||
| - name: Build crates | ||
| run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update | ||
|
|
||
| - name: Start Docker daemon | ||
| if: runner.os == 'Linux' | ||
| run: /usr/local/bin/start-docker.sh | ||
|
|
@@ -104,6 +204,7 @@ jobs: | |
| # Our .dockerignore omits `target`, which our CI Dockerfile needs. | ||
| rm .dockerignore | ||
| docker compose -f .github/docker-compose.yml up -d | ||
|
|
||
| - name: Build and start database (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: | | ||
|
|
@@ -116,14 +217,18 @@ jobs: | |
| # the sdk-manifests on windows-latest are messed up, so we need to update them | ||
| dotnet workload config --update-mode manifests | ||
| dotnet workload update | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: { python-version: "3.12" } | ||
| if: runner.os == 'Windows' | ||
|
|
||
| - name: Install python deps | ||
| run: python -m pip install -r smoketests/requirements.txt | ||
| - name: Run smoketests | ||
|
|
||
| - name: Run Python smoketests | ||
| # Note: clear_database and replication only work in private | ||
| run: cargo ci smoketests -- ${{ matrix.smoketest_args }} -x clear_database replication teams | ||
| run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams | ||
|
|
||
| - name: Stop containers (Linux) | ||
| if: always() && runner.os == 'Linux' | ||
| run: docker compose -f .github/docker-compose.yml down | ||
|
|
@@ -906,3 +1011,32 @@ jobs: | |
| repo: targetRepo, | ||
| run_id: runId, | ||
| }); | ||
|
|
||
| warn-python-smoketests: | ||
| name: Check for Python smoketest edits | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Fail if Python smoketests were modified | ||
| run: | | ||
| PYTHON_SMOKETEST_CHANGES=$(git diff --name-only origin/${{ github.base_ref }} HEAD -- 'smoketests/**.py') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heads up, I realized that this will start failing in this PR if anyone merges changes into master that touch the smoketests, even if you don't merge master into this PR. I don't know that that's a bad thing, just wanted to mention it before it's confusing. if we wanted only-changed-in-this-PR logic, it would have to be: MERGE_BASE=$(git merge-base origin/${{ github.base_ref }} HEAD)
PYTHON_SMOKETEST_CHANGES="$(git diff --name-only $MERGE_BASE HEAD -- 'smoketests/**.py')"also we probably want to make this check required just before merging - I suggest leaving this comment unresolved until then. |
||
|
|
||
| if [ -n "$PYTHON_SMOKETEST_CHANGES" ]; then | ||
| echo "::error::This PR modifies legacy Python smoketests. Please add new tests to the Rust smoketests in crates/smoketests/ instead." | ||
| echo "" | ||
| echo "Changed files:" | ||
| echo "$PYTHON_SMOKETEST_CHANGES" | ||
| echo "" | ||
| echo "The Python smoketests are being replaced by Rust smoketests." | ||
| echo "See crates/smoketests/DEVELOP.md for instructions on adding Rust smoketests." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "No Python smoketest changes detected." | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose that instead of a new toplevel command, we just update
cargo ci smoketeststo run these commands.cargo ciis supposed to be the toplevel command that has all the specialty logic for running tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I thought about this, but that's not true of cargo test, which is also meant to run all the testing. My thought was that it should also live under
cargo ci smoketestwhich it currently does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is true for
cargo test, isn't it?cargo ci test? That's at least what that's meant to be.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't personally see the value in a new toplevel command when
ci smoketestsis right there, but I'm happy to keep it if you think it adds value.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean
cargo testexists in addition tocargo ci test, so my thought was that it would be the same forcargo smoketest.So that's why we have both:
cargo smoketestcargo ci smoketestWhere
cargo ci smoketestjust callscargo ci.