-
-
Notifications
You must be signed in to change notification settings - Fork 1
243 lines (206 loc) · 8.02 KB
/
docker-test.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Docker Test
on:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
push:
branches:
- main
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# pull_request:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: "30 8 * * *" # run at 8:30 AM UTC
jobs:
bats:
name: Bats Testing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run bats
run: docker run -v "$PWD/docker/:/var/www" bats/bats:latest /var/www/tests/bats
hadolint:
name: hadolint
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Pixelfed
uses: hadolint/[email protected]
with:
dockerfile: docker/Dockerfile
config: docker/.hadolint.yaml
failure-threshold: error
pixelfed:
name: pixelfed
runs-on: ubuntu-24.04
strategy:
fail-fast: false
# See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
matrix:
php_version:
- 8.3
- 8.4
pixelfed_branch:
- staging
- dev
debian_release:
- bookworm
php_base:
- apache
- fpm
target_runtime:
- apache
- nginx
# See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#excluding-matrix-configurations
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixexclude
exclude:
# targeting [apache] runtime with [fpm] base type doesn't make sense
- target_runtime: apache
php_base: fpm
# targeting [nginx] runtime with [apache] base type doesn't make sense
- target_runtime: nginx
php_base: apache
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-and-the-default-behavior
concurrency:
group: pixelfed-${{ github.ref }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.target_runtime }}-${{ matrix.pixelfed_branch }}
cancel-in-progress: true
permissions:
contents: read
packages: write
steps:
# checout this repo
- name: Checkout Code
uses: actions/checkout@v4
# checkout pixelfed source code into src/
- name: Checkout pixelfed/pixelfed
uses: actions/checkout@v4
with:
repository: "pixelfed/pixelfed"
ref: "${{ matrix.pixelfed_branch }}"
path: "src/"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
# See: https://github.com/docker/login-action?tab=readme-ov-file#github-container-registry
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: |
name=ghcr.io/${{ github.repository }},enable=true
flavor: |
suffix=-${{ matrix.pixelfed_branch }}-${{ matrix.target_runtime }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
tags: |
# schedule
type=schedule,pattern=nightly
type=schedule,pattern=nightly-{{ date 'YYYY-MM-DD' tz='UTC' }}
# default behavior
type=ref,event=branch,prefix=branch/
type=ref,event=pr,prefix=pr/
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
target: ${{ matrix.target_runtime }}-runtime
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
push: true
provenance: false # https://github.com/docker/build-push-action/issues/894#issuecomment-1785937908
build-args: |
PHP_VERSION=${{ matrix.php_version }}
PHP_BASE_TYPE=${{ matrix.php_base }}
PHP_DEBIAN_RELEASE=${{ matrix.debian_release }}
cache-from: |
type=gha,scope=pixelfed/branch/main/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
type=gha,scope=pixelfed/branch/${{ github.ref_name }}/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
cache-to: |
type=gha,mode=max,ignore-error=true,scope=pixelfed/branch/${{ github.ref_name }}/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
- name: Setup
run: docker/tests/setup.sh
env:
CI: true
DOCKER_APP_TAG: "${{ steps.meta.outputs.version }}"
# goss validate the image
#
# See: https://github.com/goss-org/goss
- uses: e1himself/goss-installation-action@v1
with:
version: "v0.4.9"
- name: Execute Goss tests
working-directory: docker/
run: tests/goss.sh
env:
TAGS: "${{ steps.meta.outputs.tags }}"
DOCKER_APP_PHP_VERSION: ${{ matrix.php_version }}
PHP_BASE_TYPE: ${{ matrix.php_base }}
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: "docker/package-lock.json"
- name: Run E2E tests
run: docker/tests/e2e.sh
env:
CI: true
DOCKER_APP_TAG: "${{ steps.meta.outputs.version }}"
- if: always()
name: Show docker compose config
run: docker compose config
- if: always()
name: Show docker compose logs (web)
run: docker compose logs web
- if: always()
name: Show docker compose logs (worker)
run: docker compose logs worker
- if: always()
name: Show docker compose logs (cron)
run: docker compose logs cron
- if: always()
name: Show docker compose logs (proxy)
run: docker compose logs proxy proxy-acme
- if: always()
name: Show docker compose logs (db)
run: docker compose logs db
- if: always()
name: Show docker compose logs (redis)
run: docker compose logs redis
- if: always()
name: Show docker compose logs (combined)
run: docker compose logs
- if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ matrix.pixelfed_branch }}-${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
path: test-results/
retention-days: 30