Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add test coverage reporting job to CI #262

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- '*.md'

env:
CARGO_MAKE_TOOLCHAIN: nightly-2024-03-10
CARGO_MAKE_TOOLCHAIN: nightly-2024-05-15

jobs:
compiler:
Expand Down Expand Up @@ -128,3 +128,34 @@ jobs:
with:
command: make
args: check-format

test_coverage:
name: test-coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
- name: Cache Cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make
- name: Run tests and generate code coverage
run: |
cargo make test-rust-cov
- name: Push code coverage results to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov.info
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- main

env:
CARGO_MAKE_TOOLCHAIN: nightly-2024-03-10
CARGO_MAKE_TOOLCHAIN: nightly-2024-05-15

jobs:
release-plz:
Expand Down
88 changes: 46 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 28 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ args = ["target", "add", "wasm32-unknown-unknown"]
category = "Test"
description = "Install wasm32-wasi target"
command = "rustup"
args = ["target", "add", "wasm32-wasi"]
# `wasm32-wasi` target is renamed to `wasm32-wasip1`
# https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html
args = ["target", "add", "wasm32-wasip1"]

[tasks.install-rust-src]
category = "Test"
Expand All @@ -212,7 +214,13 @@ args = ["component", "add", "rust-src"]
category = "Test"
description = "Install cargo-component extension"
command = "cargo"
args = ["install", "[email protected]"]
args = ["install", "[email protected]"]

[tasks.install-cargo-tarpaulin]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't actually need this task, if you have a task that uses cargo as the command, cargo-make will check if the task name passed to cargo exists, and if not, it will attempt to cargo install it.

There's also cargo-make configuration for modifying how cargo install is invoked, like if the crate name is different, or additional arguments are needed. Not needed here, but just FYI.

The only reason to explicitly install things is when those things aren't normal cargo plugins, e.g. mdbook

category = "Test"
description = "Install cargo-tarpaulin extension"
command = "cargo"
args = ["install", "cargo-tarpaulin"]

[tasks.test-rust]
category = "Test"
Expand Down Expand Up @@ -246,6 +254,24 @@ args = [
]
dependencies = ["litcheck"]

[tasks.test-rust-cov]
category = "Test"
description = "Runs tests written in Rust and generates code coverage report"
command = "cargo"
args = [
"tarpaulin",
"--timeout=360",
"--out",
"lcov",
]
dependencies = [
"install-wasm-target",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we use rust-toolchain.toml, it occurs to me that we don't need to explicitly install the targets/components anymore, we just need to make sure they are in the toolchain file.

"install-wasm-wasi-target",
"install-rust-src",
"install-cargo-component",
"install-cargo-tarpaulin",
]

[tasks.litcheck]
category = "Test"
description = "Set up the litcheck utility"
Expand Down
2 changes: 1 addition & 1 deletion codegen/masm/src/codegen/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<'b, 'f: 'b> BlockEmitter<'b, 'f> {
// Continue normally, by emitting the contents of the block based on the given schedule
for op in block_schedule.iter() {
match op {
ScheduleOp::Init(_) | ScheduleOp::Enter(_) | ScheduleOp::Exit => continue,
ScheduleOp::Exit => continue,
ScheduleOp::Inst(inst_info) => self.emit_inst(inst_info, tasks),
ScheduleOp::Drop(value) => {
let mut emitter = self.emitter();
Expand Down
Loading
Loading