Skip to content

Commit

Permalink
Configure code coverage using Codecov (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
praseodym authored Jan 30, 2025
1 parent 8e5102c commit f30c2fc
Show file tree
Hide file tree
Showing 11 changed files with 1,304 additions and 390 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Codecov

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
backend:
name: Backend
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
env:
CARGO_TERM_COLOR: always
SQLX_OFFLINE: "true"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust Nightly
shell: bash
run: >
rustup update nightly &&
rustup default nightly &&
echo RUST_VERSION=$(rustc --version | awk -F '[( ]' '{print $4}') >> $GITHUB_ENV
- name: Install Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Tarpaulin
run: cargo binstall cargo-tarpaulin
- name: Install Nextest
run: cargo binstall cargo-nextest
- name: Cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./backend/target/
key: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-
- name: Run tests
run: cargo nextest run --profile ci
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./target/nextest/ci/junit.xml
- name: Generate code coverage
run: cargo --verbose --locked tarpaulin --timeout 120 --out xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

frontend:
name: Frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Run Vite build to report bundle size
run: npx vite build --config vite.config.ts
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run tests with coverage
run: npx vitest run --coverage --reporter=junit --outputFile=test-report.junit.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions backend/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[profile.ci.junit]
path = "junit.xml"
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/target-docker/
db.sqlite*
/templates/**/*.pdf
cobertura.xml
2 changes: 2 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ translations
*.sln
*.sw?
test-results
coverage
mock
test-report.junit.xml

# Automatically created: https://github.com/mswjs/msw/discussions/1015#discussioncomment-1747585
mockServiceWorker.js
24 changes: 22 additions & 2 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ npm run ladle

And open Ladle at http://localhost:61000/.

## Production build

Prerequisites:

- [Node](https://nodejs.org) v22

Install npm dependencies, skipping development dependencies:

```sh
npm clean-install --omit=dev
```

Build the frontend:

```sh
npm run build
```

The built frontend is located in the `dist` directory.

## Structure

### Dependencies
Expand All @@ -81,14 +101,14 @@ The application uses the following dependencies:
- `react`: creating efficient, declarative, and component-based web applications.
- `react-dom`: DOM implementation for rendering UI
- `react-router`: Handling browser routing for React applications
- `vite`: frontend build tool
- `postcss` and `autoprefixer`: CSS post processors

#### Development dependencies

- `typescript`: Strongly typed layer on top of JavaScript
- `msw`: Mock Service Worker for mocking the server, client side
- `vite`: frontend build tool
- `ladle`: simple development and test environment for UI components
- `postcss` and `autoprefixer`: CSS post processors
- `lefthook`: git hook automation
- `cross-env`: for building on Windows

Expand Down
Loading

0 comments on commit f30c2fc

Please sign in to comment.