Skip to content

SDK E2E test

SDK E2E test #83

Workflow file for this run

name: SDK E2E test
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * *"
jobs:
setup:
runs-on: ubuntu-latest
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 node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Setup project
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
npm run setup
- 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
uses: satak/webrequest-action@master
if: ${{ github.event_name == 'schedule' && (success() || (failure() && github.run_attempt >= 5)) }}
with:
url: https://prod-30.eastus.logic.azure.com:443/workflows/9aa865da96054bd89749c2d4ce68df8e/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=uIoB06NUHSnKoZeWjNDI9t4rrhbTBKxJNiBtDoMRSQs
method: POST
payload: |
{
"to": "${{ steps.list-jobs.outputs.to }}",
"body": "${{ steps.list-jobs.outputs.body }}",
"subject": "${{ steps.list-jobs.outputs.subject }}",
"apiKey": "${{ secrets.MAIL_API_KEY }}"
}