forked from medic/cht-core
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (159 loc) · 5.73 KB
/
build.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
name: Build cht-core and test against node versions
on: [push, pull_request]
env:
COUCH_URL: http://admin:pass@localhost:5984/medic-test
COUCH_NODE_NAME: nonode@nohost
BUILDS_SERVER: ${{ secrets.AUTH_MARKET_URL && '_couch/builds_testing' || '_couch/builds_external' }}
STAGING_SERVER: ${{ secrets.AUTH_MARKET_URL && '_couch/builds' || '_couch/builds_external' }}
MARKET_URL_READ: 'https://staging.dev.medicmobile.org'
MARKET_URL: ${{ secrets.AUTH_MARKET_URL || 'https://staging.dev.medicmobile.org' }}
jobs:
build:
name: Compile the app
runs-on: ubuntu-18.04
steps:
- name: Get Docker Hub username
id: get-docker-hub-username
run: echo '::set-output name=dockerhub_username::${{ secrets.DOCKERHUB_USERNAME }}'
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: steps.get-docker-hub-username.outputs.dockerhub_username
- name: Get branch name
uses: nelonoel/branch-name@1ea5c86cb559a8c4e623da7f188496208232e49f
- name: Set CI Vars
run: |
echo "BUILD_NUMBER=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Couch Start
run: ./scripts/ci/couch-start
- name: Create logs directory
run: mkdir tests/logs
- name: npm CI
run: npm ci
- name: Grunt Install
run: npm install -g grunt-cli
- name: Configure Couch
run: ./scripts/ci/couch-config
- name: Grunt CI-Compile
run: |
node --stack_size=10000 `which grunt` ci-compile-github
- name: Publish for testing
run: |
node --stack_size=10000 `which grunt` publish-for-testing
config-tests:
needs: build
name: Config Tests
runs-on: ubuntu-18.04
strategy:
matrix:
grunt-cmd: [ 'exec:test-config-standard', 'exec:test-config-default']
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Grunt Install
run: npm install -g grunt-cli
- name: NPM
run: npm ci
- name: Run Tests
run: node --stack_size=10000 `which grunt` ${{ matrix.grunt-cmd }}
publish:
needs: [tests,config-tests]
name: Publish branch build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Get branch name
uses: nelonoel/branch-name@1ea5c86cb559a8c4e623da7f188496208232e49f
- name: Set CI Vars
run: |
echo "BUILD_NUMBER=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
- name: Publish
if: ${{ github.event_name != 'pull_request' }}
run: |
cd scripts/ci
npm ci
node ./publish.js
tests:
needs: build
name: ${{ matrix.grunt-cmd }} on node ${{ matrix.node-version }}
runs-on: ubuntu-18.04
env:
NODE: ${{ matrix.node-version }}
strategy:
matrix:
node-version: ['8.x', '10.x', '12.x']
grunt-cmd: ['ci-webdriver-default', 'ci-webdriver-standard', 'ci-e2e-integration', 'ci-e2e', 'ci-e2e-mobile', 'ci-e2e-cht']
steps:
- name: Get Docker Hub username
id: get-docker-hub-username
run: echo '::set-output name=dockerhub_username::${{ secrets.DOCKERHUB_USERNAME }}'
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: steps.get-docker-hub-username.outputs.dockerhub_username
- name: Set CI Vars
run: |
echo "BUILD_NUMBER=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "TEST_SUITE=integration" >> $GITHUB_ENV
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: actions/checkout@v2
- name: Create logs directory
run: mkdir tests/logs
- name: Install pyxform
run: python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
- name: Install cht-conf
run: npm install -g cht-conf
- name: npm CI
run: npm ci
- name: Should Install Latest
run: echo "IS_TAG=TRUE" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Horti Setup
run: |
echo "COUCH_URL=$COUCH_URL HORTI_BUILDS_SERVER=$MARKET_URL_READ/$BUILDS_SERVER"
docker-compose -f scripts/ci/horti-compose.yml up -d
sh scripts/wait_for_response_code.sh 5988 200 api
# Restarting horti to install on a different builds server.
# Used for installing the current release then installing the beta.
- name: Install Latest Build After Installing Latest In Previous Startup
run: |
cp tests/logs/horti.log tests/logs/horti_first_run.log
docker stop horti
docker logs horti > tests/logs/horti_before_recreate_container.log 2>&1
INSTALL_LATEST=yes docker-compose -f scripts/ci/horti-compose.yml up -d
sh scripts/wait_for_response_code.sh 5988 200 api
if: startsWith(github.ref, 'refs/tags/')
- name: Test it!
run: node --stack_size=10000 `which grunt` ${{ matrix.grunt-cmd }}
- name: Dump Couch logs
run: |
docker logs couch > tests/logs/couch_container.log 2>&1 &&
docker logs horti > tests/logs/horti_container.log 2>&1
if: ${{ always() }}
- name: Archive Results
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.grunt-cmd }} on node ${{ matrix.node-version }}
path: |
allure-results
allure-report
tests/logs
tests/results/
if: ${{ failure() }}