From c0a2670934c8bd5612e8da3860d9065c56bc6a86 Mon Sep 17 00:00:00 2001 From: Hussein Ait Lahcen Date: Mon, 8 Jan 2024 18:32:32 +0100 Subject: [PATCH] feat(ci): add evm coverage --- .github/workflows/coverage.yml | 61 ++++++++++++++++++++++++++++++++++ evm/evm.nix | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..31fae30c84 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,61 @@ +name: Coverage + +on: + pull_request: + branches: + - main + +permissions: read-all + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + build: + uses: unionlabs/workflows/.github/workflows/build.yml@d051991e4b808b70746fbef3900ed33307a65db6 + secrets: + nixbuild_token: ${{ secrets.nixbuild_token }} + access-tokens: github.com=${{ secrets.GITHUB_TOKEN }} + with: + filter_builds: '(.top_attr == "packages") and (.system == "x86_64-linux") and (.attr == "evm-coverage")' + + + report: + runs-on: ubuntu-latest + needs: [build] + permissions: write-all + steps: + - uses: actions/download-artifact@v3 + with: + name: packages.x86_64-linux.evm-coverage + - uses: nixbuild/nix-quick-install-action@v22 + - uses: nixbuild/nixbuild-action@master + with: + nixbuild_token: ${{ secrets.nixbuild_token }} + - run: | + echo "Getting OUTPUT and NARINFO_NAME" + cat result.json + OUTPUT=`cat result.json | jq -r '.packages.x86_64-linux."evm-coverage".outputs.out'` + NARINFO_NAME=$(basename "$OUTPUT" | cut -d'-' -f1) + + echo "Copying artifacts from nixbuild.net" + nix copy --to file://`pwd`/x86_64-linux --from ssh-ng://eu.nixbuild.net $OUTPUT --extra-experimental-features nix-command + + echo "Get the NAR_URL" + nar_url_line=$(cat ./x86_64-linux/${NARINFO_NAME}.narinfo | grep "URL:") + NAR_URL=$(echo "$nar_url_line" | cut -d " " -f 2-) + + echo "Restore the package from the NAR_URL archive" + cat x86_64-linux/${NAR_URL} | xz -dc | nix-store --restore x86_64-linux.evm-coverage + + mv x86_64-linux.evm-coverage/lcov.info lcov.info + - uses: actions/download-artifact@v3 + - name: Report code coverage + uses: zgosalvez/github-actions-report-lcov@v3 + with: + coverage-files: lcov.info + minimum-coverage: 90 + artifact-name: code-coverage-report + github-token: ${{ secrets.GITHUB_TOKEN }} + update-comment: true diff --git a/evm/evm.nix b/evm/evm.nix index 9568fe818e..485e84e439 100644 --- a/evm/evm.nix +++ b/evm/evm.nix @@ -313,7 +313,7 @@ }; evm-coverage = - pkgs.runCommand "evm-coverage.log" + pkgs.runCommand "evm-coverage" { buildInputs = [ wrappedForge pkgs.lcov ]; } ''