CI - Parallelize smoketests #15935
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
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| merge_group: | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'Pull Request Number' | |
| required: false | |
| default: '' | |
| name: CI | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number || format('sha-{0}', github.sha) }} | |
| cancel-in-progress: true | |
| jobs: | |
| docker_smoketests: | |
| name: Smoketests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runner: [spacetimedb-new-runner, windows-latest] | |
| include: | |
| - runner: spacetimedb-new-runner | |
| smoketest_args: --docker | |
| container: | |
| image: localhost:5000/spacetimedb-ci:latest | |
| options: --privileged | |
| - runner: windows-latest | |
| smoketest_args: --no-build-cli | |
| container: null | |
| runs-on: ${{ matrix.runner }} | |
| container: ${{ matrix.container }} | |
| timeout-minutes: 120 | |
| env: | |
| CARGO_TARGET_DIR: ${{ github.workspace }}/target | |
| # Note: clear_database and replication only work in private | |
| SMOKETEST_ARGS: ${{ matrix.smoketest_args }} -x clear_database replication teams | |
| 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: Build crates | |
| run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update | |
| # TODO: This should be helpful on any platform.. but on Windows, `cargo ci` still ends up doing | |
| # a bunch of rebuilding when it runs `cargo build` internally. | |
| if: runner.os == 'Linux' | |
| - name: Find spacetime binary | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -x | |
| which spacetime || true | |
| find target/debug/ || true | |
| - name: Expand Docker network pool | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo 'current contents:' | |
| cat /etc/docker/daemon.json | |
| echo 'New contents': | |
| echo '{ | |
| "storage-driver": "vfs", | |
| "default-address-pools": [ | |
| { "base": "10.10.0.0/16", "size": 24 }, | |
| { "base": "10.20.0.0/16", "size": 24 } | |
| ] | |
| }' | sudo tee /etc/docker/daemon.json | |
| sudo service docker restart | |
| - name: Start Docker daemon | |
| if: runner.os == 'Linux' | |
| run: /usr/local/bin/start-docker.sh | |
| - 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 (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| export RUST_LOG=debug | |
| # Pre-build the crates because this docker compose file uses whatever's pre-built | |
| cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update | |
| # Our .dockerignore omits `target`, which our CI Dockerfile needs. | |
| rm .dockerignore | |
| cargo ci smoketests --docker .github/docker-compose.yml --parallel -- ${SMOKETEST_ARGS} | |
| - name: Run smoketests (Windows) | |
| if: runner.os == 'Windows' | |
| run: cargo ci smoketests --parallel -- ${SMOKETEST_ARGS} |