Skip to content

Commit b001c44

Browse files
ci: fix test path, go version, add vet and postgres integration
1 parent abfeb9f commit b001c44

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

.github/workflows/go.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:16
16+
env:
17+
POSTGRES_USER: cryden
18+
POSTGRES_PASSWORD: cryden_test
19+
POSTGRES_DB: cryden_test
20+
ports:
21+
- 5432:5432
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version-file: go.mod
36+
37+
- name: Verify all internal imports use the /v2 module path
38+
run: |
39+
if grep -rn '"github.com/crydensync/cryden"' --include="*.go" . ; then
40+
echo "::error::Found a bare (non-/v2) internal import — see lines above."
41+
exit 1
42+
fi
43+
44+
- name: Build
45+
run: go build -v ./...
46+
47+
- name: Vet
48+
run: go vet ./...
49+
50+
- name: Install postgresql-client
51+
run: sudo apt-get update && sudo apt-get install -y postgresql-client
52+
53+
- name: Run migrations against test Postgres
54+
run: |
55+
for f in store/postgres/migrations/*.up.sql; do
56+
psql "$DATABASE_URL" -f "$f"
57+
done
58+
env:
59+
DATABASE_URL: postgres://cryden:cryden_test@localhost:5432/cryden_test?sslmode=disable
60+
61+
- name: Test
62+
run: go test -v ./...
63+
env:
64+
DATABASE_URL: postgres://cryden:cryden_test@localhost:5432/cryden_test?sslmode=disable

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: go.mod
23+
24+
- name: Build
25+
run: go build -v ./...
26+
27+
- name: Vet
28+
run: go vet ./...
29+
30+
- name: Run tests
31+
run: go test -v ./...
32+
33+
- name: Create Release
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
generate_release_notes: true
37+
name: Release ${{ github.ref_name }}
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)