ci: add nodeSelector and tolerations for dedicated prod env node #1527
Workflow file for this run
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
name: e2e tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
env: | |
DEPLOY_ENVIRONMENT: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy')) }} | |
jobs: | |
e2e: | |
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy')) }} | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 30 | |
steps: | |
- name: Wait for deploy | |
if: ${{ env.DEPLOY_ENVIRONMENT == 'true' }} | |
# Using fork of the upstream https://github.com/lewagon/wait-on-check-action, | |
# see https://github.com/lewagon/wait-on-check-action/issues/85 for more info. | |
uses: t3chguy/wait-on-check-action@master | |
with: | |
ref: ${{ github.head_ref }} | |
check-name: 'call-workflow / build' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
allowed-conclusions: success | |
- name: Construct tests target URL | |
run: | | |
BASE_HOSTNAME="api.im.dhis2.org" | |
if [[ "$DEPLOY_ENVIRONMENT" == 'true' ]]; then | |
# convert to lower case | |
HEAD_BRANCH_LOWERCASE=${GITHUB_HEAD_REF,,} | |
# substitute all non-alphanumeric chars with hyphens "-" | |
HEAD_BRANCH_LOWERCASE_NO_NONALPHANUMERIC=${HEAD_BRANCH_LOWERCASE//[^[:alnum:]]/-} | |
# trim to 25 chars, in order to fit into the 53 char Helm release name limit | |
# the rest of the chars up to the limit are saved for the static part of the release names | |
SANITIZED_HEAD_BRANCH=${HEAD_BRANCH_LOWERCASE_NO_NONALPHANUMERIC::25} | |
echo "TARGET_URL=https://$SANITIZED_HEAD_BRANCH.$BASE_HOSTNAME" >> $GITHUB_ENV | |
else | |
echo "TARGET_URL=https://dev.$BASE_HOSTNAME" >> $GITHUB_ENV | |
fi | |
# Don't set environment variable "API_URL" in this workflow with the action below. | |
# See https://github.com/convictional/trigger-workflow-and-wait/issues/62#issuecomment-1843267732 | |
- name: Trigger E2E Playwright tests | |
uses: convictional/trigger-workflow-and-wait@v1.6.5 | |
with: | |
owner: dhis2-sre | |
repo: im-web-client | |
github_token: ${{ secrets.DHIS2_SRE_BOT_GITHUB_TOKEN }} | |
workflow_file_name: playwright.yml | |
ref: master | |
client_payload: '{"api_url": "${{ env.TARGET_URL }}"}' | |
send-slack-message: | |
runs-on: ubuntu-latest | |
if: always() && contains(needs.*.result, 'failure') && github.ref == 'refs/heads/master' | |
needs: [ e2e ] | |
steps: | |
- uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_CHANNEL: 'team-backend' | |
SLACK_MESSAGE: "Latest test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}" | |
SLACK_COLOR: '#ff0000' |