Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add workflow for updating automated test results in TestRail #11424

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

chrisleewilcox
Copy link
Contributor

@chrisleewilcox chrisleewilcox commented Sep 24, 2024

Description

Adding a workflow to release_e2e_pipeline to post test results to TestRail. This initial implementation will focus on utilizing TestRail API to post test results to TestRail mobile project when all workflows in the bitrise release_e2e_pipeline are successful. Test results will not be posted if any other workflow fails on the release_e2e_pipeline with this implementation.

Automated Test Cases in TestRail will need to be reviewed and updated to ensure the most accurate reporting until we implement mapping of automated scripts to automated test cases in TestRail. Once a mapping mechanism has been implemented this will allow us to report failed test runs in a more effective manner.

Not able to run the pipeline from bitrise dashboard until this PR is merged. Test runs for this PR was done using curl command shared in the bitrise advanced modal for the pipeline.

  • need auth token for bitrise

Related issues

Fixes: https://github.com/MetaMask/mobile-planning/issues/1891

Manual testing steps

  1. on bitrise MetaMask mobile project run release_e2e_pipeline on release branch
  2. all workflows on release_e2e_pipeline are successful
  3. test results from pipeline are posted to TestRail mobile project
  4. Test Run is created in TestRail will all automated test cases status is Passed

Screenshots/Recordings

Before

No workflow to save test results in TestRail

After

Failed pipeline doesn't post test results: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/4047bd66-20a1-405b-bd9d-c3e03942bc5a?tab=workflows

Successful pipeline post test results:
image

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@chrisleewilcox chrisleewilcox requested review from a team as code owners September 24, 2024 22:27
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

scripts/testrail/testrail.api.js Fixed Show resolved Hide resolved
@chrisleewilcox chrisleewilcox changed the title add workflow for updating automated test results in TestRail feat: add workflow for updating automated test results in TestRail Sep 24, 2024
@chrisleewilcox chrisleewilcox marked this pull request as draft September 25, 2024 00:24
@chrisleewilcox

This comment was marked as resolved.

@chrisleewilcox chrisleewilcox marked this pull request as ready for review November 14, 2024 15:49
@chrisleewilcox chrisleewilcox self-assigned this Nov 14, 2024
@chrisleewilcox chrisleewilcox added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Nov 14, 2024
Copy link

sonarcloud bot commented Nov 14, 2024

@chrisleewilcox chrisleewilcox added the No QA Needed Apply this label when your PR does not need any QA effort. label Nov 14, 2024
@@ -46,6 +46,7 @@ pipelines:
stages:
- build_e2e_ios_android_stage: {}
- run_release_e2e_ios_android_stage: {}
- report_results_stage: {}
Copy link
Contributor Author

@chrisleewilcox chrisleewilcox Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stage added for reporting results after build and tests

Comment on lines +175 to +177
report_results_stage:
workflows:
- run_testrail_update_automated_test_results: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added workflow for posting automated test results.

Comment on lines +515 to +526
### Report automated test results to TestRail
run_testrail_update_automated_test_results:
before_run:
- code_setup
steps:
- script@1:
title: 'Add Automated Test Results to TestRail'
inputs:
- content: |-
#!/usr/bin/env bash
echo 'REPORT AUTOMATED TEST RESULTS TO TESTRAIL'
node ./scripts/testrail/testrail.api.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is chaining a few request in order to properly retrieve all automated test cases and record their test status.

Comment on lines +16 to +27
.get(automatedTestCasesEndpoint)
.then((response) => {
const automatedcaseids = response.data.cases.map(
(automatedcase) => automatedcase.id,
);
console.log(`test case id count: ${automatedcaseids.length}`);
return axios.post(addTestRun, {
name: 'Automated Test Run on bitrise release_e2e_pipline',
description: 'Automated test run on release branch',
include_all: false,
case_ids: automatedcaseids,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get all the automated test cases in TestRail mobile project.
Then create a Test Run with all the automated test cases assigned to the test run.

Comment on lines +29 to +32
.then((response) => {
runID = response.data.id;
return axios.get(`${getAutomatedTestRun}${runID}`);
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the runID of the test run just created to be used for updating test results.

Comment on lines +33 to +42
.then((response) => {
const automatedResults = response.data.tests.map((test) => ({
test_id: test.id,
status_id: 1,
comment: 'Passed on bitrise',
}));
return axios.post(`${addResults}${runID}`, {
results: automatedResults,
});
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update test results for the automated test cases using the runID.
Default the results to Pass since this script is only run when all test pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) No QA Needed Apply this label when your PR does not need any QA effort. team-mobile-platform
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

2 participants