update workflow
Some checks failed
Rust / Test (push) Has been cancelled
Rust / Rustfmt (push) Has been cancelled
Rust / Clippy (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled
Rust / Build (push) Has been cancelled

This commit is contained in:
Alphonse Paix
2025-10-02 10:44:29 +02:00
parent 9e5d185aaf
commit 73a44cace7

View File

@@ -18,9 +18,73 @@ env:
APP_KV_STORE__HOST: redis APP_KV_STORE__HOST: redis
jobs: jobs:
# This job builds and caches artifacts for other jobs to use
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install mold linker
run: |
sudo apt-get update
sudo apt-get install -y mold clang
# LONG-TERM CACHE: Cargo registry (shared across workflows)
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-registry-
# LONG-TERM CACHE: sqlx-cli binary (shared across workflows)
- name: Cache sqlx-cli
id: cache-sqlx
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/sqlx
~/.cargo/bin/cargo-sqlx
key: sqlx-cli-${{ env.SQLX_VERSION }}
# LONG-TERM CACHE: Rust toolchain (shared across workflows)
# Note: Keep cache: false if it times out, the toolchain itself is cached by rustup
- name: Install the Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
- name: Install sqlx-cli
if: steps.cache-sqlx.outputs.cache-hit != 'true'
run: cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features ${{ env.SQLX_FEATURES }}
--no-default-features
--locked
# Build the project
- name: Build
run: cargo build --release
# WORKFLOW-ONLY CACHE: Upload build artifacts for other jobs
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
target/
~/.cargo/bin/
test: test:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build # Wait for build to complete
services: services:
postgres: postgres:
image: postgres image: postgres
@@ -37,24 +101,29 @@ jobs:
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install mold linker - name: Install mold linker
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y mold clang sudo apt-get install -y mold clang
# Download build artifacts from the build job
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: 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
with: with:
cache: false cache: false
- name: Install sqlx-cli
run: cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features ${{ env.SQLX_FEATURES }}
--no-default-features
--locked
- name: Migrate database - name: Migrate database
run: cargo sqlx migrate run run: cargo sqlx migrate run
- name: Run tests - name: Run tests
run: TEST_LOG=true cargo test run: TEST_LOG=true cargo test
- name: Check that queries are fresh - name: Check that queries are fresh
run: cargo sqlx prepare --check --workspace run: cargo sqlx prepare --check --workspace
@@ -63,26 +132,55 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# LONG-TERM CACHE: Cargo registry
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-registry-
- 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: rustfmt components: rustfmt
cache: false cache: false
- name: Enforce formatting - name: Enforce formatting
run: cargo fmt --check run: cargo fmt --check
clippy: clippy:
name: Clippy name: Clippy
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build # Use artifacts from build
env: env:
SQLX_OFFLINE: true SQLX_OFFLINE: true
steps: steps:
- uses: actions/checkout@v4 - name: Check out repository code
uses: actions/checkout@v4
- name: Install mold linker
run: |
sudo apt-get update
sudo apt-get install -y mold clang
# Download build artifacts
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: 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
with: with:
components: clippy components: clippy
cache: false cache: false
- name: Linting - name: Linting
run: cargo clippy -- -D warnings run: cargo clippy -- -D warnings
@@ -104,26 +202,65 @@ jobs:
- 16379:6379 - 16379:6379
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install mold linker - name: Install mold linker
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y mold clang sudo apt-get install -y mold clang
# LONG-TERM CACHE: Cargo registry
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-registry-
# LONG-TERM CACHE: sqlx-cli
- name: Cache sqlx-cli
id: cache-sqlx-cov
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/sqlx
~/.cargo/bin/cargo-sqlx
key: sqlx-cli-${{ env.SQLX_VERSION }}
# LONG-TERM CACHE: cargo-llvm-cov
- name: Cache cargo-llvm-cov
id: cache-llvm-cov
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-llvm-cov
key: cargo-llvm-cov-0.6.0 # Pin to a version
- 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: llvm-tools-preview components: llvm-tools-preview
cache: false cache: false
- name: Install sqlx-cli - name: Install sqlx-cli
if: steps.cache-sqlx-cov.outputs.cache-hit != 'true'
run: cargo install sqlx-cli run: cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }} --version=${{ env.SQLX_VERSION }}
--features ${{ env.SQLX_FEATURES }} --features ${{ env.SQLX_FEATURES }}
--no-default-features --no-default-features
--locked --locked
- name: Migrate database - name: Migrate database
run: cargo sqlx migrate run run: cargo sqlx migrate run
- name: Install cargo-llvm-cov - name: Install cargo-llvm-cov
if: steps.cache-llvm-cov.outputs.cache-hit != 'true'
uses: taiki-e/install-action@cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage - name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Generate report - name: Generate report
run: cargo llvm-cov report --html --output-dir coverage run: cargo llvm-cov report --html --output-dir coverage