forked from photoview/photoview
-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (141 loc) · 4.39 KB
/
tests.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
name: Tests
on:
push:
branches: ['*']
pull_request:
branches: [master]
jobs:
test-api:
name: Test API
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database: ['sqlite', 'mysql', 'postgres']
services:
mariadb:
image: mariadb:lts
env:
MYSQL_DATABASE: photoview_test
MYSQL_USER: photoview
MYSQL_PASSWORD: photosecret
MYSQL_RANDOM_ROOT_PASSWORD: yes
# https://github.com/MariaDB/mariadb-docker/issues/497
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
ports:
- 3306:3306
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: photoview
POSTGRES_PASSWORD: photosecret
POSTGRES_DB: photoview_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repo
uses: actions/checkout@v4
- name: Build test image
uses: docker/build-push-action@v6
with:
pull: true
push: false
load: true
target: api
tags: photoview/api
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test
id: test
run: |
docker run --name test --network host \
-v "${{ github.workspace }}:/app" \
-e PHOTOVIEW_DATABASE_DRIVER=${{ matrix.database }} \
-e PHOTOVIEW_MYSQL_URL='photoview:photosecret@tcp(localhost:3306)/photoview_test' \
-e PHOTOVIEW_POSTGRES_URL='postgres://photoview:photosecret@localhost:5432/photoview_test' \
-e PHOTOVIEW_SQLITE_PATH=/tmp/photoview.db \
photoview/api \
/app/scripts/test_all.sh
docker cp test:/app/api/coverage.txt ./api/
docker cp test:/app/api/test-api-coverage-report.xml ./api/
- name: Upload coverage
uses: codecov/codecov-action@v5
if: ${{ steps.test.conclusion == 'success' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: api-${{ matrix.database }}
- name: Upload test execution results
uses: codecov/test-results-action@v1
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: api-${{ matrix.database }}
files: ./api/test-api-coverage-report.xml
test-ui:
name: Test UI
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repo
uses: actions/checkout@v4
- name: Build test image
uses: docker/build-push-action@v6
with:
pull: true
push: false
load: true
target: ui
tags: photoview/ui
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NODE_ENV=testing
- name: Test
id: test
run: |
docker run --name test photoview/ui npm run test:ci
docker cp test:/app/ui/coverage ./ui/
docker cp test:/app/ui/junit-report.xml ./ui/
- name: Upload coverage
uses: codecov/codecov-action@v5
if: ${{ steps.test.conclusion == 'success' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ui
- name: Upload test execution results
uses: codecov/test-results-action@v1
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ui
directory: ./ui
- name: Run ESLint
working-directory: ui
run: |
docker run --name eslint photoview/ui npm run lint:ci || true
docker cp eslint:/app/ui/eslint-report.txt ./
echo "--------------------------"
echo "ESLint execution results :"
echo "--------------------------"
cat ./eslint-report.txt || echo "ESLint report file not found."
- name: ESLint artifact
id: eslint-artifact
uses: actions/upload-artifact@v4
with:
name: ESLint-report
path: ./ui/eslint-report.txt
if-no-files-found: warn
compression-level: 9
overwrite: true