Skip to content

Commit

Permalink
Add coverage config (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisllontop authored Jun 8, 2024
1 parent d94e7ce commit 08a9395
Show file tree
Hide file tree
Showing 7 changed files with 1,094 additions and 107 deletions.
55 changes: 10 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,15 @@ on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Start Services
run: |
docker-compose up -d
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt, clippy

- uses: swatinem/[email protected]

- name: Rust fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features

- name: Build release
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --all --release --all-features
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

- name: Run Test
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features
jobs:
test:
uses: ./.github/workflows/test.yml
secrets: inherit
47 changes: 3 additions & 44 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,8 @@ on:
- created

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Start services
run: |
docker-compose up -d
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- uses: swatinem/[email protected]

- name: Run fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features

- name: Run Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all

- name: Build Release
uses: actions-rs/cargo@v1
with:
command: build
args: --release
test:
uses: ./.github/workflows/test.yml

publish_to_cargo:
needs: build_and_test
Expand All @@ -69,4 +28,4 @@ jobs:
with:
command: publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Test

on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: true

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Start Services
run: |
docker-compose up -d
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt, clippy

- uses: swatinem/[email protected]

- name: Rust fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features

- name: Install Tarpaulin
run: cargo install cargo-tarpaulin

- name: Run tests with coverage
run: cargo tarpaulin --out Xml --output-dir coverage

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/cobertura.xml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
# IDES
.vscode
.idea
.fleet
.fleet
/build_rs_cov.profraw
coverage/
Loading

0 comments on commit 08a9395

Please sign in to comment.