Push cypress test results to kiwitcms not testrail (#10401)
This commit is contained in:
parent
a5fcdd7bfd
commit
853b3f822d
1 changed files with 21 additions and 63 deletions
84
.github/workflows/cypress.yaml
vendored
84
.github/workflows/cypress.yaml
vendored
|
@ -25,7 +25,7 @@ jobs:
|
||||||
commit_author: ${{ steps.commit.outputs.author }}
|
commit_author: ${{ steps.commit.outputs.author }}
|
||||||
commit_email: ${{ steps.commit.outputs.email }}
|
commit_email: ${{ steps.commit.outputs.email }}
|
||||||
percy_enable: ${{ steps.percy.outputs.value || '1' }}
|
percy_enable: ${{ steps.percy.outputs.value || '1' }}
|
||||||
testrail_enable: ${{ steps.testrail.outputs.value || '1' }}
|
kiwi_enable: ${{ steps.kiwi.outputs.value || '1' }}
|
||||||
steps:
|
steps:
|
||||||
# We create the status here and then update it to success/failure in the `report` stage
|
# 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.
|
# 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')
|
!contains(fromJSON(steps.prdetails.outputs.data).labels.*.name, 'X-Needs-Percy')
|
||||||
run: echo "::set-output name=value::0"
|
run: echo "::set-output name=value::0"
|
||||||
|
|
||||||
# Only run Testrail when it is demanded or on develop
|
# Only export to kiwi when it is demanded or on develop
|
||||||
- name: Disable Testrail if not needed
|
- name: Disable Kiwi if not needed
|
||||||
id: testrail
|
id: kiwi
|
||||||
if: |
|
if: |
|
||||||
github.event.workflow_run.event == 'pull_request' &&
|
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"
|
run: echo "::set-output name=value::0"
|
||||||
|
|
||||||
- name: Generate unique ID 💎
|
- name: Generate unique ID 💎
|
||||||
|
@ -222,69 +222,27 @@ jobs:
|
||||||
sha: ${{ github.event.workflow_run.head_sha }}
|
sha: ${{ github.event.workflow_run.head_sha }}
|
||||||
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||||
|
|
||||||
testrail:
|
kiwi:
|
||||||
name: Report results to testrail
|
name: Report results to kiwi
|
||||||
needs:
|
needs:
|
||||||
- prepare
|
- prepare
|
||||||
- tests
|
- tests
|
||||||
environment: Testrail
|
environment: Kiwi
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ needs.prepare.outputs.testrail_enable }}
|
if: ${{ needs.prepare.outputs.kiwi_enable }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v3
|
- name: Download all zip files
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: cypress-junit
|
name: cypress-junit
|
||||||
- name: Prepare testrail upload config
|
- name: Upload to kiwi
|
||||||
id: testrailprep
|
uses: vector-im/kiwitcms-upload-action@main
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
file-pattern: results-*.xml
|
||||||
- run: pip install trcli
|
kiwi-username: ${{ secrets.TCMS_USERNAME }}
|
||||||
- name: Upload junit files
|
kiwi-password: ${{ secrets.TCMS_PASSWORD }}
|
||||||
env:
|
product: "Element Web"
|
||||||
TESTRAIL_PROJECT_ID: ${{ secrets.TESTRAIL_PROJECT_ID }}
|
product-version: ${{ github.event.workflow_run.head_branch }}
|
||||||
TESTRAIL_SUITE_ID: ${{ secrets.TESTRAIL_SUITE_ID }}
|
build-id: ${{ github.event.workflow_run.head_sha }}
|
||||||
TESTRAIL_URL: https://elementqa.testrail.io
|
suite-name: "Cypress E2E"
|
||||||
TESTRAIL_USER: ${{ secrets.TESTRAIL_USER }}
|
summary-template: "$name"
|
||||||
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
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue