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

Merged
merged 26 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a9243c
add workflow for updating automated test results in TestRail
chrisleewilcox Sep 24, 2024
5c7d1b6
indent title and run
chrisleewilcox Sep 24, 2024
8acb17c
use after_run
chrisleewilcox Sep 26, 2024
f4b0506
add script after step
chrisleewilcox Sep 26, 2024
acef848
add run_testrail_update_automated_test_results workflow to release_e2…
chrisleewilcox Oct 3, 2024
dee21d9
remove token
chrisleewilcox Oct 3, 2024
ff77ef2
add and use env var for auth token
chrisleewilcox Oct 3, 2024
be741b2
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Oct 3, 2024
7ab97c0
remove before_run
chrisleewilcox Oct 3, 2024
f5bb724
load env
chrisleewilcox Oct 4, 2024
346e7a0
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Oct 30, 2024
ed500a6
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 1, 2024
8dc032b
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 8, 2024
f391ba0
Bump version number to 1491
metamaskbot Nov 8, 2024
f5091e4
Bump version number to 1492
metamaskbot Nov 8, 2024
6e06775
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 12, 2024
aeb278f
add new report stage
chrisleewilcox Nov 12, 2024
9f79d16
Revert "Bump version number to 1492"
chrisleewilcox Nov 13, 2024
731175d
Revert "Bump version number to 1491"
chrisleewilcox Nov 13, 2024
9447d71
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 13, 2024
823557f
update descriptions
chrisleewilcox Nov 13, 2024
850b698
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 14, 2024
5f7e5e8
use dot notation for auth
chrisleewilcox Nov 14, 2024
cc44f5e
disable workflows
chrisleewilcox Nov 25, 2024
55355b8
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 26, 2024
e938c2e
Merge branch 'main' into testrail/add-test-run-with-results
chrisleewilcox Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pipelines:
stages:
- build_e2e_ios_android_stage: {}
- run_release_e2e_ios_android_stage: {}
- report_results_stage: {}
- notify: {}
#PR_e2e_verfication (build ios & android), run iOS (smoke), emulator Android
pr_smoke_e2e_pipeline:
Expand Down Expand Up @@ -161,16 +162,19 @@ stages:
- run_tag_smoke_confirmations_android: {}
- run_tag_smoke_accounts_ios: {}
- run_tag_smoke_accounts_android: {}
- run_tag_smoke_notifications_ios: {}
- run_tag_smoke_notifications_android: {}
- run_tag_smoke_assets_ios: {}
# - run_tag_smoke_notifications_ios: {}
# - run_tag_smoke_notifications_android: {}
# - run_tag_smoke_assets_ios: {}
- run_tag_smoke_assets_android: {}
- run_tag_smoke_swaps_ios: {}
- run_tag_smoke_swaps_android: {}
# - run_tag_smoke_swaps_ios: {}
# - run_tag_smoke_swaps_android: {}
- run_tag_smoke_core_ios: {}
- run_tag_smoke_core_android: {}
- run_tag_upgrade_android: {}
- run_android_app_launch_times_appium_test: {}
report_results_stage:
workflows:
- run_testrail_update_automated_test_results: {}
run_e2e_ios_android_stage:
workflows:
- ios_e2e_test: {}
Expand Down Expand Up @@ -508,7 +512,18 @@ workflows:
machine_type_id: elite-xl
after_run:
- wdio_android_e2e_test

### 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
### Separating workflows so they run concurrently during smoke runs
run_tag_smoke_accounts_ios:
envs:
Expand Down
45 changes: 45 additions & 0 deletions scripts/testrail/testrail.api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const axios = require('axios');
require('dotenv').config({ path: './.js.env' });

const TESTRAIL_MM_API_URL = 'https://mmig.testrail.io/index.php?/api/v2';
const TESTRAIL_PROJECT_ID = 4;
const AUTH_TOKEN = process.env.TESTRAIL_AUTH_TOKEN;
const automatedTestCasesEndpoint = `${TESTRAIL_MM_API_URL}/get_cases/${TESTRAIL_PROJECT_ID}&refs=@automated`;
const addTestRun = `${TESTRAIL_MM_API_URL}/add_run/${TESTRAIL_PROJECT_ID}`;
const getAutomatedTestRun = `${TESTRAIL_MM_API_URL}/get_tests/`;
const addResults = `${TESTRAIL_MM_API_URL}/add_results/`;

axios.defaults.headers.common.Authorization = `Basic ${AUTH_TOKEN}`;
let runID;

axios
.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,
});
})
.then((response) => {
runID = response.data.id;
return axios.get(`${getAutomatedTestRun}${runID}`);
})
.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,
});
})
.catch((error) => {
console.error(`Error retrieving automated test cases: ${error}`);
});