forked from photoview/photoview
-
Notifications
You must be signed in to change notification settings - Fork 0
267 lines (227 loc) · 8.38 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test-api:
name: Test API
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
database: ['mysql', 'postgres', 'sqlite']
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=20s
--health-timeout=5s
--health-retries=10
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 20s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
defaults:
run:
working-directory: api
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Fetch branches
run: git fetch --all
- name: Set up Go
uses: actions/setup-go@v5
id: go
with:
go-version-file: ${{ github.workspace }}/api/go.mod
cache: false
- name: Cache Go dependencies
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get C dependencies and 3rd-party tools
run: |
sudo add-apt-repository ppa:strukturag/libheif
sudo add-apt-repository ppa:strukturag/libde265
sudo apt-get update
sudo apt-get install -y libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev libheif-dev ffmpeg exiftool gnupg2 gpg curl
echo 'deb [trusted=yes] http://download.opensuse.org/repositories/graphics:/darktable/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/graphics:darktable.list
sudo apt-get update
sudo apt-get install -y darktable
- name: Get GO dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v .
- name: Configure MySQL
if: ${{ matrix.database == 'mysql' }}
run: |
cp ../.github/mysql.testing.env testing.env
- name: Configure Postgres
if: ${{ matrix.database == 'postgres' }}
run: |
cp ../.github/postgres.testing.env testing.env
- name: Configure Sqlite
if: ${{ matrix.database == 'sqlite' }}
run: |
touch photoview_test.db
cp ../.github/sqlite.testing.env testing.env
- name: Test
id: test
run: |
go install github.com/jstemmer/go-junit-report@latest
go test ./... -v -database -filesystem -p 1 -coverprofile=coverage.txt -covermode=atomic 2>&1 | tee >(go-junit-report > test-report.xml)
- name: Upload coverage
uses: codecov/codecov-action@v5
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
flags: api-${{ matrix.database }}
token: ${{ secrets.CODECOV_TKN }}
- name: Upload test execution results
uses: codecov/test-results-action@v1
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
flags: api-${{ matrix.database }}
token: ${{ secrets.CODECOV_TKN }}
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }} && github.repository == 'kkovaletp/photoview'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_API }}
with:
projectBaseDir: api/
test-ui:
name: Test UI
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch branches
run: git fetch --all
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Install dependencies
run: npm clean-install
- name: Test
id: test
run: npm run test:ci
- name: Upload coverage
uses: codecov/codecov-action@v5
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
flags: ui
token: ${{ secrets.CODECOV_TKN }}
- name: Upload test execution results
uses: codecov/test-results-action@v1
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
with:
flags: ui
token: ${{ secrets.CODECOV_TKN }}
- name: Run ESLint
run: |
echo "--------------------------"
echo "ESLint execution results :"
echo "--------------------------"
npm run lint:ci || true
- 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
- name: Publish ESlint report in PR comment
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.COMMENT_TOKEN }}
script: |
let ESLintResults = "${{ steps.eslint-artifact.outputs.artifact-url }}";
let output = '';
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const botComment = comments.data.find(
comment => comment.user.login === 'github-actions[bot]'
&& comment.body.includes('ESLint')
);
if (ESLintResults) {
output += '#### UI: ESLint issues:\n';
output += 'ESLint detected issues in the UI code.\n';
output += '\n[ESLint execution report](' + ESLintResults + ')\n';
output += '\nMake sure that you are logged in to be able to access the report.';
output += '\nThe report is accessible by this link within 90 days after the last ';
output += 'UI testing workflow execution time.';
output += '\nAfter that time you need to go to the ESLint execution step in the ';
output += 'Actions tab to see the same results.';
if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
});
}
} else {
if (botComment) {
await github.rest.issues.deleteComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo
});
}
}
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }} && github.repository == 'kkovaletp/photoview'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_UI }}
with:
projectBaseDir: ui/