Skip to content

Improves code linting and indexing process #144

Improves code linting and indexing process

Improves code linting and indexing process #144

Workflow file for this run

name: Rust CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Check code formatting
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Run Clippy on production code
run: cargo clippy --lib --bins -- -D warnings
- name: Run Clippy on tests (with panic allowed)
run: cargo clippy --tests -- -D warnings -A clippy::unwrap_used -A clippy::expect_used -A clippy::panic
build:
needs: [fmt, clippy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build
tests:
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Pull PostgreSQL image
run: docker pull postgres:16-alpine
- name: Setup test database
run: |
docker run -d \
--name test_db \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
--health-cmd="pg_isready -U postgres" \
--health-interval=5s \
--health-timeout=5s \
--health-retries=5 \
postgres:16-alpine
- name: Wait for database to be ready
run: |
timeout 60s bash -c 'until docker exec test_db pg_isready -U postgres; do sleep 2; done'
- name: Run migrations
run: |
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
cargo install sqlx-cli --version "=0.8.6" --no-default-features --features postgres
sqlx migrate run
- name: Install required tools
run: |
cargo install cargo-llvm-cov
rustup component add llvm-tools-preview
- run: chmod +x build-scripts/run-test.sh
- run: chmod +x build-scripts/run-coverage.sh
- name: Run tests with coverage
run: |
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
./build-scripts/run-coverage.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false