Skip to content

Commit

Permalink
Add GitHub actions for Rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Oct 19, 2023
1 parent 53f713c commit b6fbcf2
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage

on: [pull_request, push]

jobs:
coverage:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: llvm-tools-preview
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
working_dir: Code
run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info
- name: Generate text report
working_dir: Code
run: cargo llvm-cov report --text
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# working_dir: Code
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
# files: lcov.info
# fail_ci_if_error: true
49 changes: 49 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Rust"
on:
push:
pull_request:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-hack
- name: Build code
working_dir: Code
run: cargo nextest run --workspace --all-features --no-run
- name: Run tests
working_dir: Code
run: cargo nextest run --workspace --all-features

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- uses: auguwu/clippy-action@1
with:
token: ${{secrets.GITHUB_TOKEN}}

fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Check formatting
uses: actions-rust-lang/rustfmt@v1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Code coverage artifacts
lcov.info
6 changes: 6 additions & 0 deletions Code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]
resolver = "2"

members = [
"round-sm"
]
2 changes: 2 additions & 0 deletions Code/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "stable"
2 changes: 2 additions & 0 deletions Code/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
max_width = 120
comment_width = 100

0 comments on commit b6fbcf2

Please sign in to comment.