Skip to content

feat(ci): optimize caching for Cargo dependencies and streamline CI workflows #132

feat(ci): optimize caching for Cargo dependencies and streamline CI workflows

feat(ci): optimize caching for Cargo dependencies and streamline CI workflows #132

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
checks: write
pull-requests: write
env:
CARGO_TERM_COLOR: always
SQLX_OFFLINE: true
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LANGUAGE: en_US
CARGO_HOME: ${{ github.workspace }}/.cargo
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add Cargo bin to PATH
run: echo "${{ github.workspace }}/.cargo/bin" >> $GITHUB_PATH
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
/usr/local/cargo
/usr/local/rustup
${{ env.CARGO_HOME }}/bin
${{ env.CARGO_HOME }}/git
${{ env.CARGO_HOME }}/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Create .env file
run: cp .env.template .env
- name: Install Cargo Tools
run: |
if rustup target list --installed | grep -F "wasm32-unknown-unknown" >/dev/null; then
echo "Target wasm32-unknown-unknown already installed"
else
rustup target add wasm32-unknown-unknown
fi
if ! cargo install-update --version >/dev/null 2>&1; then
cargo install cargo-update
else
echo "cargo-update already installed"
fi
cargo install-update -a trunk wasm-bindgen-cli wasm-opt sqlx-cli cargo-llvm-cov cargo-audit
if ! command -v trunk >/dev/null; then
cargo install trunk --locked
fi
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- name: Build frontend
working-directory: frontend
run: trunk build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: frontend/dist/
retention-days: 7