Skip to content

Commit

Permalink
Speed up other CI jobs by avoiding the usage of a live Postgres database
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker committed Aug 30, 2024
1 parent f4d2608 commit b1c7da3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 23 deletions.
33 changes: 10 additions & 23 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
# Service containers to run alongside the `test` container job
services:
postgres:
# Docker Hub image
Expand All @@ -43,6 +44,7 @@ jobs:
# It also takes care of caching intermediate build artifacts.
- name: Install the Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install sqlx-cli
run:
cargo install sqlx-cli
Expand All @@ -53,16 +55,18 @@ jobs:
# The --locked flag can be used to force Cargo to use the packaged Cargo.lock file if it is available.
# This may be useful for ensuring reproducible builds, to use the exact same set of dependencies that were available when the package was published.
# It may also be useful if a newer version of a dependency is published that no longer builds on your system, or has other problems

- name: Migrate database
run: |
sudo apt-get install libpq-dev -y
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Check sqlx-data.json is up-to-date
run: |
cargo sqlx prepare --workspace --check
- name: Run tests
run: cargo test

- name: Check that queries are fresh
run: cargo sqlx prepare --workspace --check -- --all-targets

# `fmt` container job
fmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand All @@ -78,31 +82,14 @@ jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
env:
SQLX_OFFLINE: true
steps:
- uses: actions/checkout@v4
- name: Install the Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Install sqlx-cli
run: cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features ${{ env.SQLX_FEATURES }}
--no-default-features
--locked
- name: Migrate database
run: |
sudo apt-get install libpq-dev -y
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Linting
run: cargo clippy -- -D warnings

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b1c7da3

Please sign in to comment.