-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (121 loc) · 3.73 KB
/
ci.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
name: CI
on:
pull_request:
branches: [ master ]
jobs:
build:
strategy:
fail-fast: false
matrix:
go-version: [1.22.x]
platform:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.platform }}
env:
DISPLAY: ':99.0'
XDG_SESSION_TYPE: 'x11'
EGL_PLATFORM: 'x11'
steps:
- name: install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: govulncheck
run: |
go run golang.org/x/vuln/cmd/govulncheck@latest
- name: non-Go linux dependencies
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -qq libudev-dev libxss-dev libxres-dev gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev xdotool x11-utils xdotool i3-wm
echo "DISPLAY=${DISPLAY}"
# Start a virtual frame buffer and wait a bit for it to be ready...
Xvfb :99 -screen 0 1920x1024x24 &
sleep 1
# and a window manager to get focus for testers and wait again.
i3 &
sleep 1
- name: unit tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
go test ./rpc ./internal/... ./cmd/*/api ./cmd/worklog/store
go test -run 'Test(Amendments|Continuation|DashboardData)$' ./cmd/worklog
- name: integration tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
go test .
go test -p=1 -run TestDaemon ./cmd/* -verbose_log
go test -run TestDaemon ./cmd/watcher -dynamic_timezone=false -verbose_log
go test -run TestDaemon ./cmd/watcher -dynamic_timezone=true -verbose_log
- name: no xorg watcher
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get remove -qq libxss-dev libxres-dev libx11-dev
sudo apt-get autoremove -qq
go build -tags no_xorg ./cmd/watcher
postgres-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
options: >-
--name postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: test_user
PGPASSWORD: password
POSTGRES_DB: postgres
steps:
- name: install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: non-Go linux dependencies
run: |
sudo apt-get update
sudo apt-get install -qq libudev-dev
- name: set up postgres users
run: |
psql --host $PGHOST \
--username="postgres" \
--dbname="postgres" \
--command="CREATE USER $PGUSER PASSWORD '$PGPASSWORD'" \
--command="ALTER USER $PGUSER CREATEDB" \
--command="CREATE USER ${PGUSER}_ro PASSWORD '$PGPASSWORD'" \
--command="\du"
- name: unit tests postgres
run: |
go test ./cmd/worklog/pgstore
- name: integration tests postgres
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
go test -tags postgres -run TestScripts/worklog_load_postgres