diff --git a/.github/workflows/certification.yml b/.github/workflows/certification.yml index 8cb640628..d2f21246b 100644 --- a/.github/workflows/certification.yml +++ b/.github/workflows/certification.yml @@ -31,6 +31,15 @@ jobs: generate-matrix: runs-on: ubuntu-latest steps: + - name: Parse repository_dispatch payload + if: github.event_name == 'repository_dispatch' + working-directory: ${{ github.workspace }} + run: | + if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then + echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.client_payload.issue.number }}" >> $GITHUB_ENV + fi + - name: Install yq run: | sudo snap install yq @@ -113,6 +122,23 @@ jobs: EOF ) echo "::set-output name=cloud-components::$CRON_COMPONENTS" + + - name: Create PR comment + if: env.PR_NUMBER != '' + uses: artursouza/sticky-pull-request-comment@v2.2.0 + with: + header: ${{ github.run_id }} + number: ${{ env.PR_NUMBER }} + hide: true + hide_classify: OUTDATED + GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }} + message: | + # Components conformance test + + 🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})** + + Commit ref: ${{ env.CHECKOUT_REF }} + outputs: pr-components: ${{ steps.pr-components.outputs.pr-components }} cloud-components: ${{ steps.cloud-components.outputs.cloud-components }} @@ -166,6 +192,9 @@ jobs: echo "TEST_PATH=$TEST_PATH" >> $GITHUB_ENV export SOURCE_PATH="github.com/dapr/components-contrib/${TEST_COMPONENT}" echo "SOURCE_PATH=$SOURCE_PATH" >> $GITHUB_ENV + # converts slashes to dots in this string, so that it doesn't consider them sub-folders + export SOURCE_PATH_LINEAR=$(echo "$SOURCE_PATH" |sed 's#/#\.#g') + echo "SOURCE_PATH_LINEAR=$SOURCE_PATH_LINEAR" >> $GITHUB_ENV - uses: Azure/login@v1 with: @@ -230,6 +259,9 @@ jobs: if test $status -ne 0; then echo "Setting CERTIFICATION_FAILURE" export CERTIFICATION_FAILURE=true + echo "CERTIFICATION_FAILURE=true" >> $GITHUB_ENV + else + echo "CERTIFICATION_FAILURE=false" >> $GITHUB_ENV fi set -e @@ -256,12 +288,29 @@ jobs: exit 1 fi + - name: Prepare test result info + if: always() + run: | + mkdir -p tmp/result_files + if [[ -v ${{ env.CERTIFICATION_FAILURE }} ]]; then + echo "0" >> tmp/result_files/${{ matrix.component }} + else + echo "1" >> tmp/result_files/${{ matrix.component }} + fi + + - name: Upload test result artifact + uses: actions/upload-artifact@v3 + if: always() + with: + name: result_files + path: tmp/result_files + retention-days: 1 + - name: Prepare Cert Coverage Info if: github.event_name == 'schedule' run: | mkdir -p tmp/cov_files - SOURCE_PATH_LINEAR=$(echo ${{ env.SOURCE_PATH }} |sed 's#/#\.#g') # converts slashes to dots in this string, so that it doesn't consider them sub-folders - echo "${{ env.COVERAGE_LINE }}" >> tmp/cov_files/$SOURCE_PATH_LINEAR.txt + echo "${{ env.COVERAGE_LINE }}" >> tmp/cov_files/${{ env.SOURCE_PATH_LINEAR }}.txt - name: Upload Cert Coverage Artifact uses: actions/upload-artifact@v3 @@ -289,20 +338,39 @@ jobs: path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_certification.* post_job: - name: Notify Total coverage + name: Post-completion runs-on: ubuntu-latest needs: certification - if: github.event_name == 'schedule' steps: + - name: Parse repository_dispatch payload + if: github.event_name == 'repository_dispatch' + working-directory: ${{ github.workspace }} + run: | + if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then + echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.client_payload.issue.number }}" >> $GITHUB_ENV + fi + + - name: Download test result artifact + if: env.PR_NUMBER != '' + uses: actions/download-artifact@v3 + continue-on-error: true + id: download + with: + name: result_files + path: tmp/result_files + - name: Download Cert Coverage Artifact uses: actions/download-artifact@v3 continue-on-error: true + if: github.event_name == 'schedule' id: download with: name: certtest_cov path: tmp/cov_files - name: Calculate total coverage + if: github.event_name == 'schedule' run: | threshold=80.0 echo "threshold=$threshold" >> $GITHUB_ENV @@ -327,11 +395,12 @@ jobs: done < ${{steps.download.outputs.download-path}}/$f done continue-on-error: true - + - name: Final Coverage Discord Notification + if: github.event_name == 'schedule' env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_WEBHOOK_URL }} uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9 continue-on-error: true with: - args: 'Total Coverage for Certification Tests is {{ totalPer }}%. {{ aboveThreshold }} out of {{ totalFiles }} components have certification tests with code coverage > {{ threshold }}%' \ No newline at end of file + args: 'Total Coverage for Certification Tests is {{ totalPer }}%. {{ aboveThreshold }} out of {{ totalFiles }} components have certification tests with code coverage > {{ threshold }}%' diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 702abd315..8e5e38fe7 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -31,6 +31,15 @@ jobs: generate-matrix: runs-on: ubuntu-latest steps: + - name: Parse repository_dispatch payload + if: github.event_name == 'repository_dispatch' + working-directory: ${{ github.workspace }} + run: | + if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then + echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.client_payload.issue.number }}" >> $GITHUB_ENV + fi + - name: Install yq run: | sudo snap install yq @@ -133,6 +142,23 @@ jobs: EOF ) echo "::set-output name=cron-components::$CRON_COMPONENTS" + + - name: Create PR comment + if: env.PR_NUMBER != '' + uses: artursouza/sticky-pull-request-comment@v2.2.0 + with: + header: ${{ github.run_id }} + number: ${{ env.PR_NUMBER }} + hide: true + hide_classify: OUTDATED + GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }} + message: | + # Components conformance test + + 🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})** + + Commit ref: ${{ env.CHECKOUT_REF }} + outputs: pr-components: ${{ steps.pr-components.outputs.pr-components }} cron-components: ${{ steps.cron-components.outputs.cron-components }} @@ -168,8 +194,9 @@ jobs: if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.client_payload.issue.number }}" >> $GITHUB_ENV fi - + - name: Check out code onto GOPATH uses: actions/checkout@v2 with: @@ -372,6 +399,8 @@ jobs: if test $status -ne 0; then echo "Setting CONFORMANCE_FAILURE" echo "CONFORMANCE_FAILURE=true" >> $GITHUB_ENV + else + echo "CONFORMANCE_FAILURE=false" >> $GITHUB_ENV fi set -e @@ -423,6 +452,24 @@ jobs: exit 1 fi + - name: Prepare test result info + if: always() + run: | + mkdir -p tmp/result_files + if [[ -v ${{ env.CONFORMANCE_FAILURE }} ]]; then + echo "0" >> tmp/result_files/${{ matrix.component }} + else + echo "1" >> tmp/result_files/${{ matrix.component }} + fi + + - name: Upload test result artifact + uses: actions/upload-artifact@v3 + if: always() + with: + name: result_files + path: tmp/result_files + retention-days: 1 + # Upload logs for test analytics to consume - name: Upload test results if: always() @@ -430,3 +477,26 @@ jobs: with: name: ${{ matrix.component }}_conformance_test path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_conformance.* + + post_job: + name: Post-completion + runs-on: ubuntu-latest + needs: conformance + steps: + - name: Parse repository_dispatch payload + if: github.event_name == 'repository_dispatch' + working-directory: ${{ github.workspace }} + run: | + if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then + echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.client_payload.issue.number }}" >> $GITHUB_ENV + fi + + - name: Download test result artifact + if: env.PR_NUMBER != '' + uses: actions/download-artifact@v3 + continue-on-error: true + id: download + with: + name: result_files + path: tmp/result_files