From a8511c0f36746930a30366da56c3191712b01a61 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sat, 31 Dec 2022 22:27:23 -0800 Subject: [PATCH] chore: Update `.github/workflows/code-coverage.yaml` in `artichoke/posix-space` Managed by Terraform. ## Contents ``` --- name: Code Coverage "on": push: branches: - trunk pull_request: branches: - trunk jobs: generate: name: Generate permissions: id-token: write contents: read runs-on: ubuntu-latest env: RUST_BACKTRACE: 1 CARGO_NET_GIT_FETCH_WITH_CLI: true steps: - name: Checkout repository uses: actions/checkout@v3 - name: Install nightly Rust toolchain uses: artichoke/setup-rust/code-coverage@v1 - name: Setup grcov run: | release_url="$(curl \ --url https://api.github.com/repos/mozilla/grcov/releases \ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ --header 'content-type: application/json' \ --silent \ --fail \ --retry 5 \ | jq -r '.[0].assets | map(select(.browser_download_url | test(".*x86_64-unknown-linux-musl.tar.bz2$"))) | .[0].browser_download_url' )" curl -sL "$release_url" | sudo tar xvj -C /usr/local/bin/ - name: Show grcov version run: grcov --version - name: Generate coverage env: LLVM_PROFILE_FILE: "posix-space-%m-%p.profraw" RUSTFLAGS: "-C instrument-coverage" # Unstable feature: https://github.com/rust-lang/rust/issues/56925 RUSTDOCFLAGS: "-C instrument-coverage -Z unstable-options --persist-doctests target/debug/doctests" run: cargo test - name: Generate HTML report run: grcov posix-space*.profraw --source-dir . --keep-only 'src/**/*.rs' --binary-path target/debug -t html --filter covered -o target/coverage - name: Generate detailed JSON report run: grcov posix-space*.profraw --source-dir . --keep-only 'src/**/*.rs' --binary-path target/debug -t covdir --filter covered -o target/coverage/coverage.json - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@master if: github.ref == 'refs/heads/trunk' with: aws-region: us-west-2 role-to-assume: arn:aws:iam::447522982029:role/gha-posix-space-s3-backup-20220820215201568100000009 role-session-name: GitHubActionsRustCodeCoverage@posix-space - name: Show AWS caller identity if: github.ref == 'refs/heads/trunk' run: aws sts get-caller-identity - name: Upload archives to S3 if: github.ref == 'refs/heads/trunk' run: | aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.svg' --content-type 'image/svg+xml' aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.html' --content-type 'text/html' aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.json' --content-type 'application/json' aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --include '*' --exclude '*.svg' --exclude '*.html' --exclude '*.json' - name: Check missed lines run: | curl -s https://codecov.artichokeruby.org/posix-space/coverage.json | python -c '\ import sys, json; \ \ trunk_coverage = json.loads(sys.stdin.read()); \ print("On trunk: "); \ print("coveragePercent =", trunk_coverage["coveragePercent"]); \ print("linesCovered =", trunk_coverage["linesCovered"]); \ print("linesMissed =", trunk_coverage["linesMissed"]); \ print("linesTotal =", trunk_coverage["linesTotal"]); \ print(""); \ \ branch_coverage = json.load(open("target/coverage/coverage.json")) print("On PR branch: "); \ print("coveragePercent =", branch_coverage["coveragePercent"]); \ print("linesCovered =", branch_coverage["linesCovered"]); \ print("linesMissed =", branch_coverage["linesMissed"]); \ print("linesTotal =", branch_coverage["linesTotal"]); \ print(""); \ \ is_ok = branch_coverage["linesMissed"] <= trunk_coverage["linesMissed"]; \ exit(0) if is_ok else exit(1) \ ' ``` --- .github/workflows/code-coverage.yaml | 102 --------------------------- 1 file changed, 102 deletions(-) delete mode 100644 .github/workflows/code-coverage.yaml diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml deleted file mode 100644 index e7370de..0000000 --- a/.github/workflows/code-coverage.yaml +++ /dev/null @@ -1,102 +0,0 @@ ---- -name: Code Coverage -"on": - push: - branches: - - trunk - pull_request: - branches: - - trunk -jobs: - generate: - name: Generate - permissions: - id-token: write - contents: read - runs-on: ubuntu-latest - env: - RUST_BACKTRACE: 1 - CARGO_NET_GIT_FETCH_WITH_CLI: true - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install nightly Rust toolchain - uses: artichoke/setup-rust/code-coverage@v1 - - - name: Setup grcov - run: | - release_url="$(curl \ - --url https://api.github.com/repos/mozilla/grcov/releases \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'content-type: application/json' \ - --silent \ - --fail \ - --retry 5 \ - | jq -r '.[0].assets - | map(select(.browser_download_url | test(".*x86_64-unknown-linux-musl.tar.bz2$"))) - | .[0].browser_download_url' - )" - curl -sL "$release_url" | sudo tar xvj -C /usr/local/bin/ - - - name: Show grcov version - run: grcov --version - - - name: Generate coverage - env: - LLVM_PROFILE_FILE: "posix-space-%m-%p.profraw" - RUSTFLAGS: "-C instrument-coverage" - # Unstable feature: https://github.com/rust-lang/rust/issues/56925 - RUSTDOCFLAGS: "-C instrument-coverage -Z unstable-options --persist-doctests target/debug/doctests" - run: cargo test - - - name: Generate HTML report - run: grcov posix-space*.profraw --source-dir . --keep-only 'src/**/*.rs' --binary-path target/debug -t html --filter covered -o target/coverage - - - name: Generate detailed JSON report - run: grcov posix-space*.profraw --source-dir . --keep-only 'src/**/*.rs' --binary-path target/debug -t covdir --filter covered -o target/coverage/coverage.json - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@master - if: github.ref == 'refs/heads/trunk' - with: - aws-region: us-west-2 - role-to-assume: arn:aws:iam::447522982029:role/gha-posix-space-s3-backup-20220820215201568100000009 - role-session-name: GitHubActionsRustCodeCoverage@posix-space - - - name: Show AWS caller identity - if: github.ref == 'refs/heads/trunk' - run: aws sts get-caller-identity - - - name: Upload archives to S3 - if: github.ref == 'refs/heads/trunk' - run: | - aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.svg' --content-type 'image/svg+xml' - aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.html' --content-type 'text/html' - aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --exclude '*' --include '*.json' --content-type 'application/json' - aws s3 sync target/coverage/ s3://artichoke-forge-code-coverage-us-west-2/posix-space/ --delete --sse AES256 --include '*' --exclude '*.svg' --exclude '*.html' --exclude '*.json' - - - name: Check missed lines - run: | - curl -s https://codecov.artichokeruby.org/posix-space/coverage.json | python -c '\ - import sys, json; \ - \ - trunk_coverage = json.loads(sys.stdin.read()); \ - print("On trunk: "); \ - print("coveragePercent =", trunk_coverage["coveragePercent"]); \ - print("linesCovered =", trunk_coverage["linesCovered"]); \ - print("linesMissed =", trunk_coverage["linesMissed"]); \ - print("linesTotal =", trunk_coverage["linesTotal"]); \ - print(""); \ - \ - branch_coverage = json.load(open("target/coverage/coverage.json")) - print("On PR branch: "); \ - print("coveragePercent =", branch_coverage["coveragePercent"]); \ - print("linesCovered =", branch_coverage["linesCovered"]); \ - print("linesMissed =", branch_coverage["linesMissed"]); \ - print("linesTotal =", branch_coverage["linesTotal"]); \ - print(""); \ - \ - is_ok = branch_coverage["linesMissed"] <= trunk_coverage["linesMissed"]; \ - exit(0) if is_ok else exit(1) \ - '