-
Notifications
You must be signed in to change notification settings - Fork 20
183 lines (166 loc) · 9.05 KB
/
automation-ci.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#TODO:
# - use variables to make somethings dry, like path-names, routes.
# - Caching web and express build dependencies for faster builds.
# - better way to include the fhir-web-automation repo since its private
name: Run automation tests
on:
workflow_dispatch:
inputs:
branch:
required: true
description: The branch to target
jobs:
setup:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
# setup code, directories and system wide dependency
- name: Checkout web
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
path: web
fetch-depth: 1
- name: Checkout express server
uses: actions/checkout@v4
with:
repository: onaio/express-server
path: express
- name: Checkout fhir automation
uses: actions/checkout@v4
with:
repository: onaio/fhir-web-automation
token: ${{ secrets.ACCESS_TOKEN }} # currently using a PAT -> not the best option.
path: fhir-web-automation
ref: p-netm-patch-1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# package, library installation and app configuration.
- name: Provision web envs
run: |
tee -a web/app/.env \n<<EOF
# fhir
SKIP_PREFLIGHT_CHECK=true
GENERATE_SOURCEMAP=false
INLINE_RUNTIME_CHUNK=false
IMAGE_INLINE_SIZE_LIMIT=0
REACT_APP_WEBSITE_NAME=Fhir-web
REACT_APP_BACKEND_ACTIVE=true
REACT_APP_DOMAIN_NAME=http://localhost:3000
REACT_APP_OPENSRP_ACCESS_TOKEN_URL=https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/token
REACT_APP_OPENSRP_AUTHORIZATION_URL=https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/auth
REACT_APP_OPENSRP_OAUTH_STATE=opensrp
REACT_APP_FHIR_API_BASE_URL=https://fhir.labs.smartregister.org/fhir
REACT_APP_OPENSRP_API_V2_BASE_URL=https://opensrp-fhir.labs.smartregister.org/opensrp/rest/
REACT_APP_OPENSRP_USER_URL=https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/userinfo
REACT_APP_OPENSRP_CLIENT_ID=fhir-core-client
REACT_APP_ENABLE_OPENSRP_OAUTH=true
REACT_APP_DISABLE_LOGIN_PROTECTION=false
REACT_APP_KEYCLOAK_API_BASE_URL=https://keycloak-stage.smartregister.org/auth/admin/realms/FHIR_Android
REACT_APP_EXPRESS_OAUTH_LOGOUT_URL=http://localhost:3000/logout
REACT_APP_EXPRESS_OAUTH_GET_STATE_URL=http://localhost:3000/oauth/state
REACT_APP_KEYCLOAK_LOGOUT_URL=https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/logout
REACT_APP_OPENSRP_OAUTH_SCOPES=openid,profile
REACT_APP_ENABLE_FHIR_CARE_TEAM=true
REACT_APP_KEYCLOAK_USERS_PAGE_SIZE=20
REACT_APP_FILTER_BY_PARENT_ID=true
REACT_APP_ENABLE_FHIR_HEALTHCARE=true
REACT_APP_ENABLE_PLANS=true
REACT_APP_ENABLE_LOCATIONS=true
REACT_APP_ENABLE_FHIR_LOCATIONS=true
REACT_APP_ENABLE_CARD_SUPPORT=true
REACT_APP_ENABLE_FHIR_PATIENTS=true
REACT_APP_ENABLE_TEAMS_ASSIGNMENT_MODULE=true
REACT_APP_ENABLE_FORM_CONFIGURATION=true
REACT_APP_ENABLE_FHIR_USER_MANAGEMENT=true
REACT_APP_LANGUAGE_CODE=en
REACT_APP_PROJECT_CODE=core
REACT_APP_FHIR_API_BASE_URL=https://fhir.labs.smartregister.org/fhir
REACT_APP_ENABLE_FHIR_GROUP=false
REACT_APP_ENABLE_FHIR_PRACTITIONER_ROLE=true
REACT_APP_PAGINATION_SIZE=1000
REACT_APP_OPENSRP_WEB_VERSION=$npm_package_version
REACT_APP_DEPLOYMENT_ENVIRONMENT=production
REACT_APP_ENABLE_FHIR_ORGANIZATION=true
REACT_APP_ENABLE_FHIR_TEAMS=true
REACT_APP_FHIR_ROOT_LOCATION_ID=eff94f33-c356-4634-8795-d52340706ba9
REACT_APP_FHIR_INVENTORY_LIST_ID=81b674df-e958-4684-8931-8feefa74d6fb
REACT_APP_FHIR_PATIENT_SORT_FIELDS=-_lastUpdated
REACT_APP_FHIR_PATIENT_BUNDLE_SIZE=5000
REACT_APP_ENABLE_FHIR_HEALTHCARE_SERVICES=false
REACT_APP_ENABLE_FHIR_COMMODITY=true
REACT_APP_ENABLE_QUEST=true
EOF
# cache builds or artifacts, probably cache - TODO
- name: Build Application
run: |
cd web
yarn install --frozen-lockfile
yarn lerna:prepublish
- name: Get absolute path for build files
run: |
echo "REACT_BUILD_FOLDER=$(pwd)/web/app/build" >> $GITHUB_ENV
- name: Build express application
run: |
cd express
yarn install --frozen-lockfile
yarn build
yarn start > /dev/null 2>&1 &
env:
NODE_ENV: development # so that we can insall devDepenencies required for build
EXPRESS_OPENSRP_ACCESS_TOKEN_URL: https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/token
EXPRESS_OPENSRP_AUTHORIZATION_URL: https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/auth
EXPRESS_KEYCLOAK_LOGOUT_URL: https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/logout
EXPRESS_OPENSRP_USER_URL: https://keycloak-stage.smartregister.org/auth/realms/FHIR_Android/protocol/openid-connect/userinfo
EXPRESS_OPENSRP_CLIENT_ID: fhir-core-client
EXPRESS_OPENSRP_CLIENT_SECRET: ${{ secrets.EXPRESS_OPENSRP_CLIENT_SECRET }}
EXPRESS_ALLOW_TOKEN_RENEWAL: true
EXPRESS_REACT_BUILD_PATH: ${{ env.REACT_BUILD_FOLDER }}
EXPRESS_CONTENT_SECURITY_POLICY_CONFIG: "{\"default-src\":[\"'self'\",\"smartregister.org\",\"https://github.com/opensrp/\"],\"connect-src\":[\"'self'\",\"*.smartregister.org\"],\"img-src\":[\"https://github.com/opensrp/\"],\"script-src\":[\"'self'\"]}"
- name: Wait (max 2 mins) for express server to be reachable
run: |
count=0; while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/)" != "200" ]]; do if [[ count -lt 24 ]]; then ((count=count+1)); else exit 1; fi; sleep 5; done
- name: Debug running local instance
run: |
curl http://localhost:3000 -v
# setup automation tests
- name: Update integration test application properties
run: |
sed -i 's/headless = false/headless = true/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
# sed -i 's/LogTestRail = false/LogTestRail = true/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/TestRailusername = <testrail_username>/TestRailusername = '$(echo $TEST_RAIL_USERNAME)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/TestRailpassword = <testrail_password>/TestRailpassword = '$(echo $TEST_RAIL_PASSWORD)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/TestRailurl = <testrail_url>/TestRailurl='$(echo $TEST_RAIL_URL)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/TestRailprojectid = <testrail_project_id>/TestRailprojectid='$(echo $TEST_RAIL_PROJECT_ID)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/baseUrl = http:\/\/fhir-web.opensrp-stage.smartregister.org/baseUrl = http:\/\/localhost:3000/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/dashboardUrl = http:\/\/fhir-web.opensrp-stage.smartregister.org/dashboardUrl = http:\/\/localhost:3000/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/userName = <app_userName>/userName = '$(echo $LOGIN_USERNAME)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
sed -i 's/password = <app_password>/password = '$(echo $LOGIN_PASSWORD)'/g' fhir-web-automation/src/main/resources/ApplicationConfig.properties
env:
TEST_RAIL_USERNAME: ${{ secrets.TEST_RAIL_USERNAME }}
TEST_RAIL_PASSWORD: ${{ secrets.TEST_RAIL_PASSWORD }}
TEST_RAIL_URL: ${{ secrets.TEST_RAIL_URL }}
TEST_RAIL_PROJECT_ID: ${{ secrets.TEST_RAIL_PROJECT_ID }}
LOGIN_USERNAME: ${{ secrets.WEB_TEST_USERNAME }}
LOGIN_PASSWORD: ${{ secrets.WEB_TEST_PASSWORD }}
- name: Debug applicationConfig properties
run: cat fhir-web-automation/src/main/resources/ApplicationConfig.properties
- name: Run integration test
run: |
cd fhir-web-automation
mvn -f ./ clean test
- name: Upload report as artifact
uses: actions/upload-artifact@v3
with:
name: automation-test-report
path: |
fhir-web-automation/reports
fhir-web-automation/screenshots