-
Notifications
You must be signed in to change notification settings - Fork 14
205 lines (200 loc) · 7.33 KB
/
pull_request.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: PR
on:
pull_request:
branches:
- "main"
- "branch-v*"
- "bug-fix-*"
- "feature-*"
concurrency:
group: '${{ github.head_ref }}'
cancel-in-progress: true
jobs:
python-dependencies:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
- name: Install Pipenv
run: pip install pipenv==2023.8.22
- name: Install virtual environment
run: |
sudo apt-get install libsnappy-dev
pipenv install --dev
node-dependencies:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.14.0"
- name: Get yarn cache
id: get-yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn modules
id: cache-yarn
uses: actions/cache@v3
with:
path: ${{ steps.get-yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Install yarn deps
if: steps.cache-yarn.outputs.cache-hit != 'true'
run: yarn
lint:
needs: [python-dependencies, node-dependencies]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
- uses: actions/setup-node@v3
with:
node-version: "18.14.0"
- name: Write app version
run: printf "${{ github.event.pull_request.head.sha }}" > .application-version
- name: Install pipenv
run: pip install pipenv==2023.8.22
- name: Install virtual environment
run: pipenv install --dev
- name: Compile translations
run: make translate
- name: Running translation tests
run: pipenv run python -m scripts.extract_translation_templates --test
- name: Python linting
run: pipenv run ./scripts/run_lint_python.sh
- name: Get yarn cache
id: get-yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn modules
uses: actions/cache@v3
id: cache-yarn
with:
path: ${{ steps.get-yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Install yarn deps
run: yarn install
- name: Functional tests spec lint
run: ./scripts/lint_functional_test_specs.sh
- name: Javascript linting
run: yarn lint
test-unit:
needs: python-dependencies
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
- name: Install apt dependencies
run: |
sudo apt-get install libsnappy-dev libgconf-2-4 jq
# Install wkthtmltopdf with patched Qt
sudo apt-get install -y xfonts-base xfonts-75dpi
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6-1.bionic_amd64.deb
- name: Write app version
run: printf "${{ github.event.pull_request.head.sha }}" > .application-version
- name: Install pipenv
run: pip install pipenv==2023.8.22
- name: Install virtual environment
run: pipenv install --dev
- name: Load templates
run: make load-design-system-templates
- name: Compile translations
run: make translate
- name: Link env vars
run: ln -sf .development.env .env
- name: Running unit tests
run: pipenv run ./scripts/run_tests_unit.sh
validate-schemas:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Run validator
run: ./scripts/run_validator.sh
- name: Running schema tests
run: ./scripts/validate_test_schemas.sh
test-functional:
needs: [python-dependencies, node-dependencies]
strategy:
matrix:
suite: [ timeout_modal_expired, timeout_modal_extended, timeout_modal_extended_new_window, features, general, components ]
runs-on: ubuntu-22.04
env:
EQ_RUN_FUNCTIONAL_TESTS_HEADLESS: True
# :TODO: Revisit & update when 2 instances can be used without adverse effects
EQ_FUNCTIONAL_TEST_MAX_INSTANCES: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.14.0"
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
- name: Install pipenv
run: pip install pipenv==2023.8.22
- name: Install virtual environment
run: pipenv install --dev
- name: Get yarn cache
id: get-yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn modules
uses: actions/cache@v3
id: cache-yarn
with:
path: ${{ steps.get-yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Install yarn deps
run: yarn install
- name: Docker compose
run: docker-compose --version && RUNNER_ENV_FILE=.functional-tests.env docker-compose up --build -d
- name: Functional tests
run: ./scripts/run_tests_functional.sh ${{ matrix.suite }}
- name: Docker compose shutdown
run: RUNNER_ENV_FILE=.functional-tests.env docker-compose kill
docker-push:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set Tag and SHA
run: |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -)
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV
echo "SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Write app version
run: |
echo "Writing SHA $SHA to .application_version"
printf $SHA > .application-version
- name: Build
run: >
docker build -t onsdigital/eq-questionnaire-runner:$TAG
-t ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-runner:$TAG .
- name: Push to Docker Hub
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
echo "Pushing to DockerHub with tag $TAG"
docker push onsdigital/eq-questionnaire-runner:$TAG
- name: Push to GAR
env:
GAR_SERVICE_KEY: ${{ secrets.GAR_SERVICE_KEY }}
run: |
echo $GAR_SERVICE_KEY | docker login -u _json_key --password-stdin https://${{ secrets.GAR_LOCATION }}
gcloud auth configure-docker ${{ secrets.GAR_LOCATION }}
echo "Pushing to GAR with tag $TAG"
docker push ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-runner:$TAG