Skip to content

Commit

Permalink
Add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pnehrer committed Apr 21, 2024
1 parent 5d8c694 commit 8838a88
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
76 changes: 76 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
on:
pull_request:
push:
branches:
- main

name: Rust CI

jobs:
lint:
name: Check formatting and run clippy
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D warnings

coverage:
name: Run tests with coverage
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build the binary
uses: actions-rs/cargo@v1
with:
command: build
env:
CARGO_INCREMENTAL: '0'
RUSTC_BOOTSTRAP: '1'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: Run unit tests
uses: actions-rs/cargo@v1
with:
command: test
env:
CARGO_INCREMENTAL: '0'
RUSTC_BOOTSTRAP: '1'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: Install grcov
uses: actions-rs/cargo@v1
with:
command: install
args: 'grcov --version 0.8.9'
- name: Run grcov
run: grcov . -s . --binary-path ./target/debug/ --excl-start '^mod\s+tests\s*\{$' -t covdir --branch --ignore-not-existing --keep-only 'src/**' -o ./target/covdir.json
- name: Generate coverage report
uses: ecliptical/covdir-report-action@v0.2
with:
file: ./target/covdir.json
summary: 'true'
out: ./target/coverage.md
- name: Add coverage comment to the pull request
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
path: ./target/coverage.md
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This crate provides basic utilities that help you develop [custom GitHub Actions
use gha::github_workspace;
use std::fs::File;

let workspace = File::open(github_workspace().append("config.yaml"))?;
let workspace = github_workspace();
let my_file = File::open(workspace.append("my_file.yaml"))?
```

## Messages
Expand Down

0 comments on commit 8838a88

Please sign in to comment.