From 739a8a90445d7c9b15f1ad09593e9592ddd456ef Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sat, 6 Jun 2020 07:32:46 -0700 Subject: [PATCH 01/13] rework github actions for code coverage This reworks our GitHub Actions workflow to include code coverage via tarpaulin. Note that this is essentially directly lifted from the again[1] crate's methodology. Fixes #164. [1] https://github.com/softprops/again/blob/dd5f0013533e28f803b282ebc281e9525ca64d86/.github/workflows/main.yml --- .github/workflows/rust.yml | 70 +++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 06db11ebf..49d1c2119 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,28 +3,58 @@ name: Rust on: [push] jobs: - build: + + codestyle: + runs-on: ubuntu-latest + steps: + - name: Set up Rust + uses: hecrj/setup-rust-action@v1 + with: + components: rustfmt + rust-version: nightly + - uses: actions/checkout@v2 + - run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') + + lint: + runs-on: ubuntu-latest + steps: + - name: Set up Rust + uses: hecrj/setup-rust-action@v1 + with: + components: clippy + - uses: actions/checkout@v2 + - run: cargo clippy --all-targets -- -D clippy::all + + compile: runs-on: ubuntu-latest + steps: + - name: Set up Rust + uses: hecrj/setup-rust-action@v1 + - uses: actions/checkout@master + - run: cargo check --all + test: + needs: [codestyle, lint, compile] + strategy: + matrix: + rust: [stable, beta, nightly] + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - name: Setup Rust + uses: hecrj/setup-rust-action@v1 + with: + rust-version: ${{ matrix.rust }} + - name: Checkout + uses: actions/checkout@v2 + - name: Test + run: cargo test + - name: Coverage + if: matrix.rust == 'stable' run: | - rustup toolchain install nightly --profile default - rustup toolchain install stable - rustup override set stable - # Clippy must be run first, as its lints are only triggered during - # compilation. Put another way: after a successful `cargo build`, `cargo - # clippy` is guaranteed to produce no results. This bug is known upstream: - # https://github.com/rust-lang/rust-clippy/issues/2604. -# - name: Clippy -# run: cargo clippy -- --all-targets --all-features -- -D warnings - - name: Check formatting - run: | - cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - - name: Run tests for all features - run: cargo test --verbose -- all-features + # Tarpaulin interoperates with CI services, however Actions is not + # currently supported. As a workaround, we can pretend to be Travis. + export TRAVIS_JOB_ID=${GITHUB_SHA} + export TRAVIS_PULL_REQUEST=false + export TRAVIS_BRANCH=${GITHUB_REF##*/} + cargo install cargo-tarpaulin + cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID From ea1b930789a51964eac018ddbe615ce78f603d95 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 06:45:26 -0700 Subject: [PATCH 02/13] use --all-features for clippy and test --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 49d1c2119..95ebd9bc4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,7 +23,7 @@ jobs: with: components: clippy - uses: actions/checkout@v2 - - run: cargo clippy --all-targets -- -D clippy::all + - run: cargo clippy --all-targets -- -D clippy::all --all-features compile: runs-on: ubuntu-latest @@ -47,7 +47,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Test - run: cargo test + run: cargo test --all-features - name: Coverage if: matrix.rust == 'stable' run: | From a199d5c7029e4c2b5dc5613504fcb051a708a762 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 06:48:51 -0700 Subject: [PATCH 03/13] mirror travis config for clippy and test --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 95ebd9bc4..bf691d138 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,7 +23,7 @@ jobs: with: components: clippy - uses: actions/checkout@v2 - - run: cargo clippy --all-targets -- -D clippy::all --all-features + - run: cargo clippy -- --all-targets --all-features -- -D warnings compile: runs-on: ubuntu-latest @@ -47,7 +47,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Test - run: cargo test --all-features + run: cargo test -- all-features - name: Coverage if: matrix.rust == 'stable' run: | From d126b189a8e3920b0f6ed98a21ce2761f21b8990 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 06:52:10 -0700 Subject: [PATCH 04/13] use canonical clippy invocation --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf691d138..376852054 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,7 +23,7 @@ jobs: with: components: clippy - uses: actions/checkout@v2 - - run: cargo clippy -- --all-targets --all-features -- -D warnings + - run: cargo clippy --all-targets --all-features -- -D warnings compile: runs-on: ubuntu-latest From 01f0abb6bb3dc7fb2c0d56df4d26a0f4839ee34e Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:08:33 -0700 Subject: [PATCH 05/13] check all targets and all features --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 376852054..962bbb857 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Rust uses: hecrj/setup-rust-action@v1 - uses: actions/checkout@master - - run: cargo check --all + - run: cargo check --all-targets --all-features test: needs: [codestyle, lint, compile] From a54b98120a768b8ae935708b3eb6c0130afb4179 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:09:00 -0700 Subject: [PATCH 06/13] remove upstream jobs for test --- .github/workflows/rust.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 962bbb857..2044da648 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,7 +34,6 @@ jobs: - run: cargo check --all-targets --all-features test: - needs: [codestyle, lint, compile] strategy: matrix: rust: [stable, beta, nightly] From ec83b8dedf24badeef2ce91cbe16bef3579b40fa Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:10:21 -0700 Subject: [PATCH 07/13] document nightly requirement for fmt --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2044da648..8a933227e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,6 +11,7 @@ jobs: uses: hecrj/setup-rust-action@v1 with: components: rustfmt + # Note that `nightly` is required for `license_template_path`, as it's an unstable feature. rust-version: nightly - uses: actions/checkout@v2 - run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') From a213095fbc6086f5b96c46e35943ea48b0a529b8 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:10:50 -0700 Subject: [PATCH 08/13] more consistent comment formatting --- .github/workflows/rust.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8a933227e..9c31e6f9a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,8 @@ jobs: uses: hecrj/setup-rust-action@v1 with: components: rustfmt - # Note that `nightly` is required for `license_template_path`, as it's an unstable feature. + # Note that `nightly` is required for `license_template_path`, as + # it's an unstable feature. rust-version: nightly - uses: actions/checkout@v2 - run: cargo fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') From a3f4e9ee1a1217340938d84a87be185678d00b41 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:26:15 -0700 Subject: [PATCH 09/13] subscribe to pull_request --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9c31e6f9a..339f857ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,6 +1,6 @@ name: Rust -on: [push] +on: [push, pull_request] jobs: From 41221c9b5d809d5e2d584b21f5f1e09aaad3fc1e Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:32:17 -0700 Subject: [PATCH 10/13] use install action to provide tarpaulin --- .github/workflows/rust.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 339f857ad..6703c8fbd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -45,6 +45,12 @@ jobs: uses: hecrj/setup-rust-action@v1 with: rust-version: ${{ matrix.rust }} + - name: Install Tarpaulin + uses: actions-rs/install@v0.1 + with: + crate: cargo-tarpaulin + version: 0.13.3 + use-tool-cache: true - name: Checkout uses: actions/checkout@v2 - name: Test @@ -57,5 +63,4 @@ jobs: export TRAVIS_JOB_ID=${GITHUB_SHA} export TRAVIS_PULL_REQUEST=false export TRAVIS_BRANCH=${GITHUB_REF##*/} - cargo install cargo-tarpaulin cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID From 36275e1edc889b466a90dfdff72a8853e40f3458 Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:33:34 -0700 Subject: [PATCH 11/13] fixup yaml --- .github/workflows/rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6703c8fbd..fa1450225 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -47,10 +47,10 @@ jobs: rust-version: ${{ matrix.rust }} - name: Install Tarpaulin uses: actions-rs/install@v0.1 - with: - crate: cargo-tarpaulin - version: 0.13.3 - use-tool-cache: true + with: + crate: cargo-tarpaulin + version: 0.13.3 + use-tool-cache: true - name: Checkout uses: actions/checkout@v2 - name: Test From 55c90b334eba8292426768fdcd2fb25aafc70c8b Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 07:46:07 -0700 Subject: [PATCH 12/13] fixup typo --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fa1450225..c310169ee 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -54,7 +54,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Test - run: cargo test -- all-features + run: cargo test --all-features - name: Coverage if: matrix.rust == 'stable' run: | From 8ef50c664048bcf4563c109f71395755b9ac74cd Mon Sep 17 00:00:00 2001 From: Max Countryman Date: Sun, 7 Jun 2020 09:11:34 -0700 Subject: [PATCH 13/13] use coveralls action --- .github/workflows/rust.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c310169ee..a53e0babc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -57,10 +57,9 @@ jobs: run: cargo test --all-features - name: Coverage if: matrix.rust == 'stable' - run: | - # Tarpaulin interoperates with CI services, however Actions is not - # currently supported. As a workaround, we can pretend to be Travis. - export TRAVIS_JOB_ID=${GITHUB_SHA} - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=${GITHUB_REF##*/} - cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID + run: cargo tarpaulin -o Lcov --output-dir ./coverage + - name: Coveralls + if: matrix.rust == 'stable' + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }}