-
Notifications
You must be signed in to change notification settings - Fork 625
147 lines (130 loc) · 4.91 KB
/
Copy path_test.yml
File metadata and controls
147 lines (130 loc) · 4.91 KB
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
name: "Unit Tests"
on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: true
env:
CGO_ENABLED: 0
jobs:
test-linux:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.18
env:
POSTGRES_PASSWORD: shiori
POSTGRES_USER: shiori
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
mariadb:
image: mariadb:10.5.27
env:
MYSQL_USER: shiori
MYSQL_PASSWORD: shiori
MYSQL_DATABASE: shiori
MYSQL_ROOT_PASSWORD: shiori
options: >-
--health-cmd="/usr/local/bin/healthcheck.sh --connect" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
mysql:
image: mysql:8.0.40
env:
MYSQL_USER: shiori
MYSQL_PASSWORD: shiori
MYSQL_DATABASE: shiori
MYSQL_ROOT_PASSWORD: shiori
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
ports:
- 3307:3306
name: Go unit tests (ubuntu-latest)
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: ./go.mod
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # v2.2.0
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # 5.0.1
with:
path: |
~/.cache/go-build
~/go/pkg
key: golangci-lint.cache-{platform-arch}-{interval_number}-{go.mod_hash}
restore-keys: |
golangci-lint.cache-{interval_number}-
golangci-lint.cache-
- run: make unittest
env:
SHIORI_TEST_PG_URL: "postgres://shiori:shiori@localhost:5432/shiori?sslmode=disable"
SHIORI_TEST_MYSQL_URL: "shiori:shiori@(localhost:3306)/shiori"
SHIORI_TEST_MARIADB_URL: "shiori:shiori@(localhost:3307)/shiori"
CGO_ENABLED: 1 # go test -race requires cgo
- run: go build -tags osusergo,netgo -ldflags="-s -w -X main.version=$(git describe --tags) -X main.date=$(date --iso-8601=seconds)"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # 5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-windows-macos:
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Go unit tests (${{ matrix.os }})
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: ./go.mod
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # 5.0.1
with:
path: |
~/.cache/go-build
~/go/pkg
key: golangci-lint.cache-{platform-arch}-{interval_number}-{go.mod_hash}
restore-keys: |
golangci-lint.cache-{interval_number}-
golangci-lint.cache-
- run: make unittest GO_TEST_FLAGS="-tags test_sqlite_only -race -v -count=1"
env:
CGO_ENABLED: 1 # go test -race requires cgo
- run: go build -tags osusergo,netgo -ldflags="-s -w -X main.version=$(git describe --tags) -X main.date=$(date --iso-8601=seconds)"
# Please note BSD support is offered on a best-effort basis, this check is not blocking but for us to be aware of issues.
# This test also does not take into consideration the go version specified in the go.mod file and just uses the
# latest version available in the openbsd package repository.
test-bsd:
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
os:
- name: openbsd
architecture: x86-64
version: "7.7"
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Test on ${{ matrix.os.name }}
uses: cross-platform-actions/action@46e8d7fb25520a8d6c64fd2b7a1192611da98eda # v0.30.0
with:
environment_variables: GO_VERSION
operating_system: ${{ matrix.os.name }}
architecture: ${{ matrix.os.architecture }}
version: ${{ matrix.os.version }}
shell: bash
memory: 1G
cpu_count: 1
run: |
sudo pkg_add -u
sudo pkg_add gmake git
curl -L https://go.dev/dl/go1.25.1.openbsd-amd64.tar.gz | sudo tar -C /usr/local -xzf -
export PATH=$PATH:/usr/local/go/bin
gmake unittest GO_TEST_FLAGS="-tags test_sqlite_only -v -count=1"