Push cypress test results to kiwitcms not testrail (#10401)
parent
a5fcdd7bfd
commit
853b3f822d
|
@ -25,7 +25,7 @@ jobs:
|
|||
commit_author: ${{ steps.commit.outputs.author }}
|
||||
commit_email: ${{ steps.commit.outputs.email }}
|
||||
percy_enable: ${{ steps.percy.outputs.value || '1' }}
|
||||
testrail_enable: ${{ steps.testrail.outputs.value || '1' }}
|
||||
kiwi_enable: ${{ steps.kiwi.outputs.value || '1' }}
|
||||
steps:
|
||||
# We create the status here and then update it to success/failure in the `report` stage
|
||||
# This provides an easy link to this workflow_run from the PR before Cypress is done.
|
||||
|
@ -67,12 +67,12 @@ jobs:
|
|||
!contains(fromJSON(steps.prdetails.outputs.data).labels.*.name, 'X-Needs-Percy')
|
||||
run: echo "::set-output name=value::0"
|
||||
|
||||
# Only run Testrail when it is demanded or on develop
|
||||
- name: Disable Testrail if not needed
|
||||
id: testrail
|
||||
# Only export to kiwi when it is demanded or on develop
|
||||
- name: Disable Kiwi if not needed
|
||||
id: kiwi
|
||||
if: |
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
!contains(fromJSON(steps.prdetails.outputs.data).labels.*.name, 'X-Send-Testrail')
|
||||
!contains(fromJSON(steps.prdetails.outputs.data).labels.*.name, 'X-Send-Kiwi')
|
||||
run: echo "::set-output name=value::0"
|
||||
|
||||
- name: Generate unique ID 💎
|
||||
|
@ -222,69 +222,27 @@ jobs:
|
|||
sha: ${{ github.event.workflow_run.head_sha }}
|
||||
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
testrail:
|
||||
name: Report results to testrail
|
||||
kiwi:
|
||||
name: Report results to kiwi
|
||||
needs:
|
||||
- prepare
|
||||
- tests
|
||||
environment: Testrail
|
||||
environment: Kiwi
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ needs.prepare.outputs.testrail_enable }}
|
||||
if: ${{ needs.prepare.outputs.kiwi_enable }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
- name: Download all zip files
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: cypress-junit
|
||||
- name: Prepare testrail upload config
|
||||
id: testrailprep
|
||||
env:
|
||||
TESTRAIL_PROJECT_ID: ${{ secrets.TESTRAIL_PROJECT_ID }}
|
||||
TESTRAIL_SUITE_ID: ${{ secrets.TESTRAIL_SUITE_ID }}
|
||||
TEST_ID: ${{ github.run_id }}
|
||||
TESTRAIL_URL: https://elementqa.testrail.io
|
||||
TESTRAIL_USER: ${{ secrets.TESTRAIL_USER }}
|
||||
TESTRAIL_API_KEY: ${{ secrets.TESTRAIL_API_KEY }}
|
||||
run: |
|
||||
echo '{"name": "element-web cypress '$TEST_ID'", "suite_id": '$TESTRAIL_SUITE_ID' }' > body.json # TODO add description with more context?
|
||||
RUN_ID=`curl -X POST -d @body.json -u "$TESTRAIL_USER:$TESTRAIL_API_KEY" -H "Content-Type: application/json" "$TESTRAIL_URL/index.php?/api/v2/add_run/$TESTRAIL_PROJECT_ID" | jq '.id'`
|
||||
PROJECT_NAME=`curl -X GET -u "$TESTRAIL_USER:$TESTRAIL_API_KEY" -H "Content-Type: application/json" "$TESTRAIL_URL/index.php?/api/v2/get_project/$TESTRAIL_PROJECT_ID" | jq '.name'`
|
||||
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
|
||||
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
||||
- name: setup python
|
||||
uses: actions/setup-python@v4
|
||||
- name: Upload to kiwi
|
||||
uses: vector-im/kiwitcms-upload-action@main
|
||||
with:
|
||||
python-version: "3.11"
|
||||
- run: pip install trcli
|
||||
- name: Upload junit files
|
||||
env:
|
||||
TESTRAIL_PROJECT_ID: ${{ secrets.TESTRAIL_PROJECT_ID }}
|
||||
TESTRAIL_SUITE_ID: ${{ secrets.TESTRAIL_SUITE_ID }}
|
||||
TESTRAIL_URL: https://elementqa.testrail.io
|
||||
TESTRAIL_USER: ${{ secrets.TESTRAIL_USER }}
|
||||
TESTRAIL_API_KEY: ${{ secrets.TESTRAIL_API_KEY }}
|
||||
TESTRAIL_RUN_ID: ${{ steps.testrailprep.outputs.run_id }}
|
||||
run: |
|
||||
for file in results-*.xml; do
|
||||
echo "Handling $file"
|
||||
trcli -y -h $TESTRAIL_URL \
|
||||
--project-id $TESTRAIL_PROJECT_ID \
|
||||
--project ${{ steps.testrailprep.outputs.project_name }} \
|
||||
--username $TESTRAIL_USER \
|
||||
--password $TESTRAIL_API_KEY \
|
||||
parse_junit \
|
||||
--run-id $TESTRAIL_RUN_ID \
|
||||
--suite-id $TESTRAIL_SUITE_ID \
|
||||
--title "if you see this please check cypress build for run id not being provisioned" \
|
||||
-f $file || true
|
||||
# We want to keep uploading what we can; but don't want the failures/red marks when it fails, so we add || true above.
|
||||
done
|
||||
- name: Close test run
|
||||
id: testrailpost
|
||||
if: always()
|
||||
env:
|
||||
TESTRAIL_URL: https://elementqa.testrail.io
|
||||
TESTRAIL_USER: ${{ secrets.TESTRAIL_USER }}
|
||||
TESTRAIL_API_KEY: ${{ secrets.TESTRAIL_API_KEY }}
|
||||
TESTRAIL_RUN_ID: ${{ steps.testrailprep.outputs.run_id }}
|
||||
run: |
|
||||
CLOSE_RESPONSE=`curl -X POST -d '{}' -u "$TESTRAIL_USER:$TESTRAIL_API_KEY" -H "Content-Type: application/json" "$TESTRAIL_URL/index.php?/api/v2/close_run/$TESTRAIL_RUN_ID"`
|
||||
if [ ! "0" == "`echo $CLOSE_RESPONSE | jq .untested_count`" ] ; then echo "::warning title=Missing Tests::Testrail reported some cypress tests were not run. $CLOSE_RESPONSE"; fi
|
||||
file-pattern: results-*.xml
|
||||
kiwi-username: ${{ secrets.TCMS_USERNAME }}
|
||||
kiwi-password: ${{ secrets.TCMS_PASSWORD }}
|
||||
product: "Element Web"
|
||||
product-version: ${{ github.event.workflow_run.head_branch }}
|
||||
build-id: ${{ github.event.workflow_run.head_sha }}
|
||||
suite-name: "Cypress E2E"
|
||||
summary-template: "$name"
|
||||
|
|
Loading…
Reference in New Issue