-
Notifications
You must be signed in to change notification settings - Fork 33
200 lines (190 loc) · 6.85 KB
/
test-pr.yaml
File metadata and controls
200 lines (190 loc) · 6.85 KB
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
name: "CI - Test Templates"
on:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@2.0.0
with:
check_together: 'yes'
env:
SHELLCHECK_OPTS: -e SC1090 -e SC1091
detect-changes:
name: "Detect changes"
runs-on: ubuntu-latest
strategy:
matrix:
common_filters:
-
- '.github/workflows/test-pr.yaml'
- '.github/actions/smoke-test/**'
- 'startupscript/**'
- 'test/**'
config:
- example:
user: jovyan
jupyter-template:
user: jupyter
r-analysis:
user: rstudio
workbench_tools: true
postgres_client: true
r-analysis-aou:
user: rstudio
workbench_tools: true
postgres_client: true
filters:
- 'src/aou-common/**'
vscode:
user: abc
workbench_tools: true
postgres_client: true
vscode-docker:
user: abc
workbench_tools: true
workbench-jupyter:
template: custom-workbench-jupyter-template
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
options:
containerImage: 'us-west2-docker.pkg.dev/shared-pub-buckets-94mvrf/workbench-artifacts/app-workbench-jupyter:ov-dev-stable'
filters:
- 'src/jupyter-common/**'
jupyter-aou:
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
filters:
- 'src/jupyter-common/**'
- 'src/aou-common/**'
nemo_jupyter:
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
nemo_jupyter_aou:
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
filters:
- 'src/aou-common/**'
- 'src/nemo_jupyter/**'
workbench-jupyter-parabricks:
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
workbench-jupyter-parabricks-aou:
user: jupyter
maximize_build_space: true
workbench_tools: true
postgres_client: true
filters:
- 'src/aou-common/**'
- 'src/workbench-jupyter-parabricks/**'
ubuntu-example:
user: vscode
outputs:
apps: ${{ steps.output.outputs.apps }}
steps:
- name: Build filters
id: build-filters
run: |
CONFIG='${{ toJson(matrix.config) }}'
COMMON='${{ toJson(matrix.common_filters) }}'
echo "filters<<EOF" >> $GITHUB_OUTPUT
jq -n \
--argjson config "$CONFIG" \
--argjson common "$COMMON" \
'[$config
| to_entries
| .[]
| .value as $v
| .value = $common
| .value += ["src/" + ($v.template // .key) + "/**"]
| .value += if $v.workbench_tools then ["features/src/workbench-tools/**"] else [] end
| .value += if $v.postgres_client then ["features/src/postgres-client/**"] else [] end
| .value += ($v.filters // [])
] | from_entries' | yq -P >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: json
filters: ${{ steps.build-filters.outputs.filters }}
- name: Output changed templates as JSON object
id: output
run: |
CHANGED_TEMPLATES='${{ steps.filter.outputs.changes }}'
CONFIG='${{ toJson(matrix.config) }}'
# output to github output
echo "apps<<EOF" >> $GITHUB_OUTPUT
jq -n \
--argjson changed "$CHANGED_TEMPLATES" \
--argjson config "$CONFIG" \
'[$changed[] as $t
| $config[$t]
| select(. != null)
| {
template: (.template // $t),
user,
maximize_build_space: (.maximize_build_space // false),
workbench_tools: (.workbench_tools // false),
postgres_client: (.postgres_client // false),
options: (.options // {}),
}
]' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
test:
name: "Smoke test '${{ matrix.app.template }}'"
needs: [detect-changes]
runs-on: ubuntu-latest
continue-on-error: true
if : ${{ needs.detect-changes.outputs.apps != '[]' }}
strategy:
matrix:
app: ${{ fromJSON(needs.detect-changes.outputs.apps) }}
steps:
- uses: actions/checkout@v4
# Free up disk space by removing unnecessary files, if needed
- name: Maximize build disk space
if: ${{ matrix.app.maximize_build_space }}
uses: easimon/maximize-build-space@v10
with:
# This is the amount of space left over, not allocated to the LVM
# volume. We already checked out the repo so we don't need much
root-reserve-mb: 512
build-mount-path: /mnt/build
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
- name: Reconfigure docker and containerd to use new build space
if: ${{ matrix.app.maximize_build_space }}
run: |
sudo mkdir -p /mnt/build/docker
echo '{"data-root": "/mnt/build/docker"}' | sudo tee /etc/docker/daemon.json
sudo mkdir -p /mnt/build/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
sudo sed -i "s|root = '/var/lib/containerd'|root = '/mnt/build/containerd'|" /etc/containerd/config.toml
- name: Restart docker and containerd
if: ${{ matrix.app.maximize_build_space }}
run: |
sudo systemctl restart containerd
sudo systemctl restart docker
- name: Smoke test for '${{ matrix.app.template }}'
id: smoke_test
uses: ./.github/actions/smoke-test
with:
template: "${{ matrix.app.template }}"
user: "${{ matrix.app.user }}"
workbench_tools: "${{ matrix.app.workbench_tools }}"
postgres_client: "${{ matrix.app.postgres_client }}"
options: "${{ toJSON(matrix.app.options) }}"