From 37ba45a627a5c2d905557d068726e33d6b1e93ea Mon Sep 17 00:00:00 2001 From: Max Revitt Date: Fri, 22 Jul 2022 16:09:50 +0100 Subject: [PATCH] feat(ci): badges for hive and code coverage on devel (#4793) * feat(ci): badges for hive and code coverage on devel * feat(ci): hive CI tidy up (#2) run hive on successful CI only run on non-draft PR only --- .github/workflows/ci.yml | 36 ++++++++++++++++++- .github/workflows/coverage.yml | 55 ++++++++++++++++++++++++++++++ .github/workflows/hive-results.yml | 46 ++++++++++++++++++++++--- .github/workflows/hive.yml | 35 ------------------- README.md | 4 +++ 5 files changed, 136 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/coverage.yml delete mode 100644 .github/workflows/hive.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26a80271b30..9781d2e3441 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,6 +119,25 @@ jobs: - name: sudo make docker run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker + hive: + needs: + - tests + - tests-windows + - docker + runs-on: ubuntu-20.04 + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # fetch git tags for "git describe" + + - name: build erigon image + run: DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker + + # check with root permissions, should be cached from previous build + - name: build erigon image (root permissions) + run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker + - name: run hive run: sudo mkdir /results && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work gatewayfm/hive:latest --sim ethereum/engine --results-root=/work/results --client erigon_ci-$GITHUB_SHA --docker.output --loglevel 5 @@ -130,4 +149,19 @@ jobs: if: always() with: name: hive-ci-output - path: results/*.xml + path: results/*.xml + + event_file: + needs: + - tests + - tests-windows + - docker + name: archive event file + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + steps: + - name: upload + uses: actions/upload-artifact@v2 + with: + name: event file + path: ${{ github.event_path }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000000..72deaea1d53 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,55 @@ +name: Coverage +on: + push: + branches: + - devel + +jobs: + coverage: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + - run: git submodule update --init --recursive --force + + - uses: actions/setup-go@v3 + with: + go-version: 1.18.x + + - name: install dependencies on Linux + if: runner.os == 'Linux' + run: sudo apt update && sudo apt install build-essential + + - name: run coverage + run: echo "COVERAGE=$(make coverage)" >> $GITHUB_ENV + + - name: set badge color + shell: bash + run: | + if [ ${{ env.COVERAGE }} -lt 40 ] + then + echo "BADGE_COLOR=800000" >> $GITHUB_ENV + elif [ ${{ env.COVERAGE }} -lt 75 ] + then + echo "BADGE_COLOR=696969" >> $GITHUB_ENV + else + echo "BADGE_COLOR=31c653" >> $GITHUB_ENV + fi + + - name: create badge + uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 + with: + label: Coverage + status: ${{ env.COVERAGE }} + color: ${{ env.BADGE_COLOR }} + path: badge.svg + + - name: upload badge to gist + if: > + github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' || + github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel' + uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d + with: + token: ${{ secrets.GIST_TOKEN }} + gistURL: https://gist.githubusercontent.com/revittm/ee38e9beb22353eef6b88f2ad6ed7aa9 + file: badge.svg \ No newline at end of file diff --git a/.github/workflows/hive-results.yml b/.github/workflows/hive-results.yml index b23dc2ce478..8147393e090 100644 --- a/.github/workflows/hive-results.yml +++ b/.github/workflows/hive-results.yml @@ -2,7 +2,7 @@ name: Hive results on: workflow_run: - workflows: ["Hive"] + workflows: ["CI"] types: - completed @@ -12,8 +12,13 @@ jobs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion != 'skipped' + permissions: + checks: write + pull-requests: write+ + actions: read + steps: - - name: Download and extract artifacts + - name: download and extract artifacts env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | @@ -28,10 +33,43 @@ jobs: unzip -d "$name" "$name.zip" done - - name: Publish hive test results + - name: publish hive test results uses: EnricoMi/publish-unit-test-result-action@v1 with: commit: ${{ github.event.workflow_run.head_sha }} event_file: artifacts/Event File/event.json event_name: ${{ github.event.workflow_run.event }} - files: "artifacts/**/*.xml" \ No newline at end of file + files: "artifacts/**/*.xml" + + - name: set badge color + shell: bash + run: | + case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in + success) + echo "BADGE_COLOR=31c653" >> $GITHUB_ENV + ;; + failure) + echo "BADGE_COLOR=800000" >> $GITHUB_ENV + ;; + neutral) + echo "BADGE_COLOR=696969" >> $GITHUB_ENV + ;; + esac + + - name: create badge + uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 + with: + label: Hive + status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' + color: ${{ env.BADGE_COLOR }} + path: badge.svg + + - name: upload badge to gist + if: > + github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' || + github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel' + uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d + with: + token: ${{ secrets.GIST_TOKEN }} + gistURL: https://gist.githubusercontent.com/revittm/dc492845ba6eb694e6c7279224634b20 + file: badge.svg \ No newline at end of file diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml deleted file mode 100644 index 3705a1fe9ca..00000000000 --- a/.github/workflows/hive.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Hive -on: - workflow_run: - workflows: ["CI"] - types: - - completed - -jobs: - hive: - runs-on: ubuntu-20.04 - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # fetch git tags for "git describe" - - - name: build erigon image - run: DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker - - # check with root permissions, should be cached from previous build - - name: build erigon image (root permissions) - run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker - - - name: run hive - run: sudo mkdir /results && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work gatewayfm/hive:latest --sim ethereum/engine --results-root=/work/results --client erigon_ci-$GITHUB_SHA --docker.output --loglevel 5 - - - name: parse hive output - run: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work --entrypoint /app/hivecioutput gatewayfm/hive:latest --resultsdir=/work/results --outdir=/work/results - - - name: archive hive results - uses: actions/upload-artifact@v3 - if: always() - with: - name: hive-ci-output - path: results/*.xml diff --git a/README.md b/README.md index 5fdff12f27a..760f5fdb034 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Erigon is an implementation of Ethereum (aka "Ethereum client"), on the efficien ![Build status](https://github.com/ledgerwatch/erigon/actions/workflows/ci.yml/badge.svg) +![Coverage](https://gist.githubusercontent.com/revittm/ee38e9beb22353eef6b88f2ad6ed7aa9/raw/19f7838ede42d896370aff17753346a01fc5d4ad/badge.svg) + +![Hive](https://gist.githubusercontent.com/revittm/dc492845ba6eb694e6c7279224634b20/raw/51f5a73aa31c5ae2f199969321161bcb9abc5c10/badge.svg) + - [System Requirements](#system-requirements)