-
Notifications
You must be signed in to change notification settings - Fork 14
195 lines (190 loc) · 6.64 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
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@v4
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Install virtual environment
run: |
sudo apt-get install libsnappy-dev
poetry install
node-dependencies:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file : ".nvmrc"
- name: Install npm deps
run: npm install
lint:
needs: [python-dependencies, node-dependencies]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Write app version
run: printf "${{ github.event.pull_request.head.sha }}" > .application-version
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Compile translations
run: make translate
- name: Running translation tests
run: poetry run python -m scripts.extract_translation_templates --test
- name: Python linting
run: make lint-python
- name: Install npm deps
run: npm install
- name: Functional tests spec lint
run: ./scripts/lint_functional_test_specs.sh
- name: Javascript linting
run: make lint-js
- name: HTML linting
run: make lint-html
test-unit:
needs: python-dependencies
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- 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 Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Install dotenv plugin
run: poetry self add poetry-plugin-dotenv
- 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: make test-unit
validate-schemas:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Run validator
run: ./scripts/run_validator.sh
- name: Running schema tests
run: make validate-test-schemas
test-functional:
needs: [python-dependencies, node-dependencies]
strategy:
matrix:
suite: [ timeout_modal_expired, timeout_modal_extended, timeout_modal_extended_new_window, features, summaries, general, journeys, components, list_collector]
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
EQ_RUN_FUNCTIONAL_TESTS_HEADLESS: True
# :TODO: Revisit & update when 2 instances can be used without adverse effects
EQ_FUNCTIONAL_TEST_MAX_INSTANCES: 2
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Install npm deps
run: npm install
- name: Docker compose
run: docker compose --version && RUNNER_ENV_FILE=.functional-tests.env docker compose up --build -d
- name: Functional tests
run: make test-functional-suite SUITE=${{ matrix.suite }}
- name: Docker compose shutdown
run: RUNNER_ENV_FILE=.functional-tests.env docker compose kill
docker-push:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
- 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
run: |
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