-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (94 loc) · 3.43 KB
/
build-run-test.yaml
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
name: Build and Run Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
# TODO - Optimize. Build images only once.
# For example, webapp-next is built 3 times now:
# In build job and once for each backend when testing e2e
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
service:
[
backend-rest-go,
backend-rest-js,
webapp-htmx-go,
webapp-nextjs,
e2e-cypress,
bdd-go,
]
steps:
- uses: actions/checkout@v4
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build Docker image
run: |
docker build -t ${{ matrix.service }} ${{ matrix.service }} \
--tag ghcr.io/${{ github.repository_owner }}/kadai/${{ matrix.service }}:${GITHUB_SHA}
- name: Push Docker image
run: |
docker push ghcr.io/${{ github.repository_owner }}/kadai/${{ matrix.service }}:${GITHUB_SHA}
system:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
runner: [bdd-go]
backend: [go, js]
db: [inmemory, mongo]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: KengoTODA/actions-setup-docker-compose@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "${{ secrets.DOT_ENV }}" > .env
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Run Acceptance - API tests
run: |
WEBAPP_IMAGE="" \
BACKEND_IMAGE=ghcr.io/${{ github.repository_owner }}/kadai/backend-rest-${{ matrix.backend }}:${GITHUB_SHA} \
RUNNER_IMAGE=ghcr.io/${{ github.repository_owner }}/kadai/${{ matrix.runner }}:${GITHUB_SHA} \
just ci-${{ matrix.runner }}-${{ matrix.backend }}-${{ matrix.db }}
e2e:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
runner: [cypress]
frontend: [nextjs, htmx-go]
backend: [go, js]
db: [inmemory, mongo]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: KengoTODA/actions-setup-docker-compose@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "${{ secrets.DOT_ENV }}" > .env
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Run E2E tests
run: |
WEBAPP_IMAGE=ghcr.io/${{ github.repository_owner }}/kadai/webapp-${{ matrix.frontend }}:${GITHUB_SHA} \
BACKEND_IMAGE=ghcr.io/${{ github.repository_owner }}/kadai/backend-rest-${{ matrix.backend }}:${GITHUB_SHA} \
RUNNER_IMAGE=ghcr.io/${{ github.repository_owner }}/kadai/e2e-${{ matrix.runner }}:${GITHUB_SHA} \
just ci-${{ matrix.runner }}-${{ matrix.frontend }}-${{ matrix.backend }}-${{ matrix.db }}
- name: Upload test screenshots
uses: actions/[email protected]
with:
name: e2e-screenshots-${{ matrix.e2e_runner }}-${{ matrix.frontend }}-${{ matrix.backend }}-${{ matrix.db }}
path: e2e-cypress/cypress/screenshots