From 37b959a3e9854767e2e954a581bbe640d6d8e21a Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Fri, 3 May 2024 10:10:50 +0200 Subject: [PATCH] ci: send data to coveralls from emqx/emqx only also optimize cover reports - submit in parallel --- .github/workflows/_pr_entrypoint.yaml | 9 +- .github/workflows/_push-entrypoint.yaml | 13 +- .github/workflows/run_test_cases.yaml | 176 +++++++++++------------- rebar.config.erl | 2 +- 4 files changed, 98 insertions(+), 102 deletions(-) diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 4c8349f3f..b56c958a6 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -14,9 +14,6 @@ on: env: IS_CI: "yes" -permissions: - contents: read - jobs: sanity-checks: runs-on: ubuntu-22.04 @@ -32,6 +29,9 @@ jobs: otp_vsn: "26.2.1-2" elixir_vsn: "1.15.7" + permissions: + contents: read + steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: @@ -127,6 +127,9 @@ jobs: - emqx - emqx-enterprise + permissions: + contents: read + steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index 24ac94db8..7033ab989 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -13,9 +13,10 @@ on: - 'master' - 'release-5[0-9]' - 'ci/**' - -permissions: - contents: read + workflow_dispatch: + inputs: + ref: + required: false env: IS_CI: 'yes' @@ -36,6 +37,9 @@ jobs: otp_vsn: '26.2.1-2' elixir_vsn: '1.15.7' + permissions: + contents: read + steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: @@ -132,6 +136,9 @@ jobs: - emqx - emqx-enterprise + permissions: + contents: read + steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: diff --git a/.github/workflows/run_test_cases.yaml b/.github/workflows/run_test_cases.yaml index 47e2fd194..0c7c4adfe 100644 --- a/.github/workflows/run_test_cases.yaml +++ b/.github/workflows/run_test_cases.yaml @@ -20,9 +20,6 @@ on: required: true type: string -permissions: - contents: read - env: IS_CI: "yes" @@ -40,35 +37,39 @@ jobs: shell: bash container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04" + env: + PROFILE: ${{ matrix.profile }} + ENABLE_COVER_COMPILE: 1 + CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }} + + permissions: + contents: read + steps: - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 with: name: ${{ matrix.profile }} + - name: extract artifact run: | unzip -o -q ${{ matrix.profile }}.zip git config --global --add safe.directory "$GITHUB_WORKSPACE" # produces eunit.coverdata - - name: eunit - env: - PROFILE: ${{ matrix.profile }} - ENABLE_COVER_COMPILE: 1 - CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }} - run: make eunit + - run: make eunit # produces proper.coverdata - - name: proper - env: - PROFILE: ${{ matrix.profile }} - ENABLE_COVER_COMPILE: 1 - CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }} - run: make proper + - run: make proper - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: coverdata-${{ matrix.profile }}-${{ matrix.otp }} - path: _build/test/cover - retention-days: 7 + - run: make cover + + - name: send to coveralls + if: github.repository == 'emqx/emqx' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make coveralls + + - run: cat rebar3.crashdump + if: failure() ct_docker: runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }} @@ -82,6 +83,12 @@ jobs: run: shell: bash + env: + PROFILE: ${{ matrix.profile }} + + permissions: + contents: read + steps: - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 with: @@ -89,7 +96,6 @@ jobs: - name: extract artifact run: | unzip -o -q ${{ matrix.profile }}.zip - git config --global --add safe.directory "$GITHUB_WORKSPACE" # produces $PROFILE---sg.coverdata - name: run common tests @@ -103,19 +109,30 @@ jobs: TDENGINE_TAG: "3.0.2.4" OPENTS_TAG: "9aa7f88" MINIO_TAG: "RELEASE.2023-03-20T20-16-18Z" - PROFILE: ${{ matrix.profile }} SUITEGROUP: ${{ matrix.suitegroup }} ENABLE_COVER_COMPILE: 1 CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }} - run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: coverdata-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }} - path: _build/test/cover - retention-days: 7 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} --keep-up + + - name: make cover + run: | + docker exec -e PROFILE="$PROFILE" -t erlang make cover + + - name: send to coveralls + if: github.repository == 'emqx/emqx' + run: | + ls _build/test/cover/*.coverdata || exit 0 + docker exec -e PROFILE="$PROFILE" -t erlang make coveralls + + - name: rebar3.crashdump + if: failure() + run: cat rebar3.crashdump + - name: compress logs if: failure() run: tar -czf logs.tar.gz _build/test/logs + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 if: failure() with: @@ -137,6 +154,15 @@ jobs: run: shell: bash + permissions: + contents: read + + env: + PROFILE: ${{ matrix.profile }} + SUITEGROUP: ${{ matrix.suitegroup }} + ENABLE_COVER_COMPILE: 1 + CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }} + steps: - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 with: @@ -148,22 +174,25 @@ jobs: # produces $PROFILE---sg.coverdata - name: run common tests + run: make "${{ matrix.app }}-ct" + + - run: make cover + + - name: send to coveralls + if: github.repository == 'emqx/emqx' env: - PROFILE: ${{ matrix.profile }} - SUITEGROUP: ${{ matrix.suitegroup }} - ENABLE_COVER_COMPILE: 1 - CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - make "${{ matrix.app }}-ct" - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: coverdata-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }} - path: _build/test/cover - if-no-files-found: warn # do not fail if no coverdata found - retention-days: 7 + ls _build/test/cover/*.coverdata || exit 0 + make coveralls + + - run: cat rebar3.crashdump + if: failure() + - name: compress logs if: failure() run: tar -czf logs.tar.gz _build/test/logs + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 if: failure() with: @@ -180,61 +209,18 @@ jobs: runs-on: ubuntu-22.04 strategy: fail-fast: false + + permissions: + pull-requests: write + steps: + - name: Coveralls finished + if: github.repository == 'emqx/emqx' + uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3 + with: + parallel-finished: true + git-branch: ${{ github.ref }} + git-commit: ${{ github.sha }} + - run: echo "All tests passed" - - make_cover: - needs: - - eunit_and_proper - - ct - - ct_docker - runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }} - container: ${{ inputs.builder }} - strategy: - fail-fast: false - matrix: - profile: - - emqx-enterprise - steps: - - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 - with: - name: ${{ matrix.profile }} - - name: extract artifact - run: | - unzip -o -q ${{ matrix.profile }}.zip - git config --global --add safe.directory "$GITHUB_WORKSPACE" - - - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 - name: download coverdata - with: - pattern: coverdata-${{ matrix.profile }}-* - path: _build/test/cover - merge-multiple: true - - - name: make cover - env: - PROFILE: emqx-enterprise - run: make cover - - - name: send to coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PROFILE: emqx-enterprise - run: make coveralls - - - name: get coveralls logs - if: failure() - run: cat rebar3.crashdump - - # do this in a separate job - upload_coverdata: - needs: make_cover - runs-on: ubuntu-22.04 - steps: - - name: Coveralls Finished - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -v -k https://coveralls.io/webhook \ - --header "Content-Type: application/json" \ - --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true + diff --git a/rebar.config.erl b/rebar.config.erl index 399f34b18..6d4027f10 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -190,7 +190,7 @@ plugins() -> test_plugins() -> [ {rebar3_proper, "0.12.1"}, - {coveralls, {git, "https://github.com/emqx/coveralls-erl", {tag, "v2.2.0-emqx-1"}}} + {coveralls, {git, "https://github.com/emqx/coveralls-erl", {tag, "v2.2.0-emqx-2"}}} ]. test_deps() ->