-
Notifications
You must be signed in to change notification settings - Fork 11
129 lines (129 loc) · 8.09 KB
/
BahmniLite_E2E_Test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Bahmni Lite E2E Tests
on:
push:
branches:
- main
schedule:
- cron: "0 1 * * *" # Schedule fpr DEV.lite Env Runs at 06.30AM IST - 1.00AM UTC
repository_dispatch:
types: [Smoke-Test-Dev-Lite]
workflow_dispatch:
inputs:
TEST_CONTEXT:
description: "Test tags to be executed. eg. clinic, payment, lab, 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
- dev-lite
- demo-lite
TARGET_BRANCH:
description: "Branch to checkout"
required: true
type: choice
default: main
options:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.context || 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.client_payload.context || github.event.inputs.TEST_CONTEXT || 'clinic & regression' }}
TARGET_ENV: ${{ github.event.inputs.TARGET_ENV || 'dev.lite' }}
ENV_FLAG: false
TARGET_BRANCH: ${{ github.event.inputs.TARGET_BRANCH || 'main'}}
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
echo "TARGET_BRANCH=main" >> $GITHUB_ENV
- name: Show current Env variables
run: |
echo "TARGET_ENV - ${{env.TARGET_ENV}} TEST_CONTEXT - ${{env.TEST_CONTEXT}} TARGET_BRANCH - ${{env.TARGET_BRANCH}}"
- run: echo "Current Concurrency Group - ${{ github.workflow }}-${{ github.event.client_payload.context || github.event.inputs.TEST_CONTEXT || 'clinic & regression' }}-${{ github.event.inputs.TARGET_ENV || 'dev.lite' }}-${{github.event.schedule}}"
- uses: actions/checkout@v2
with:
ref: ${{env.TARGET_BRANCH}}
submodules: recursive
- name: Wait for environment to be up
shell: bash
run: bash .github/waitForEnv.sh $TARGET_ENV
- uses: actions/setup-node@v2
with:
node-version: "16"
cache: "npm"
- uses: zcong1993/[email protected]
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 API Tests
id: run_api_test
run: xvfb-run npm run ci -- --env $TARGET_ENV --tags 'api'
- name: Run Tests
id: run_test
run: xvfb-run -a npm run ci -- --env $TARGET_ENV --tags "${{env.TEST_CONTEXT}}"
- name: Upload HTML reports
if: ${{(success() || failure()) && env.ENV_FLAG}}
uses: actions/upload-artifact@v2
with:
name: HTML_Reports_${{ GITHUB.RUN_NUMBER }}
path: ./reports/html-report
- name: Upload Logs
if: ${{(success() || failure()) && env.ENV_FLAG}}
uses: actions/upload-artifact@v2
with:
name: Logs_${{ GITHUB.RUN_NUMBER }}
path: ./logs/gauge.log
- 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 Lite 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 Lite 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 Lite 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 }}