Skip to content

Commit b78c5df

Browse files
authored
Update site template (#13)
1 parent a0418d5 commit b78c5df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2800
-1123
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ root = true
55
[*]
66
charset = utf-8
77
end_of_line = lf
8+
trim_trailing_whitespace = true
89
insert_final_newline = true
910
indent_style = tab
1011
indent_size = 4
1112

1213
# Markdown
1314
[*.{md,markdown}]
15+
trim_trailing_whitespace = false
1416
indent_style = space
1517
indent_size = 2
1618

.env

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
COMPOSE_PROJECT_NAME='fluffevent-files-website'
22
IMAGES_PREFIX='fluffevent-files-website'
33

4-
# Override these values with your own in `.env.local`:
4+
# -- Override the values below with your own in `.env.local`.
5+
# -- Leave values empty to use defaults.
56

6-
# HTTP ports
7-
HTTP_PORT='' # Exposed port
8-
HTTP_DOCKER_PORT='' # Container port
7+
# Docker ports
8+
# (host ports: "*_PORT"; container ports: "*_DOCKER_PORT")
9+
HTTP_PORT=''
10+
HTTP_DOCKER_PORT=''
911

10-
# Application configuration
12+
# Deployment
1113
GITHUB_REPOSITORY_URL=''
1214
GITHUB_SHA=''
15+
VERSION_TAG=''
16+
17+
# Astro
18+
ASTRO_SITE_URL=''
19+
ASTRO_BASE_PATH=''
20+
ASTRO_ASSETS_PREFIX=''
21+
22+
# Application
23+
# (Add env vars for your application here.)

.env.cli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COMPOSE_PROJECT_NAME='fluffevent-files-website-cli'

.github/workflows/check.yml

Lines changed: 257 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
name: Check CI
22

3+
# GitHub variables:
4+
# - VERSION_TAG
5+
# - ASTRO_SITE_URL
6+
# - ASTRO_BASE_PATH
7+
# - ASTRO_ASSETS_PREFIX
8+
9+
# GitHub secrets: N/A
10+
311
on:
412

513
# Run on pull requests to primary branches
614
pull_request:
715
branches:
816
# Production
917
- main
18+
# Staging
19+
- staging
1020
# Development
1121
- dev
1222
paths:
13-
# CI files
23+
# CI/CD files
1424
- '.github/workflows/check.yml'
1525
- 'docker-compose.yml'
1626
- 'docker-compose.cicd.yml'
27+
- 'docker-compose.test-unit.yml'
28+
- 'docker-compose.test-e2e.yml'
1729
- '.env'
1830
# Application files
1931
- 'app/**'
2032

2133
# Run on manual triggers
2234
workflow_dispatch:
2335

24-
# Set GITHUB_TOKEN permissions for the workflow
36+
# Set default GITHUB_TOKEN permissions for the workflow
2537
permissions:
2638
contents: read
2739

@@ -36,14 +48,14 @@ jobs:
3648
build:
3749
name: Build
3850
runs-on: ubuntu-latest
39-
timeout-minutes: 15
51+
timeout-minutes: 20
4052

4153
steps:
4254

43-
# Steps dependencies
55+
# Dependency steps
4456

4557
- name: Checkout
46-
uses: actions/checkout@v4
58+
uses: actions/checkout@v5
4759

4860
# Execution steps
4961

@@ -62,16 +74,27 @@ jobs:
6274
6375
- name: Build for production
6476
env:
77+
# Build
78+
BUILD_CHECK: 'true' # Run type checks
79+
# Deployment
6580
GITHUB_REPOSITORY_URL: https://github.com/${{ github.repository }}
6681
GITHUB_SHA: ${{ github.sha }}
67-
BUILD_CHECK: "true" # Run type checks
82+
VERSION_TAG: ${{ vars.VERSION_TAG }}
83+
# Astro
84+
ASTRO_SITE_URL: ${{ vars.ASTRO_SITE_URL }}
85+
ASTRO_BASE_PATH: ${{ vars.ASTRO_BASE_PATH }}
86+
ASTRO_ASSETS_PREFIX: ${{ vars.ASTRO_ASSETS_PREFIX }}
87+
# Application
88+
# (Add env vars for your application here.)
6889
run: |
6990
# docker compose build
91+
echo '::group::Build details'
7092
export DOCKER_UID="$(id -u)"
7193
docker compose \
7294
-f ./docker-compose.yml -f ./docker-compose.cicd.yml \
7395
--env-file .env \
7496
build
97+
echo '::endgroup::'
7598
7699
- name: Copy application files
77100
run: |
@@ -86,5 +109,231 @@ jobs:
86109
run: |
87110
# Check application files
88111
[ -d ./app/dist ] && [ $(ls -1 ./app/dist | wc -l) -gt 0 ] \
89-
&& echo "Application files found" \
90-
|| ( echo "No application files found" && exit 1 )
112+
&& echo 'Application files found' \
113+
|| ( echo 'No application files found' && exit 1 )
114+
115+
# Test Unit job
116+
test-unit:
117+
name: Test Unit
118+
runs-on: ubuntu-latest
119+
timeout-minutes: 20
120+
121+
steps:
122+
123+
# Dependency steps
124+
125+
- name: Checkout
126+
uses: actions/checkout@v5
127+
128+
# Execution steps
129+
130+
- name: Pull dependencies
131+
run: |
132+
# docker compose pull --ignore-buildable
133+
docker compose \
134+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
135+
--env-file .env \
136+
pull --ignore-buildable
137+
138+
- name: Build for unit tests
139+
env:
140+
# Deployment
141+
GITHUB_REPOSITORY_URL: https://github.com/${{ github.repository }}
142+
GITHUB_SHA: ${{ github.sha }}
143+
VERSION_TAG: ${{ vars.VERSION_TAG }}
144+
# Astro
145+
ASTRO_SITE_URL: ${{ vars.ASTRO_SITE_URL }}
146+
ASTRO_BASE_PATH: ${{ vars.ASTRO_BASE_PATH }}
147+
ASTRO_ASSETS_PREFIX: ${{ vars.ASTRO_ASSETS_PREFIX }}
148+
# Application
149+
# (Add env vars for your application here.)
150+
run: |
151+
# docker compose build
152+
echo '::group::Build details'
153+
export DOCKER_UID="$(id -u)"
154+
docker compose \
155+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
156+
--env-file .env \
157+
build
158+
echo '::endgroup::'
159+
160+
- name: Start unit tests
161+
run: |
162+
# docker compose up
163+
export DOCKER_UID="$(id -u)"
164+
docker compose \
165+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
166+
--env-file .env \
167+
up -d
168+
169+
- name: List unit tests services
170+
run: |
171+
# Set DOCKER_SERVICES environment variable
172+
DOCKER_SERVICES="$(
173+
docker compose \
174+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
175+
--env-file .env \
176+
config --services
177+
)"
178+
echo "Set DOCKER_SERVICES to '${DOCKER_SERVICES}'"
179+
echo 'DOCKER_SERVICES<<GITHUB_ENV_EOF' >> $GITHUB_ENV
180+
echo "${DOCKER_SERVICES}" >> $GITHUB_ENV
181+
echo 'GITHUB_ENV_EOF' >> $GITHUB_ENV
182+
183+
- name: Wait for unit tests to finish
184+
env:
185+
DOCKER_SERVICES: ${{ env.DOCKER_SERVICES }}
186+
run: |
187+
# docker compose wait
188+
docker compose \
189+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
190+
--env-file .env \
191+
wait $DOCKER_SERVICES \
192+
|| exit 0
193+
194+
- name: Print unit tests logs
195+
env:
196+
DOCKER_SERVICES: ${{ env.DOCKER_SERVICES }}
197+
run: |
198+
# docker compose logs
199+
for SERVICE in $DOCKER_SERVICES; do
200+
echo "::group::Docker logs for service '${SERVICE}'"
201+
docker compose \
202+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
203+
--env-file .env \
204+
logs --no-log-prefix $SERVICE
205+
echo '::endgroup::'
206+
done
207+
208+
# Check services exit codes
209+
echo '::group::Check services exit codes'
210+
docker compose \
211+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
212+
--env-file .env \
213+
ps -a
214+
NON_ZERO_EXIT_CODES=$(
215+
docker compose \
216+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
217+
--env-file .env \
218+
ps -a --format '{{.ExitCode}}' \
219+
| grep -v '^0$' \
220+
|| true
221+
)
222+
if [ -n "${NON_ZERO_EXIT_CODES}" ]; then
223+
# Non-zero exit code found
224+
exit 1
225+
fi
226+
echo '::endgroup::'
227+
228+
# Test E2E job
229+
test-e2e:
230+
name: Test E2E
231+
runs-on: ubuntu-latest
232+
timeout-minutes: 20
233+
234+
steps:
235+
236+
# Dependency steps
237+
238+
- name: Checkout
239+
uses: actions/checkout@v5
240+
241+
# Execution steps
242+
243+
- name: Pull dependencies
244+
run: |
245+
# docker compose pull --ignore-buildable
246+
docker compose \
247+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
248+
--env-file .env \
249+
pull --ignore-buildable
250+
251+
- name: Build for E2E tests
252+
env:
253+
# Deployment
254+
GITHUB_REPOSITORY_URL: https://github.com/${{ github.repository }}
255+
GITHUB_SHA: ${{ github.sha }}
256+
VERSION_TAG: ${{ vars.VERSION_TAG }}
257+
# Astro
258+
ASTRO_SITE_URL: ${{ vars.ASTRO_SITE_URL }}
259+
ASTRO_BASE_PATH: ${{ vars.ASTRO_BASE_PATH }}
260+
ASTRO_ASSETS_PREFIX: ${{ vars.ASTRO_ASSETS_PREFIX }}
261+
# Application
262+
# (Add env vars for your application here.)
263+
run: |
264+
# docker compose build
265+
echo '::group::Build details'
266+
export DOCKER_UID="$(id -u)"
267+
docker compose \
268+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
269+
--env-file .env \
270+
build
271+
echo '::endgroup::'
272+
273+
- name: Start E2E tests
274+
run: |
275+
# docker compose up
276+
export DOCKER_UID="$(id -u)"
277+
docker compose \
278+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
279+
--env-file .env \
280+
up -d
281+
282+
- name: List E2E tests services
283+
run: |
284+
# Set DOCKER_SERVICES environment variable
285+
DOCKER_SERVICES="$(
286+
docker compose \
287+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
288+
--env-file .env \
289+
config --services
290+
)"
291+
echo "Set DOCKER_SERVICES to '${DOCKER_SERVICES}'"
292+
echo 'DOCKER_SERVICES<<GITHUB_ENV_EOF' >> $GITHUB_ENV
293+
echo "${DOCKER_SERVICES}" >> $GITHUB_ENV
294+
echo 'GITHUB_ENV_EOF' >> $GITHUB_ENV
295+
296+
- name: Wait for E2E tests to finish
297+
env:
298+
DOCKER_SERVICES: ${{ env.DOCKER_SERVICES }}
299+
run: |
300+
# docker compose wait
301+
docker compose \
302+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
303+
--env-file .env \
304+
wait $DOCKER_SERVICES \
305+
|| exit 0
306+
307+
- name: Print E2E tests logs
308+
env:
309+
DOCKER_SERVICES: ${{ env.DOCKER_SERVICES }}
310+
run: |
311+
# docker compose logs
312+
for SERVICE in $DOCKER_SERVICES; do
313+
echo "::group::Docker logs for service '${SERVICE}'"
314+
docker compose \
315+
-f ./docker-compose.yml -f ./docker-compose.test-e2e.yml \
316+
--env-file .env \
317+
logs --no-log-prefix $SERVICE
318+
echo '::endgroup::'
319+
done
320+
321+
# Check services exit codes
322+
echo '::group::Check services exit codes'
323+
docker compose \
324+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
325+
--env-file .env \
326+
ps -a
327+
NON_ZERO_EXIT_CODES=$(
328+
docker compose \
329+
-f ./docker-compose.yml -f ./docker-compose.test-unit.yml \
330+
--env-file .env \
331+
ps -a --format '{{.ExitCode}}' \
332+
| grep -v '^0$' \
333+
|| true
334+
)
335+
if [ -n "${NON_ZERO_EXIT_CODES}" ]; then
336+
# Non-zero exit code found
337+
exit 1
338+
fi
339+
echo '::endgroup::'

0 commit comments

Comments
 (0)