Run testRigor Regression Tests #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2021-2023 Technology Matters | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published | |
# by the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see https://www.gnu.org/licenses/. | |
name: Run testRigor Regression Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
environment_code: | |
description: Aselo environment to test | |
required: true | |
type: choice | |
options: | |
- staging | |
default: staging | |
section: | |
description: Section or feature to test | |
required: true | |
type: choice | |
options: | |
- all | |
- online-contact-webchat | |
- offline-contact | |
- yellow-banner | |
- general-search | |
- case-list | |
- teams | |
- client-profiles | |
default: all | |
jobs: | |
run-regression-tests-suite: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Helpline Environment | |
run: echo "ENVIRONMENT_NAME=${{inputs.environment_code}}" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Set Test Rigor Suite ID | |
uses: "marvinpinto/action-inject-ssm-secrets@latest" | |
with: | |
ssm_parameter: "/${{env.ENVIRONMENT_NAME}}/test_rigor/regression_tests/test_suite_id" | |
env_variable_name: "TEST_RIGOR_SUITE_ID" | |
- name: Set Test Rigor Auth Token | |
uses: "marvinpinto/action-inject-ssm-secrets@latest" | |
with: | |
ssm_parameter: "/${{env.ENVIRONMENT_NAME}}/test_rigor/regression_tests/auth_token" | |
env_variable_name: "TEST_RIGOR_AUTH_TOKEN" | |
- name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN | |
uses: "marvinpinto/action-inject-ssm-secrets@latest" | |
with: | |
ssm_parameter: "GITHUB_ACTIONS_SLACK_BOT_TOKEN" | |
env_variable_name: "GITHUB_ACTIONS_SLACK_BOT_TOKEN" | |
- name: Set ASELO_DEPLOYS_CHANNEL_ID | |
uses: "marvinpinto/action-inject-ssm-secrets@latest" | |
with: | |
ssm_parameter: "ASELO_DEPLOYS_CHANNEL_ID" | |
env_variable_name: "ASELO_DEPLOYS_CHANNEL_ID" | |
- name: Run Test Rigor Regression Tests | |
shell: bash | |
run: | | |
task_response=$( curl -X POST \ | |
-H 'Content-type: application/json' \ | |
-H 'auth-token: ${{env.TEST_RIGOR_AUTH_TOKEN}}' \ | |
--data '{"forceCancelPreviousTesting":true,"labels": [ "${{inputs.section}}"]}' \ | |
https://api.testrigor.com/api/v1/apps/${{env.TEST_RIGOR_SUITE_ID}}/retest) | |
task_id=$(echo "$task_response" | jq -r '.taskId') | |
# Check if task_id is defined | |
if [[ -z "$task_id" || "$task_id" == "null" ]]; then | |
echo "Failed to start the test. Task response: $task_response" | |
exit 1 | |
fi | |
# Set task_id as an environment variable for the next steps | |
echo "TASK_ID=$task_id" >> $GITHUB_ENV | |
echo "Test started with taskId: $task_id" | |
sleep 10 | |
while true | |
do | |
echo " " | |
echo "===================================" | |
echo " Checking TestRigor retest" | |
echo "===================================" | |
response=$(curl -i -o - -s -X GET 'https://api.testrigor.com/api/v1/apps/${{env.TEST_RIGOR_SUITE_ID}}/status?labels=${{inputs.section}}' -H 'auth-token: ${{env.TEST_RIGOR_AUTH_TOKEN}}' -H 'Accept: application/json') | |
code=$(echo "$response" | grep HTTP | awk '{print $2}') | |
body=$(echo "$response" | sed -n '/{/,/}/p') | |
echo "Status code: " $code | |
echo "Response: " $body | |
case $code in | |
4*|5*) | |
# 400 or 500 errors | |
echo "Error calling API" | |
exit 1 | |
;; | |
200) | |
# 200: successfully finished | |
echo "Test finished successfully" | |
exit 0 | |
;; | |
227|228) | |
# 227: New - 228: In progress | |
echo "Test is not finished yet" | |
;; | |
230) | |
# 230: Failed | |
echo "Test finished but failed" | |
exit 1 | |
;; | |
*) | |
echo "Unknown status" | |
exit 1 | |
esac | |
sleep 10 | |
done | |
- name: Slack Aselo channel | |
id: slack | |
uses: slackapi/slack-github-action@v1.14.0 | |
with: | |
channel-id: ${{ env.ASELO_DEPLOYS_CHANNEL_ID }} | |
slack-message: "`[testRigor]` Regression Tests (${{ inputs.section }}) for environment `${{ inputs.environment_code }}` of ${{ github.ref_type }} `${{ github.ref_name }}` requested by `${{ github.triggering_actor }}` completed using workflow `${{ github.workflow }}` with SHA ${{ github.sha }} :rocket:. \n Test Results: (https://app.testrigor.com/${{ env.TEST_RIGOR_SUITE_ID }}/runs/${{ env.TASK_ID }})" | |
env: | |
SLACK_BOT_TOKEN: ${{ env.GITHUB_ACTIONS_SLACK_BOT_TOKEN }} |