Skip to content

Commit

Permalink
CI Improvements (#112)
Browse files Browse the repository at this point in the history
- renamed `build.yml` to `ci.yml`
- use toml-sort action in `ci.yml`
- removed `toml-sort.yml`
- removed cargo check job
- perform tests with nextest instead of cargo test
- added llvm cov for coverage ~ fixes #106
- print lines coverage to actions cli output
- comment PR with report when allowed
- added `--no-deps` arg to clippy
- bumped version for upgraded actions
- removed unmaintained actions
- created `rust-toolchain.toml` with stable channel
- tests and clippy are run after rustfmt and toml-sort are successful
- tests and clippy's target is cached even on failure


Signed-off-by: muraca <mmuraca247@gmail.com>
  • Loading branch information
muraca authored Oct 5, 2023
1 parent 2b42530 commit b86ed18
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 124 deletions.
98 changes: 0 additions & 98 deletions .github/workflows/build.yml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
on:
pull_request:
branches:
- main
push:
branches:
- main

name: Continuous integration

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Run Rustfmt
run: cargo fmt --all -- --check

toml-sort:
name: TOML Sort check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Off-Narrative-Labs/toml_sort@v1
with:
all: true

test:
name: Test and code coverage
needs: [fmt, toml-sort]
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run tests and print coverage data
run: cargo llvm-cov nextest --json --output-path lcov.json
--ignore-filename-regex "node/" --summary-only &&
echo "Lines coverage " && jq ".data[0].totals.lines.percent" lcov.json
# if the PR is on the same repo, the coverage data can be reported as a comment
- if: github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
name: Generate lcov report
run: cargo llvm-cov report --lcov --output-path lcov.info
--ignore-filename-regex "node/"
- if: github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
name: Report code coverage
uses: Nef10/lcov-reporter-action@v0.4.0
with:
lcov-file: lcov.info
pr-number: ${{ github.event.pull_request.number }}

clippy:
name: Clippy
needs: [fmt, toml-sort]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run Clippy
run: cargo clippy --no-deps -- -D warnings
22 changes: 0 additions & 22 deletions .github/workflows/toml-sort.yml

This file was deleted.

5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
components = [ "rustfmt", "clippy" ]
profile = "minimal"
targets = [ "wasm32-unknown-unknown" ]
8 changes: 4 additions & 4 deletions toml-sort.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
keys = [
"package",
"dependencies",
"package",
"dependencies",
]

inline_keys = [
"version",
"features",
"version",
"features",
]

0 comments on commit b86ed18

Please sign in to comment.