-
Notifications
You must be signed in to change notification settings - Fork 71
200 lines (159 loc) · 5.36 KB
/
build.yml
File metadata and controls
200 lines (159 loc) · 5.36 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
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
name: Build and Test
permissions:
contents: write
packages: write
pages: write
on:
push:
branches:
- master
pull_request:
paths-ignore: ['docs/**', 'mkdocs.yml']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-postgresql-windows:
if: true # false to skip job during debug
name: Test on Windows
runs-on: windows-latest
steps:
- name: Start PostgreSQL on Windows
run: |
$pgService = Get-Service -Name postgresql*
Set-Service -InputObject $pgService -Status running -StartupType automatic
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
- name: Create scheduler user on Windows
run: |
& $env:PGBIN\psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du"
- name: Create timetable database
run: |
& $env:PGBIN\createdb --owner=scheduler timetable
$env:PGPASSWORD = 'somestrong'
& $env:PGBIN\psql --username=scheduler --host=localhost --list timetable
- name: Check out code
uses: actions/checkout@v5
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Test
run: go test -v -p 1 -parallel 1 -failfast ./...
test-postgresql-macos:
if: true # false to skip job during debug
name: Test on MacOS
runs-on: macos-latest
steps:
- name: Start PostgreSQL on MacOS
run: |
brew update
brew install postgresql@16
brew link --force postgresql@16
brew services start postgresql@16
echo "Check PostgreSQL service is running"
i=10
COMMAND='pg_isready'
while [ $i -gt 0 ]; do
echo "Check PostgreSQL service status"
eval $COMMAND && break
((i--))
if [ $i == 0 ]; then
echo "PostgreSQL service not ready, all attempts exhausted"
exit 1
fi
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
sleep 10
done
# Homebrew creates an account with the same name as the installing user, but no password
- name: Create scheduler user
run: |
psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du" postgres
- name: Create timetable database
run: |
createdb --owner=scheduler timetable
PGPASSWORD=somestrong psql --username=scheduler --host=localhost --list timetable
- name: Check out code
uses: actions/checkout@v5
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Test
run: go test -v -p 1 -parallel 1 -failfast ./...
test-postgresql-ubuntu:
if: true # false to skip job during debug
name: Test and Build on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Start PostgreSQL on Ubuntu
run: |
sudo systemctl start postgresql.service
pg_isready
- name: Create scheduler user
run: |
sudo -u postgres psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du"
- name: Create timetable database
run: |
sudo -u postgres createdb --owner=scheduler timetable
PGPASSWORD=somestrong psql --username=scheduler --host=localhost --list timetable
- name: Check out code
uses: actions/checkout@v5
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Get dependencies
run: |
go mod download
go version
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
- name: Test
run: go test -failfast -v -timeout=300s -p 1 -coverprofile=profile.cov ./...
- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --snapshot --skip=publish --clean
build-docs:
if: true # false to skip job during debug
needs: [test-postgresql-ubuntu, test-postgresql-windows, test-postgresql-macos]
name: Build Docs
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Configure Git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Set up gopages
run: go install github.com/johnstarich/go/[email protected]
- name: Build Developer Docs
run: gopages -out "docs/godoc" -base "/pg_timetable/devel/godoc" -internal
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.13
cache: 'pip'
cache-dependency-path: '**/requirements-doc.txt'
- name: Install dependencies
run: pip install -r docs/requirements-doc.txt
- name: Check if we should push to gh-pages
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
git fetch origin gh-pages --depth=1
echo "push_opt=--push" >> $GITHUB_ENV
- name: Build mkdocs
run: mike deploy ${{ env.push_opt }} devel