Merge branch 'master' into change_threshold

This commit is contained in:
Dapr Bot 2022-10-05 17:33:46 -07:00 committed by GitHub
commit 56ece3cfee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 233 additions and 17 deletions

View File

@ -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,21 @@ 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 }}
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
# Components certification 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 }}
@ -124,8 +148,6 @@ jobs:
run:
shell: bash
needs: generate-matrix
env:
PROJECT_PATH: ./src/github.com/dapr/components-contrib
strategy:
fail-fast: false # Keep running even if one component fails
@ -147,10 +169,9 @@ jobs:
echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV
fi
- name: Check out code onto GOPATH
- name: Check out code
uses: actions/checkout@v2
with:
path: ${{ env.PROJECT_PATH }}
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}
@ -162,10 +183,13 @@ jobs:
- name: Configure certification test and source path
run: |
TEST_COMPONENT=$(echo ${{ matrix.component }} | sed -E 's/\./\//g')
export TEST_PATH="${PROJECT_PATH}/tests/certification/${TEST_COMPONENT}"
export TEST_PATH="tests/certification/${TEST_COMPONENT}"
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:
@ -254,15 +278,36 @@ jobs:
done
if [[ -v CERTIFICATION_FAILURE ]]; then
echo "CERTIFICATION_FAILURE=true" >> $GITHUB_ENV
exit 1
else
echo "CERTIFICATION_FAILURE=false" >> $GITHUB_ENV
fi
- name: Prepare test result info
if: always()
run: |
mkdir -p tmp/result_files
echo "Writing to tmp/result_files/${{ matrix.component }}.txt"
if [[ "${{ env.CERTIFICATION_FAILURE }}" == "true" ]]; then
echo "0" >> "tmp/result_files/${{ matrix.component }}.txt"
else
echo "1" >> "tmp/result_files/${{ matrix.component }}.txt"
fi
- name: Upload result files
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
@ -290,20 +335,83 @@ 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: testresults
with:
name: result_files
path: tmp/result_files
- name: Build message
if: env.PR_NUMBER != ''
run: |
BASEPATH="${{steps.testresults.outputs.download-path}}"
mkdir -p tmp/
cat << EOT > tmp/message.txt
# Components conformance test
🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**
Commit ref: ${{ env.CHECKOUT_REF }}
## Result
| Component | Status |
| --- | --- |
EOT
ls "$BASEPATH" | while read f; do
while read LINE; do
if [[ "$LINE" == "1" ]]; then
echo "| ${f%.*} | ✅ |" >> tmp/message.txt
elif [[ "$LINE" == "0" ]]; then
echo "| ${f%.*} | ❌ |" >> tmp/message.txt
else
echo "| ${f%.*} | 🤔 |" >> tmp/message.txt
fi
done < "$BASEPATH/$f"
done
echo "Final message"
cat tmp/message.txt
- name: Replace PR comment
if: env.PR_NUMBER != ''
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
path: tmp/message.txt
- 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=60.0
echo "threshold=$threshold" >> $GITHUB_ENV
@ -325,14 +433,15 @@ jobs:
echo "totalPer=$totalPer" >> $GITHUB_ENV
echo "aboveThreshold=$aboveThreshold" >> $GITHUB_ENV
echo "totalFiles=$totalFiles" >> $GITHUB_ENV
done < ${{steps.download.outputs.download-path}}/$f
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 }}%'
args: 'Total Coverage for Certification Tests is {{ totalPer }}%. {{ aboveThreshold }} out of {{ totalFiles }} components have certification tests with code coverage > {{ threshold }}%'

View File

@ -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,21 @@ 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 }}
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 }}
@ -143,10 +167,7 @@ jobs:
defaults:
run:
shell: bash
working-directory: ${{ env.PROJECT_PATH }}
needs: generate-matrix
env:
PROJECT_PATH: ./src/github.com/dapr/components-contrib
strategy:
fail-fast: false # Keep running even if one component fails
@ -168,12 +189,12 @@ 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:
path: ${{ env.PROJECT_PATH }}
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}
@ -423,6 +444,25 @@ jobs:
exit 1
fi
- name: Prepare test result info
if: always()
run: |
mkdir -p tmp/result_files
echo "Writing to tmp/result_files/${{ matrix.component }}.txt"
if [[ "${{ env.CONFORMANCE_FAILURE }}" == "true" ]]; then
echo "0" >> "tmp/result_files/${{ matrix.component }}.txt"
else
echo "1" >> "tmp/result_files/${{ matrix.component }}.txt"
fi
- name: Upload result files
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 +470,70 @@ 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: testresults
with:
name: result_files
path: tmp/result_files
- name: Build message
if: env.PR_NUMBER != ''
run: |
BASEPATH="${{steps.testresults.outputs.download-path}}"
mkdir -p tmp/
cat << EOT > tmp/message.txt
# Components conformance test
🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**
Commit ref: ${{ env.CHECKOUT_REF }}
## Result
| Component | Status |
| --- | --- |
EOT
ls "$BASEPATH" | while read f; do
while read LINE; do
if [[ "$LINE" == "1" ]]; then
echo "| ${f%.*} | ✅ |" >> tmp/message.txt
elif [[ "$LINE" == "0" ]]; then
echo "| ${f%.*} | ❌ |" >> tmp/message.txt
else
echo "| ${f%.*} | 🤔 |" >> tmp/message.txt
fi
done < "$BASEPATH/$f"
done
echo "Final message"
cat tmp/message.txt
- name: Replace PR comment
if: env.PR_NUMBER != ''
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
path: tmp/message.txt