refactor: add api/backend/proc-macro crate #1624
This file contains 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: Coverage | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: full | |
RUST_LOG: debug | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" | |
AWS_ACCESS_KEY_ID: minioadmin | |
AWS_SECRET_ACCESS_KEY: minioadmin | |
AWS_REGION: us-east-1 | |
AWS_ENDPOINT_URL: http://localhost:9000 | |
AWS_USE_PATH_STYLE_ENDPOINT: true | |
MINIO_ROOT_USER: minioadmin | |
MINIO_ROOT_PASSWORD: minioadmin | |
jobs: | |
coverage: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:17 | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
--name postgres | |
ports: | |
- 5432:5432 | |
s3: | |
image: bitnami/minio:2024.10.2 | |
env: | |
MINIO_ROOT_USER: ${{ env.MINIO_ROOT_USER }} | |
MINIO_ROOT_PASSWORD: ${{ env.MINIO_ROOT_PASSWORD }} | |
ports: | |
- 9000:9000 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Export GitHub Actions cache environment variables | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Extract rust toolchain | |
id: toolchain | |
run: | | |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT" | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.toolchain.outputs.channel }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: coverage | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- uses: cargo-bins/cargo-binstall@main | |
- name: Increase postgres max connection | |
run: | | |
docker exec postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET max_connections = '1000'"; | |
docker exec postgres psql -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '2048MB'"; | |
docker restart postgres | |
- name: Install vcpkg build deps | |
run: sudo apt-get --assume-yes install nasm | |
- name: Install cargo-vcpkg | |
uses: taiki-e/cache-cargo-install-action@v2 | |
with: | |
tool: cargo-vcpkg | |
- name: Build vcpkg dependencies | |
run: | | |
cargo vcpkg --verbose build --target x86_64-unknown-linux-gnu | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Generate code coverage | |
run: cargo llvm-cov --all-features --workspace --exclude nghe-frontend --codecov --output-path codecov.json | |
env: | |
LASTFM_KEY: ${{ secrets.LASTFM_KEY }} | |
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }} | |
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: codecov.json | |
fail_ci_if_error: true |