fix(workflows): enforce Justfile as single source of truth for docs w… #190
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
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 | |
RUST_BACKTRACE: 1 | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: rustygpt_test | |
POSTGRES_USER: postgres | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Install Just | |
uses: extractions/setup-just@v2 | |
- name: Add Cargo bin to PATH | |
run: echo "${{ github.workspace }}/.cargo/bin" >> $GITHUB_PATH | |
- name: Cache Cargo tools | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_HOME }}/bin | |
key: ${{ runner.os }}-cargo-tools-${{ hashFiles('Justfile') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-tools- | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
${{ env.CARGO_HOME }}/git | |
${{ env.CARGO_HOME }}/registry | |
${{ env.CARGO_HOME }}/.crates2.json | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Cache Dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- name: Install tools | |
run: just install-ci | |
- name: Create .env file | |
run: | | |
cp .env.template .env | |
echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/rustygpt_test" >> .env | |
- name: Check formatting | |
run: just check | |
- name: Build all crates | |
run: just build | |
- name: Run tests | |
run: just test | |
- name: Generate coverage report | |
run: just coverage | |
- name: Upload coverage to codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: .coverage/lcov.info | |
fail_ci_if_error: false | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
if: success() | |
with: | |
name: dist | |
path: rustygpt-web/dist/ | |
retention-days: 7 |