Skip to content

Commit 8cfac46

Browse files
committed
update GHA workflow
1 parent 7a43138 commit 8cfac46

File tree

1 file changed

+30
-106
lines changed

1 file changed

+30
-106
lines changed

.github/workflows/build.yml

Lines changed: 30 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,111 +17,17 @@ concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref }}
1818
cancel-in-progress: true
1919

20-
jobs:
21-
22-
test-postgresql-windows:
23-
if: true # false to skip job during debug
24-
name: Test on Windows
25-
runs-on: windows-latest
26-
steps:
27-
28-
- name: Start PostgreSQL on Windows
29-
run: |
30-
$pgService = Get-Service -Name postgresql*
31-
Set-Service -InputObject $pgService -Status running -StartupType automatic
32-
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
33-
34-
- name: Create scheduler user on Windows
35-
run: |
36-
& $env:PGBIN\psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du"
37-
38-
- name: Create timetable database
39-
run: |
40-
& $env:PGBIN\createdb --owner=scheduler timetable
41-
$env:PGPASSWORD = 'somestrong'
42-
& $env:PGBIN\psql --username=scheduler --host=localhost --list timetable
43-
44-
- name: Check out code
45-
uses: actions/checkout@v5
46-
47-
- name: Set up Golang
48-
uses: actions/setup-go@v6
49-
with:
50-
go-version: '1.25'
51-
52-
- name: Test
53-
run: go test -v -p 1 -parallel 1 -failfast ./...
54-
55-
56-
57-
test-postgresql-macos:
58-
if: true # false to skip job during debug
59-
name: Test on MacOS
60-
runs-on: macos-latest
61-
steps:
62-
63-
- name: Start PostgreSQL on MacOS
64-
run: |
65-
brew update
66-
brew install postgresql@16
67-
brew link --force postgresql@16
68-
brew services start postgresql@16
69-
echo "Check PostgreSQL service is running"
70-
i=10
71-
COMMAND='pg_isready'
72-
while [ $i -gt 0 ]; do
73-
echo "Check PostgreSQL service status"
74-
eval $COMMAND && break
75-
((i--))
76-
if [ $i == 0 ]; then
77-
echo "PostgreSQL service not ready, all attempts exhausted"
78-
exit 1
79-
fi
80-
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
81-
sleep 10
82-
done
83-
84-
# Homebrew creates an account with the same name as the installing user, but no password
85-
- name: Create scheduler user
86-
run: |
87-
psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du" postgres
88-
89-
- name: Create timetable database
90-
run: |
91-
createdb --owner=scheduler timetable
92-
PGPASSWORD=somestrong psql --username=scheduler --host=localhost --list timetable
20+
# This workflow uses testcontainers-go for PostgreSQL testing
21+
# Docker provides consistent environment - only Ubuntu needed
9322

94-
- name: Check out code
95-
uses: actions/checkout@v5
96-
97-
- name: Set up Golang
98-
uses: actions/setup-go@v6
99-
with:
100-
go-version: '1.25'
101-
102-
- name: Test
103-
run: go test -v -p 1 -parallel 1 -failfast ./...
23+
jobs:
10424

105-
test-postgresql-ubuntu:
25+
test:
10626
if: true # false to skip job during debug
107-
name: Test and Build on Ubuntu
27+
name: Test and Build with Testcontainers
10828
runs-on: ubuntu-latest
10929
steps:
11030

111-
- name: Start PostgreSQL on Ubuntu
112-
run: |
113-
sudo systemctl start postgresql.service
114-
pg_isready
115-
116-
- name: Create scheduler user
117-
run: |
118-
sudo -u postgres psql --command="CREATE USER scheduler PASSWORD 'somestrong'" --command="\du"
119-
120-
- name: Create timetable database
121-
run: |
122-
sudo -u postgres createdb --owner=scheduler timetable
123-
PGPASSWORD=somestrong psql --username=scheduler --host=localhost --list timetable
124-
12531
- name: Check out code
12632
uses: actions/checkout@v5
12733

@@ -140,23 +46,41 @@ jobs:
14046
with:
14147
version: latest
14248

143-
- name: Test
144-
run: go test -failfast -v -timeout=300s -p 1 -coverprofile=profile.cov ./...
49+
- name: Test with Testcontainers
50+
run: go test -failfast -v -timeout=300s -coverprofile=profile.cov ./...
14551

146-
- name: Coveralls
147-
uses: shogo82148/actions-goveralls@v1
52+
- name: Upload coverage profile
53+
uses: actions/upload-artifact@v5
14854
with:
149-
path-to-profile: profile.cov
55+
name: coverage-profile
56+
path: profile.cov
15057

15158
- name: Run GoReleaser
15259
uses: goreleaser/goreleaser-action@v6
15360
with:
15461
version: latest
15562
args: release --snapshot --skip=publish --clean
15663

64+
coverage:
65+
if: true # false to skip job during debug
66+
name: Coverage Report
67+
runs-on: ubuntu-latest
68+
needs: [test]
69+
steps:
70+
71+
- name: Download coverage profile
72+
uses: actions/download-artifact@v5
73+
with:
74+
name: coverage-profile
75+
76+
- name: Send coverage to Coveralls
77+
uses: coverallsapp/github-action@v2
78+
with:
79+
file: profile.cov
80+
15781
build-docs:
15882
if: true # false to skip job during debug
159-
needs: [test-postgresql-ubuntu, test-postgresql-windows, test-postgresql-macos]
83+
needs: [test]
16084
name: Build Docs
16185
runs-on: ubuntu-latest
16286
steps:
@@ -201,7 +125,7 @@ jobs:
201125

202126
test-docker-images:
203127
if: true # false to skip job during debug
204-
needs: [test-postgresql-ubuntu, test-postgresql-windows, test-postgresql-macos]
128+
needs: [test]
205129
name: Test Docker Image Build
206130
runs-on: ubuntu-latest
207131
steps:

0 commit comments

Comments
 (0)