mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-02 14:16:35 +00:00
Speed up other CI jobs by avoiding the usage of a live Postgres database
This commit is contained in:
parent
d21119ff3b
commit
a266ccdfaf
2 changed files with 36 additions and 23 deletions
33
.github/workflows/general.yml
vendored
33
.github/workflows/general.yml
vendored
|
@ -21,6 +21,7 @@ jobs:
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# Service containers to run alongside the `test` container job
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
# Docker Hub image
|
# Docker Hub image
|
||||||
|
@ -43,6 +44,7 @@ jobs:
|
||||||
# It also takes care of caching intermediate build artifacts.
|
# It also takes care of caching intermediate build artifacts.
|
||||||
- name: Install the Rust toolchain
|
- name: Install the Rust toolchain
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
|
||||||
- name: Install sqlx-cli
|
- name: Install sqlx-cli
|
||||||
run:
|
run:
|
||||||
cargo install sqlx-cli
|
cargo install sqlx-cli
|
||||||
|
@ -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.
|
# 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.
|
# 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
|
# 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
|
- name: Migrate database
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install libpq-dev -y
|
|
||||||
SKIP_DOCKER=true ./scripts/init_db.sh
|
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
|
- name: Run tests
|
||||||
run: cargo test
|
run: cargo test
|
||||||
|
|
||||||
|
- name: Check that queries are fresh
|
||||||
|
run: cargo sqlx prepare --workspace --check -- --all-targets
|
||||||
|
|
||||||
|
# `fmt` container job
|
||||||
fmt:
|
fmt:
|
||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -78,31 +82,14 @@ jobs:
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
env:
|
||||||
postgres:
|
SQLX_OFFLINE: true
|
||||||
image: postgres:14
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: password
|
|
||||||
POSTGRES_DB: postgres
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install the Rust toolchain
|
- name: Install the Rust toolchain
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
components: clippy
|
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
|
- name: Linting
|
||||||
run: cargo clippy -- -D warnings
|
run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT email, name FROM subscriptions",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "email",
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": []
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "ed279fc2dda0c3ede3e81a4500fcaa9da2220f8a9ad6c1debc3095deb9f84759"
|
||||||
|
}
|
Loading…
Reference in a new issue