Skip to content

Commit 978d2f2

Browse files
committed
fix(ci) :: move rust test harness steps into scripts
Previously these scripts were embedded into the CI so they couldn't easly be run locally without copying, editing, and pasting the block to run in your terminal. Now they are in `scripts/`. This commit also updates the README to better explain the purpose of the scripts.
1 parent 4bbc429 commit 978d2f2

4 files changed

Lines changed: 52 additions & 39 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,7 @@ jobs:
5050
# different DATABASE_URL values. Package the Linux test executables once
5151
# here so those jobs do not recompile SQLPage or its dependencies.
5252
- name: Package Linux Rust test binaries
53-
run: |
54-
set -euo pipefail
55-
rm -rf target/sqlpage-test-binaries
56-
mkdir -p target/sqlpage-test-binaries
57-
cargo test --features odbc-static --no-run --message-format=json \
58-
| jq -r 'select(.profile.test == true and .executable != null) | .executable' \
59-
| while IFS= read -r test_binary; do
60-
cp -- "$test_binary" target/sqlpage-test-binaries/
61-
done
62-
test -n "$(find target/sqlpage-test-binaries -maxdepth 1 -type f -print -quit)"
63-
tar -C target/sqlpage-test-binaries -czf target/sqlpage-linux-test-binaries.tar.gz .
53+
run: scripts/package-test-binaries.sh
6454
- name: Build Linux binary
6555
run: cargo build --features odbc-static
6656
- name: Upload Linux Rust test binaries
@@ -150,19 +140,7 @@ jobs:
150140
run: docker compose logs ${{ matrix.container }}
151141
- name: Run tests against ${{ matrix.database }}
152142
timeout-minutes: 5
153-
run: |
154-
set -euo pipefail
155-
shopt -s nullglob
156-
test_binaries=(target/sqlpage-test-binaries/*)
157-
if ((${#test_binaries[@]} == 0)); then
158-
echo "No test binaries were found in target/sqlpage-test-binaries" >&2
159-
exit 1
160-
fi
161-
for test_binary in "${test_binaries[@]}"; do
162-
echo "::group::$(basename "$test_binary")"
163-
"$test_binary" --quiet
164-
echo "::endgroup::"
165-
done
143+
run: scripts/run-test-binaries.sh
166144
env:
167145
DATABASE_URL: ${{ matrix.db_url }}
168146
MALLOC_CHECK_: 3

‎scripts/README.md‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
# Docker Build Scripts
1+
# Scripts
22

3-
This directory contains scripts used by the Dockerfile to build SQLPage with cross-compilation support.
3+
## The Dockerfile runs these
44

5-
## Scripts
5+
- **`setup-cross-compilation.sh`** :: (1) Sets up the cross-compilation environment from the target and build architectures; (2) Installs system dependencies and cross-compilers; and (3) extracts libgcc for the runtime stage.
6+
- **`build-dependencies.sh`** :: Builds only the dependencies for Docker layer caching.
7+
- **`build-project.sh`**: Builds the SQLPage binary.
8+
- **`build-frontend.mjs`**: Bundles the browser assets into `frontend/dist`. Also callable via `npm run build`.
9+
- **`install-duckdb-odbc.sh`**: Installs the DuckDB ODBC driver into the `duckdb` image variant.
10+
- **`setup-sqlpage-user.sh`**: Creates the unprivileged user the images run as.
611

7-
- **`setup-cross-compilation.sh`**: Sets up the cross-compilation environment based on target and build architectures. Handles system dependencies, cross-compiler installation, and libgcc extraction for runtime.
8-
- **`build-dependencies.sh`**: Builds only the project dependencies for Docker layer caching
9-
- **`build-project.sh`**: Builds the final SQLPage binary
12+
These scripts pass configuration between build stages through temporary files in `/tmp/`.
1013

11-
## Usage
14+
## CI runs these
1215

13-
These scripts are automatically copied and executed by the Dockerfile during the build process. They handle:
14-
15-
- Cross-compilation setup for different architectures (amd64, arm64, arm)
16-
- System dependencies installation
17-
- Cargo build configuration with appropriate linkers
18-
- Library extraction for runtime
19-
20-
The scripts use temporary files in `/tmp/` to pass configuration between stages and export environment variables for use in subsequent build steps.
16+
- **`package-test-binaries.sh`**: Compiles the Rust test harnesses once and tars them, so the database matrix runs the same executables instead of recompiling SQLPage six times.
17+
- **`run-test-binaries.sh`**: Runs SQLPage compiled executables against whatever `DATABASE_URL` names.
18+
- **`test-examples-hurl.sh`**: Starts an example's containers and runs its `test.hurl` suite. Takes an example path to filter on.

‎scripts/package-test-binaries.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
5+
6+
BINARY_DIR=target/sqlpage-test-binaries
7+
ARCHIVE=target/sqlpage-linux-test-binaries.tar.gz
8+
9+
rm -rf "$BINARY_DIR"
10+
mkdir -p "$BINARY_DIR"
11+
12+
cargo test --features odbc-static --no-run --message-format=json \
13+
| jq -r 'select(.profile.test == true and .executable != null) | .executable' \
14+
| while IFS= read -r test_binary; do
15+
cp -- "$test_binary" "$BINARY_DIR/"
16+
done
17+
18+
test -n "$(find "$BINARY_DIR" -maxdepth 1 -type f -print -quit)"
19+
tar -C "$BINARY_DIR" -czf "$ARCHIVE" .

‎scripts/run-test-binaries.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
5+
6+
shopt -s nullglob
7+
test_binaries=(target/sqlpage-test-binaries/*)
8+
9+
if ((${#test_binaries[@]} == 0)); then
10+
echo "No test binaries were found in target/sqlpage-test-binaries" >&2
11+
exit 1
12+
fi
13+
14+
for test_binary in "${test_binaries[@]}"; do
15+
echo "::group::$(basename "$test_binary")"
16+
"$test_binary" --quiet
17+
echo "::endgroup::"
18+
done

0 commit comments

Comments
 (0)