Skip to content

Run testRigor Smoke Tests #20

Run testRigor Smoke Tests

Run testRigor Smoke Tests #20

# 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 Smoke Tests
on:
workflow_dispatch:
inputs:
environment_code:
description: Aselo environment to test
required: true
type: choice
options:
- staging
default: staging
jobs:
run-smoke-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/smoke_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/smoke_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 Smoke 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,"storedValues":{"storedValueName1":"Value"}}' \
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"
- 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]` Smoke Tests for environment `${{ inputs.environment_code }}` requested by `${{ github.triggering_actor }}` started using workflow `${{ github.workflow }}` :rocket:. \n Test Run: https://app.testrigor.com/test-suites/${{ env.TEST_RIGOR_SUITE_ID }}/runs/${{ env.TASK_ID }}"
env:
SLACK_BOT_TOKEN: ${{ env.GITHUB_ACTIONS_SLACK_BOT_TOKEN }}