@@ -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,42 @@ 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@v4
14854 with :
149- path-to-profile : profile.cov
55+ name : coverage-profile-${{ github.run_id }}
56+ path : profile.cov
57+ retention-days : 1
15058
15159 - name : Run GoReleaser
15260 uses : goreleaser/goreleaser-action@v6
15361 with :
15462 version : latest
15563 args : release --snapshot --skip=publish --clean
15664
65+ coverage :
66+ if : true # false to skip job during debug
67+ name : Coverage Report
68+ runs-on : ubuntu-latest
69+ needs : [test]
70+ steps :
71+
72+ - name : Download coverage profile
73+ uses : actions/download-artifact@v4
74+ with :
75+ name : coverage-profile-${{ github.run_id }}
76+
77+ - name : Send coverage to Coveralls
78+ uses : coverallsapp/github-action@v2
79+ with :
80+ file : profile.cov
81+
15782 build-docs :
15883 if : true # false to skip job during debug
159- needs : [test-postgresql-ubuntu, test-postgresql-windows, test-postgresql-macos ]
84+ needs : [test]
16085 name : Build Docs
16186 runs-on : ubuntu-latest
16287 steps :
@@ -201,7 +126,7 @@ jobs:
201126
202127 test-docker-images :
203128 if : true # false to skip job during debug
204- needs : [test-postgresql-ubuntu, test-postgresql-windows, test-postgresql-macos ]
129+ needs : [test]
205130 name : Test Docker Image Build
206131 runs-on : ubuntu-latest
207132 steps :
0 commit comments