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
26 changes: 2 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,7 @@ jobs:
# different DATABASE_URL values. Package the Linux test executables once
# here so those jobs do not recompile SQLPage or its dependencies.
- name: Package Linux Rust test binaries
run: |
set -euo pipefail
rm -rf target/sqlpage-test-binaries
mkdir -p target/sqlpage-test-binaries
cargo test --features odbc-static --no-run --message-format=json \
| jq -r 'select(.profile.test == true and .executable != null) | .executable' \
| while IFS= read -r test_binary; do
cp -- "$test_binary" target/sqlpage-test-binaries/
done
test -n "$(find target/sqlpage-test-binaries -maxdepth 1 -type f -print -quit)"
tar -C target/sqlpage-test-binaries -czf target/sqlpage-linux-test-binaries.tar.gz .
run: scripts/package-test-binaries.sh
- name: Build Linux binary
run: cargo build --features odbc-static
- name: Upload Linux Rust test binaries
Expand Down Expand Up @@ -150,19 +140,7 @@ jobs:
run: docker compose logs ${{ matrix.container }}
- name: Run tests against ${{ matrix.database }}
timeout-minutes: 5
run: |
set -euo pipefail
shopt -s nullglob
test_binaries=(target/sqlpage-test-binaries/*)
if ((${#test_binaries[@]} == 0)); then
echo "No test binaries were found in target/sqlpage-test-binaries" >&2
exit 1
fi
for test_binary in "${test_binaries[@]}"; do
echo "::group::$(basename "$test_binary")"
"$test_binary" --quiet
echo "::endgroup::"
done
run: scripts/run-test-binaries.sh
env:
DATABASE_URL: ${{ matrix.db_url }}
MALLOC_CHECK_: 3
Expand Down
28 changes: 13 additions & 15 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Docker Build Scripts
# Scripts

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

## Scripts
- **`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.
- **`build-dependencies.sh`** :: Builds only the dependencies for Docker layer caching.
- **`build-project.sh`**: Builds the SQLPage binary.
- **`build-frontend.mjs`**: Bundles the browser assets into `frontend/dist`. Also callable via `npm run build`.
- **`install-duckdb-odbc.sh`**: Installs the DuckDB ODBC driver into the `duckdb` image variant.
- **`setup-sqlpage-user.sh`**: Creates the unprivileged user the images run as.

- **`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.
- **`build-dependencies.sh`**: Builds only the project dependencies for Docker layer caching
- **`build-project.sh`**: Builds the final SQLPage binary
These scripts pass configuration between build stages through temporary files in `/tmp/`.

## Usage
## CI runs these

These scripts are automatically copied and executed by the Dockerfile during the build process. They handle:

- Cross-compilation setup for different architectures (amd64, arm64, arm)
- System dependencies installation
- Cargo build configuration with appropriate linkers
- Library extraction for runtime

The scripts use temporary files in `/tmp/` to pass configuration between stages and export environment variables for use in subsequent build steps.
- **`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.
- **`run-test-binaries.sh`**: Runs SQLPage compiled executables against whatever `DATABASE_URL` names.
- **`test-examples-hurl.sh`**: Starts an example's containers and runs its `test.hurl` suite. Takes an example path to filter on.
19 changes: 19 additions & 0 deletions scripts/package-test-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

BINARY_DIR=target/sqlpage-test-binaries
ARCHIVE=target/sqlpage-linux-test-binaries.tar.gz

rm -rf "$BINARY_DIR"
mkdir -p "$BINARY_DIR"

cargo test --features odbc-static --no-run --message-format=json \
| jq -r 'select(.profile.test == true and .executable != null) | .executable' \
| while IFS= read -r test_binary; do
cp -- "$test_binary" "$BINARY_DIR/"
done

test -n "$(find "$BINARY_DIR" -maxdepth 1 -type f -print -quit)"
tar -C "$BINARY_DIR" -czf "$ARCHIVE" .
18 changes: 18 additions & 0 deletions scripts/run-test-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

shopt -s nullglob
test_binaries=(target/sqlpage-test-binaries/*)

if ((${#test_binaries[@]} == 0)); then
echo "No test binaries were found in target/sqlpage-test-binaries" >&2
exit 1
fi

for test_binary in "${test_binaries[@]}"; do
echo "::group::$(basename "$test_binary")"
"$test_binary" --quiet
echo "::endgroup::"
done
Loading