ABDM E2E Tests #339
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: ABDM E2E Tests | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: "0 1 * * *" # Schedule for DEV.lite Env Runs at 06.30AM IST - 1.00AM UTC | |
workflow_dispatch: | |
inputs: | |
TEST_CONTEXT: | |
description: "Test tags to be executed. eg. clinic, payment, lab, hospital, smoke, regression. Logical operators can be used." | |
required: false | |
default: "clinic & regression" | |
TARGET_ENV: | |
description: "Environment to test" | |
required: true | |
type: choice | |
default: dev.lite | |
options: | |
- dev.lite | |
- qa.lite | |
- lite | |
- demo | |
- demo-v94 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.inputs.TEST_CONTEXT || 'clinic & regression' }}-${{ github.event.inputs.TARGET_ENV || 'dev.lite' }}-${{github.event.schedule}} | |
cancel-in-progress: true | |
env: | |
TEST_CONTEXT: ${{ github.event.inputs.TEST_CONTEXT || 'clinic & regression' }} | |
TARGET_ENV: ${{ github.event.inputs.TARGET_ENV || 'dev.lite' }} | |
ENV_FLAG: false | |
LANGUAGE: en-IN | |
jobs: | |
build-and-run: | |
name: Build and Run E2E tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set environment variables for dev.lite Regression Schedule | |
if: github.event.schedule=='0 1 * * *' | |
run: | | |
echo "TARGET_ENV=dev.lite" >> $GITHUB_ENV | |
echo "TEST_CONTEXT=clinic & regression" >> $GITHUB_ENV | |
- name: Show current Env variables | |
run: | | |
echo "TARGET_ENV - ${{env.TARGET_ENV}} TEST_CONTEXT - ${{env.TEST_CONTEXT}}" | |
- run: echo "Current Concurrency Group - ${{ github.workflow }}-${{ github.event.inputs.TEST_CONTEXT || 'clinic & regression' }}-${{ github.event.inputs.TARGET_ENV || 'dev.lite' }}-${{github.event.schedule}}" | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Wait for environment to be up | |
shell: bash | |
run: bash .github/waitForEnv.sh $TARGET_ENV | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- uses: zcong1993/setup-timezone@v2.0.0 | |
with: | |
timezone: "Asia/Kolkata" | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgbm-dev | |
sudo apt-get install -y xvfb | |
sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf | |
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable | |
sudo apt-get -y install imagemagick x11-apps | |
sudo apt-get update | |
sudo apt-get install -yq \ | |
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ | |
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ | |
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \ | |
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \ | |
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget ffmpeg | |
- run: npm install @getgauge/cli | |
- run: npm install | |
- name: Run Tests | |
id: run_test | |
run: xvfb-run npm run ci -- --env $TARGET_ENV --tags "${{env.TEST_CONTEXT}}" | |
- name: Upload HTML reports | |
if: ${{(success() || failure()) && env.ENV_FLAG}} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: HTML_Reports_${{ GITHUB.RUN_NUMBER }} | |
path: ./reports/html-report | |
- name: Upload Logs | |
if: ${{(success() || failure()) && env.ENV_FLAG}} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Logs_${{ GITHUB.RUN_NUMBER }} | |
path: ./logs/gauge.log | |
- name: Upload Video | |
if: ${{(success() || failure()) && env.ENV_FLAG}} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Videos_${{ GITHUB.RUN_NUMBER }} | |
path: ./reports/video | |
- name: Deploy reports | |
if: ${{(success() || failure()) && env.ENV_FLAG == 'true'}} | |
env: | |
SRC_FOLDER_PATH: "reports/html-report" | |
TARGET_BRANCH: "gh-pages" | |
MAX_DIR: 10 | |
shell: bash | |
run: bash .github/deleteOldReports.sh $MAX_DIR $SRC_FOLDER_PATH $TARGET_BRANCH ${{secrets.BAHMNI_USERNAME}} ${{secrets.BAHMNI_EMAIL}} ${{GITHUB.RUN_ID}} ${{GITHUB.RUN_ATTEMPT}} | |
- name: Get Repository Name | |
if: always() | |
run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV | |
- name: Send Slack Notification if execution Success | |
if: ${{ success() && env.ENV_FLAG == 'true'}} | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"attachments":[{"color": "#32CD32","blocks":[{"type":"header","text":{"type":"plain_text","text":"✅ Bahmni ABDM E2E Tests Passed in ${{env.TARGET_ENV}} for tags ${{env.TEST_CONTEXT}}.","emoji":true}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"🧪 View the detailed HTML report here 👉"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View"},"url":"https://${{github.repository_owner}}.github.io/${{env.REPO_NAME}}/report-${{GITHUB.RUN_ID}}-${{GITHUB.RUN_ATTEMPT}}"}},{"type":"section","text":{"type":"mrkdwn","text":"🧪 View Workflow Run Details 👉"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View"},"url":"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"}},{"type":"section","fields":[{"type":"plain_text","text":"RUN NUMBER - ${{ GITHUB.RUN_NUMBER }}","emoji":true},{"type":"plain_text","text":"RUN ID - ${{ GITHUB.RUN_ID }}","emoji":true}]}]}]}' ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Send Slack Notification if execution Failure | |
if: ${{ failure() && env.ENV_FLAG == 'true'}} | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"attachments":[{"color": "#FF0000","blocks":[{"type":"header","text":{"type":"plain_text","text":"❌ Bahmni ABDM E2E Tests Failed in ${{env.TARGET_ENV}} for tags ${{env.TEST_CONTEXT}}.","emoji":true}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"📌 View the detailed HTML report here 👉"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View"},"url":"https://${{github.repository_owner}}.github.io/${{env.REPO_NAME}}/report-${{GITHUB.RUN_ID}}-${{GITHUB.RUN_ATTEMPT}}"}},{"type":"section","text":{"type":"mrkdwn","text":"📌 View Workflow Run Details 👉"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View"},"url":"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"}},{"type":"section","fields":[{"type":"plain_text","text":"RUN NUMBER - ${{ GITHUB.RUN_NUMBER }}","emoji":true},{"type":"plain_text","text":"RUN ID - ${{ GITHUB.RUN_ID }}","emoji":true}]}]}]}' ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Send Slack Notification if Environment Not available | |
if: ${{(success() || failure()) && env.ENV_FLAG == 'false'}} | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"attachments":[{"color": "#FF8C00","blocks":[{"type":"header","text":{"type":"plain_text","text":"⚠️ Unable to execute Bahmni ABDM E2E Tests in ${{env.TARGET_ENV}}, Environment is down.","emoji":true}},{"type":"divider"},{"type":"section","text":{"type":"mrkdwn","text":"📌 View Workflow Run Details 👉"},"accessory":{"type":"button","text":{"type":"plain_text","text":"View"},"url":"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"}},{"type":"section","fields":[{"type":"plain_text","text":"RUN NUMBER - ${{ GITHUB.RUN_NUMBER }}","emoji":true},{"type":"plain_text","text":"RUN ID - ${{ GITHUB.RUN_ID }}","emoji":true}]}]}]}' ${{ secrets.SLACK_WEBHOOK_URL }} |