SDK E2E test #1046
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SDK E2E test | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 5 * * *" | |
push: | |
branches: | |
- renovate/** | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
env: | |
SDK_INTEGRATION_TEST_SQL: ${{ secrets.SDK_INTEGRATION_TEST_SQL }} | |
SDK_INTEGRATION_TEST_ACCOUNT: ${{ secrets.SDK_INTEGRATION_TEST_ACCOUNT }} | |
SDK_INTEGRATION_TEST_AAD: ${{ secrets.SDK_INTEGRATION_TEST_AAD }} | |
SDK_INTEGRATION_TEST_API_CERTPROVIDER: ${{ secrets.SDK_INTEGRATION_TEST_API_CERTPROVIDER }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: setup project | |
uses: ./.github/actions/setup-project | |
- name: setup python | |
uses: actions/setup-python@v3 | |
- name: install xq | |
run: | | |
pip install yq | |
- name: run test - node | |
if: ${{ always() }} | |
working-directory: packages/sdk | |
run: | | |
npm run test:e2e:node | |
- name: run test - browser | |
if: ${{ always() }} | |
working-directory: packages/sdk | |
run: | | |
npm run test:e2e:browser | |
- name: get job id | |
id: get-job-id | |
if: ${{ always() }} | |
uses: ayachensiyuan/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
job-name: "setup" | |
- name: List jobs | |
if: ${{ always() }} | |
id: list-jobs | |
working-directory: packages/sdk | |
run: | | |
lists="" | |
total_node=`cat test-results.node.xml | xq '.testsuite| ."@tests"' | sed -e 's/"//g'` | |
total_browser=`cat test-results.browser.xml | xq '.testsuite| ."@tests"' | sed -e 's/"//g'` | |
total=$((total_node+total_browser)) | |
error_node=`cat test-results.node.xml | xq '.testsuite| ."@errors"' | sed -e 's/"//g'` | |
error_browser=`cat test-results.browser.xml | xq '.testsuite| ."@errors"' | sed -e 's/"//g'` | |
failed=$((error_node+error_browser)) | |
passed=$((total-failed)) | |
emails="[email protected]" | |
case_node=`cat test-results.node.xml | xq '.testsuite | .testcase'` | |
case_browser=`cat test-results.browser.xml | xq '.testsuite | .testcase'` | |
for case in $(jq --slurp 'add' <(echo "$case_node ") <(echo "$case_browser") | jq -r '.[] | @base64'); do | |
_jq() { | |
echo "${case}" | base64 --decode | jq -r "${1}" | |
} | |
if [ -z "$case" ]; then | |
continue | |
fi | |
suite=$(_jq '."@classname"' | sed -e 's/"/\\"/g') | |
name=$(_jq '."@name"' | sed -e 's/"/\\"/g') | |
duration=$(_jq '."@time"'| sed -e 's/"/\\"/g') | |
failure=$(_jq '.failure'| sed -e 's/"/\\"/g') | |
email="[email protected]" | |
author="<a href=\\\"mailto:$email\\\"><span>$email</span></a>" | |
label="" | |
if [ "$failure" == "null" ]; then | |
label="<span style=\\\"background-color:#2aa198;color:white;font-weight:bold;\\\">PASSED</span>" | |
else | |
label="<span style=\\\"background-color:#dc322f;color:white;font-weight:bold;\\\">FAILED</span>" | |
fi | |
if [[ ! -z "$email" && ! "$emails" == *"$email"* && "$failure" ]]; then | |
emails="$emails;$email" | |
fi | |
row="<tr> <td style=\\\"text-align: left;\\\">$suite</td> <td style=\\\"text-align: left;\\\">$name</td> <td style=\\\"text-align: center;\\\">$label</td> <td style=\\\"text-align: center;\\\">$author</td> <td>$duration sec</td> </tr>" | |
if [[ -z "$failure" ]]; then | |
lists="$lists $row" | |
else | |
lists="$row $lists" | |
fi | |
done | |
body="<table class=\\\"w3-table w3-striped w3-bordered\\\"> <tr> <th>Suite</th> <th>Case</th> <th>Status</th> <th>Author</th> <th>Duration</th> </tr> $lists </table> <br /> The detail can be found here: <a> https://github.com/OfficeDev/TeamsFx/actions/runs/${{ github.run_id }}</a>" | |
subject="SDK E2E Test Report ($passed/$total Passed)" | |
if [ $failed -gt 0 ]; then | |
subject="[FAILED] $subject" | |
else | |
subject="[PASSED] $subject" | |
fi | |
echo "body=$body" >> $GITHUB_OUTPUT | |
echo "to=$emails" >> $GITHUB_OUTPUT | |
echo "subject=$subject" >> $GITHUB_OUTPUT | |
- name: Rerun | |
if: ${{ github.event_name == 'schedule' && failure() && github.run_attempt < 5 }} | |
run: | | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/rerun.yml/dispatches \ | |
-d '{"ref":"${{ github.ref_name }}","inputs":{"run_id":"${{ github.run_id }}", "max_attempts":"5"}}' | |
- name: Report result | |
if: ${{ github.event_name == 'schedule' && (success() || (failure() && github.run_attempt >= 5)) }} | |
uses: ./.github/actions/send-email-report | |
env: | |
TO: ${{ steps.list-jobs.outputs.to }} | |
BODY: '"${{ steps.list-jobs.outputs.body }}"' | |
SUBJECT: ${{ steps.list-jobs.outputs.subject }} | |
MAIL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }} | |
MAIL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }} | |
MAIL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }} |