From 093087eb1d84767bc582bdf9b7515dd7ce4c4c98 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Wed, 19 Jan 2022 17:42:12 -0500 Subject: [PATCH] Update the include_str support to fix CI on nightly (#12) * Update the include_str support to fix CI on nightly * Upgrade coverage.yaml to use cargo-llvm-cov * Show CodeCov comment on PRs --- .github/workflows/coverage.yaml | 52 ++++++++++++--------------------- codecov.yml | 12 +++----- src/lib.rs | 4 +-- 3 files changed, 24 insertions(+), 44 deletions(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 237fa0b..9bb3fc2 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -1,6 +1,7 @@ -name: CI +name: Coverage on: + workflow_dispatch: pull_request: branches: - main @@ -11,48 +12,33 @@ on: jobs: coverage: - name: Coverage + name: Coverage (+nightly) timeout-minutes: 30 - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2.4.0 + with: + persist-credentials: false - uses: actions-rs/toolchain@v1.0.7 with: - toolchain: nightly + # Pinned to workaround issue making cargo-llvm-cov fail, see + # https://github.com/taiki-e/cargo-llvm-cov/issues/128 + # TODO: restore to just `nightly` after it's fixed + toolchain: nightly-2022-01-14 override: true profile: minimal components: llvm-tools-preview - - name: Install rustfilt symbol demangler - run: | - cargo install rustfilt + - name: Install cargo-llvm-cov cargo command + run: cargo install cargo-llvm-cov - - name: Rerun tests for coverage - env: - RUSTFLAGS: -Zinstrument-coverage -C link-dead-code -C debuginfo=2 - LLVM_PROFILE_FILE: "${{ github.workspace }}/test.%p.profraw" - ZEBRA_SKIP_NETWORK_TESTS: 1 - run: | - cargo test - cargo test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > filenames.txt + - name: Run tests + run: cargo llvm-cov --lcov --no-report - - name: Merge coverage data - run: | - $(rustc --print target-libdir)/../bin/llvm-profdata merge test.*.profraw -o test.profdata - - - name: Generate detailed html coverage report for github artifact - run: | - $(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(printf -- "-object %s " $(cat filenames.txt)) - - - uses: actions/upload-artifact@v2 - with: - name: coverage - path: ./coverage - - - name: Generate lcov coverage report for codecov - run: | - $(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(printf -- "-object %s " $(cat filenames.txt)) > "lcov.info" + - name: Generate coverage report + run: cargo llvm-cov --lcov --no-run --output-path lcov.info - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v1.5.2 + uses: codecov/codecov-action@v2.1.0 diff --git a/codecov.yml b/codecov.yml index 8dc6498..6d93fe3 100644 --- a/codecov.yml +++ b/codecov.yml @@ -16,14 +16,10 @@ parsers: method: yes macro: yes -# comment: -# layout: "diff" -# # if true: only post the comment if coverage changes -# require_changes: true - -# This turns off the extra comment; the coverage %'s are still -# reported on the main PR page as check results -comment: false +comment: + layout: "diff" + # post a coverage comment, even if coverage hasn't changed + require_changes: false github_checks: annotations: false diff --git a/src/lib.rs b/src/lib.rs index fff6b3d..2e3723a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,10 +8,8 @@ // - Deirdre Connolly // - Henry de Valence -#![doc(html_root_url = "https://docs.rs/reddsa/0.1.0")] -#![cfg_attr(feature = "nightly", feature(external_doc))] -#![cfg_attr(feature = "nightly", doc(include = "../README.md"))] #![deny(missing_docs)] +#![doc = include_str!("../README.md")] //! Docs require the `nightly` feature until RFC 1990 lands.