Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 57 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,33 @@ jobs:
with:
persist-credentials: false
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- uses: taiki-e/install-action@3f74d7c16a4242f1c95561e98edc25d36adb4375 # v2.87.12
with:
tool: cargo-nextest@0.9.140
- name: Build the reference emulator
run: cargo build --locked --release -p refemu
- name: Archive the reference emulator's ROM suites
# In release, the build they need. The `emulator` group runs them.
run: |
mkdir -p target/nextest
cargo nextest archive --locked --release -p refemu --features rom-tests \
--archive-file target/nextest/rom-suites.tar.zst
- name: Upload refemu artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: refemu
path: target/release/refemu
- name: Upload the ROM suites archive
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: rom-suites
path: target/nextest/rom-suites.tar.zst

build-tests:
# Every test binary, compiled once into two nextest archives: the
# workspace with the live suites, and the reference emulator's release
# ROM suites. The test jobs run from the archives and compile nothing.
# The workspace's test binaries with the live suites, compiled once into
# two nextest archives, one per matrix entry: the native crate's suites,
# and every other crate's. The test jobs run from the archives and
# compile nothing.
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -115,30 +130,44 @@ jobs:
# its panic message with the file and line; a backtrace names
# functions only. Set for the job so rust-cache keys on it.
CARGO_PROFILE_TEST_DEBUG: "0"
strategy:
fail-fast: false
matrix:
include:
- archive: native
packages: -p clickdoom-native
- archive: workspace
packages: --workspace --exclude clickdoom-native
name: build-tests (${{ matrix.archive }})
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
key: ${{ matrix.archive }}
- uses: taiki-e/install-action@3f74d7c16a4242f1c95561e98edc25d36adb4375 # v2.87.12
with:
tool: cargo-nextest@0.9.140
- name: Archive the suites
env:
ARCHIVE: ${{ matrix.archive }}
PACKAGES: ${{ matrix.packages }}
run: |
mkdir -p target/nextest
cargo nextest archive --locked --workspace --features clickhouse-tests \
--archive-file target/nextest/tests.tar.zst
cargo nextest archive --locked --release -p refemu --features rom-tests \
--archive-file target/nextest/rom-suites.tar.zst
- name: Upload the archives
# shellcheck disable=SC2086 # $PACKAGES is a list of flags
cargo nextest archive --locked $PACKAGES --features clickhouse-tests \
--archive-file "target/nextest/$ARCHIVE.tar.zst"
- name: Upload the archive
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-archives
path: target/nextest/*.tar.zst
name: ${{ matrix.archive }}-tests
path: target/nextest/${{ matrix.archive }}.tar.zst

test:
# Every suite, in the groups scripts/test-group.sh names, one runner per
# group with its own ClickHouse, run from the archives build-tests made.
# group with its own ClickHouse, run from the archives build-tests and
# build-refemu made.
# Throwaway databases only; never `clickdoom`. `make test` runs the same
# suites in one pass locally.
needs: [build-tests, build-rom, build-refemu]
Expand Down Expand Up @@ -176,10 +205,25 @@ jobs:
tool: cargo-nextest@0.9.140
- name: Start the pinned ClickHouse
run: make up
- name: Download the test archives
# Each group downloads the archives scripts/test-group.sh runs it
# from, and a group that lacks one fails on the missing file.
- name: Download the native crate's suites
if: matrix.group != 'emulator'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: native-tests
path: target/nextest
- name: Download the other crates' suites
if: matrix.group == 'emulator' || matrix.group == 'native-rest'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: workspace-tests
path: target/nextest
- name: Download the ROM suites
if: matrix.group == 'emulator'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: test-archives
name: rom-suites
path: target/nextest
- name: Download ROM artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down
40 changes: 24 additions & 16 deletions scripts/test-group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,30 @@ cd "$(dirname "$0")/.."
group="${1-}"

# With NEXTEST_ARCHIVE_DIR set, the suites come pre-built from
# `cargo nextest archive` (tests.tar.zst for the workspace with the live
# suites, rom-suites.tar.zst for the reference emulator's release ROM
# suites) and nothing is compiled here. Without it, each run builds what it
# needs.
# `cargo nextest archive` and nothing is compiled here: native.tar.zst holds
# the native crate's suites, workspace.tar.zst every other crate's with the
# live suites, and rom-suites.tar.zst the reference emulator's release ROM
# suites. Each group names the archives it runs from. Without it, each run
# builds what it needs.
archive="${NEXTEST_ARCHIVE_DIR-}"
if [ -n "$archive" ]; then
# Extracted over the workspace rather than into a temporary directory:
# a test that runs the driver binary reaches it by the path compiled in
# at build time, which is the workspace's own target directory.
extract=(--workspace-remap . --extract-to . --extract-overwrite)
run() {
cargo nextest run --archive-file "$archive/tests.tar.zst" "${extract[@]}" "$@"
run_native() {
cargo nextest run --archive-file "$archive/native.tar.zst" "${extract[@]}" "$@"
}
run_workspace() {
cargo nextest run --archive-file "$archive/workspace.tar.zst" "${extract[@]}" "$@"
}
run_rom() {
cargo nextest run --archive-file "$archive/rom-suites.tar.zst" "${extract[@]}" "$@"
}
live=""
else
run() { cargo nextest run --locked "$@"; }
run_native() { cargo nextest run --locked "$@"; }
run_workspace() { cargo nextest run --locked "$@"; }
run_rom() { cargo nextest run --locked --release -p refemu --features rom-tests "$@"; }
live="--workspace --features clickhouse-tests"
fi
Expand Down Expand Up @@ -90,7 +95,7 @@ case "$group" in
# them would warm or cool, and the connection suite counts the
# server's connections, which a neighbour's session would move.
# shellcheck disable=SC2086 # $live is a list of flags or nothing
run $live --test-threads 1 \
run_workspace $live --test-threads 1 \
-E 'not package(clickdoom-native) and (not binary(/^native_/) or binary(native_connections_live))'
# The ROM suites are the reference emulator's, so only it is built
# in release.
Expand All @@ -105,38 +110,41 @@ case "$group" in
# measured length. A runner with more cores sets TEST_THREADS higher.
native-sim-a)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and ($sim_a)"
;;
native-sim-b)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and ($sim_b)"
;;
native-sim-c)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and ($sim_c)"
;;
native-sim-d)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and ($sim_d)"
;;
native-sim-e)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and binary(/^sim_/) and not ($sim_a | $sim_b | $sim_c | $sim_d | $sim_f)"
;;
native-sim-f)
# shellcheck disable=SC2086
run $live --test-threads "${TEST_THREADS:-4}" \
run_native $live --test-threads "${TEST_THREADS:-4}" \
-E "package(clickdoom-native) and ($sim_f)"
;;
native-rest)
# shellcheck disable=SC2086
run $live --test-threads 2 \
-E '(package(clickdoom-native) and not binary(/^sim_/)) or (package(clickdoom-driver) and binary(/^native_/) and not binary(native_connections_live))'
run_native $live --test-threads 2 \
-E 'package(clickdoom-native) and not binary(/^sim_/)'
# shellcheck disable=SC2086
run_workspace $live --test-threads 2 \
-E 'package(clickdoom-driver) and binary(/^native_/) and not binary(native_connections_live)'
;;
*)
echo "usage: scripts/test-group.sh emulator|native-sim-a|native-sim-b|native-sim-c|native-sim-d|native-sim-e|native-sim-f|native-rest" >&2
Expand Down
Loading