Skip to content

Commit

Permalink
CI: sqlx setup
Browse files Browse the repository at this point in the history
  • Loading branch information
awoimbee committed Jan 15, 2025
1 parent 2633917 commit 33eeacc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- name: Cache compilation artefacts
uses: mozilla-actions/[email protected]
- name: Setup cargo-sqlx
run: cargo install sqlx-cli
- name: Setup sqlx database
run: mkdir -p target && cargo sqlx database setup

- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Run Trow test suite
Expand All @@ -41,6 +46,10 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- name: Cache compilation artefacts
uses: mozilla-actions/[email protected]
- name: Setup cargo-sqlx
run: cargo install sqlx-cli
- name: Setup sqlx database
run: mkdir -p target && cargo sqlx database setup
- name: Build
run: |
cargo build
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## sqlx setup

To develop, build and test Trow, an sqlx development database is required.
The TL;DR is `cargo sqlx database setup`, more information can be found at
The TL;DR is `mkdir -p target && cargo sqlx database setup`, more information can be found at
<https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md>.

## Using Docker/Podman
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ COPY .cargo/config.toml .cargo/config.toml
COPY src src

# Get rid of the "cp" when cargo build --out is stable
RUN --mount=type=cache,target=./target \
RUN --mount=type=bind,source=./target,target=./target \
cargo build --release --target $(cat /.platform) && \
cp /usr/src/trow/target/$(cat /.platform)/release/trow /usr/src/trow/

Expand Down
30 changes: 29 additions & 1 deletion docker/multi-arch.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
#!/usr/bin/env bash
set -eo pipefail
set -exo pipefail

# change to directory with script so we know where project root is
src_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$src_dir"

GH_REPO="ghcr.io/trow-registry/trow"

# Check if cargo-sqlx is installed
if ! command -v cargo-sqlx >/dev/null 2>&1; then
echo "→ sqlx-cli not found. Installing..."
if ! cargo install sqlx-cli; then
echo "Error: Failed to install sqlx-cli"
exit 1
fi
echo "→ sqlx-cli installed successfully"
else
echo "→ sqlx-cli is already installed"
fi

# Check if development database exists
DB_PATH="$src_dir/target/dev.db"
if [ ! -f "$DB_PATH" ]; then
echo "→ Development database not found. Setting up..."
cd "$src_dir/.."
mkdir -p target
if ! cargo sqlx database setup; then
echo "Error: Failed to setup database"
exit 1
fi
cd "$src_dir"
echo "→ Database setup completed"
else
echo "→ Development database already exists at $DB_PATH"
fi

# Use trow-multi builder if it exists, otherwise create it
if ! docker buildx ls | grep -s trow-multi ;
then
Expand Down

0 comments on commit 33eeacc

Please sign in to comment.