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

improve CI tests #157

Closed
wants to merge 7 commits into from
Closed
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
61 changes: 61 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "Test and code coverage"
description: "Run tests with nextest and report code coverage in a PR comment."
author: "Off-Narrative Labs"
branding:
icon: "check-circle"
color: "green"

inputs:
packages:
description: "Packages to be tested by `cargo nextest`."
required: true
default: ""
ignore:
description: "Folders or files to be ignored by `cargo llvm-cov report`."
required: true
default: "target" # we need a default value, otherwise the command doesn't work
title:
description: "Title of the comment with the code coverage."
required: true

runs:
using: "composite"
steps:
- name: Install tooling
shell: bash
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-targets: true
cache-on-failure: true
- name: Run tests and print coverage data
shell: bash
run: |
pkgs=`for p in ${{ inputs.packages }}; do echo -n "-p $p "; done`;
cargo llvm-cov nextest --release \
$pkgs --json --summary-only --output-path lcov.json &&
perc=`jq ".data[0].totals.lines.percent" lcov.json` &&
echo Lines coverage: ${perc:0:5}%
# 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
shell: bash
run: |
function join_by { local IFS="$1"; shift; echo "$*"; };
ignore=`join_by \| ${{ inputs.ignore }}`;
cargo llvm-cov report --lcov --output-path lcov.info \
--ignore-filename-regex "$ignore"
- if: github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
name: Report code coverage
uses: romeovs/lcov-reporter-action@master
with:
lcov-file: lcov.info
delete-old-comments: true
title: ${{ inputs.title }}
88 changes: 48 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,60 @@ jobs:
all: true
match: "Cargo.toml"

test:
name: Test and code coverage
test-core:
name: Test and Code Coverage for Tuxedo Core
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
- uses: ./.github/actions/test
with:
cache-targets: true
cache-on-failure: true
- name: Run tests and print coverage data
run: cargo llvm-cov nextest --workspace
--exclude node-template --exclude parachain-template-node
--exclude derive-no-bound
--json --output-path lcov.json --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: romeovs/lcov-reporter-action@master
packages: tuxedo-core
title: "Code Coverage for Tuxedo Core"

test-parachain:
name: Test and Code Coverage for Tuxedo Parachain Core and Piece
needs: [fmt, toml-sort]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
packages: tuxedo-parachain-core parachain-piece
ignore: tuxedo-core
title: "Code Coverage for Tuxedo Parachain Core and Piece"

test-runtime:
name: Test and Code Coverage for Tuxedo Template Runtime
needs: [fmt, toml-sort]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
packages: tuxedo-template-runtime
ignore: tuxedo-core wardrobe
title: "Code Coverage for Tuxedo Template Runtime"

test-wardrobe:
name: Test and Code Coverage for Tuxedo Wardrobe Pieces
needs: [fmt, toml-sort]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
lcov-file: lcov.info
pr-number: ${{ github.event.pull_request.number }}
delete-old-comments: true
packages: kitties money poe runtime-upgrade timestamp
ignore: tuxedo-core
title: "Code Coverage for Tuxedo Wardrobe Pieces"

clippy:
name: Clippy
Expand All @@ -77,9 +89,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
run: sudo apt-get install -y protobuf-compiler && protoc --version
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
Expand All @@ -95,9 +105,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
run: sudo apt-get install -y protobuf-compiler && protoc --version
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
Expand Down