-
Notifications
You must be signed in to change notification settings - Fork 108
91 lines (76 loc) · 2.31 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
name: ci
on:
pull_request: {}
push:
branches:
- main
jobs:
go-fmt:
name: go-fmt
runs-on: ubuntu-20.04
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.23"
- name: Checkout branch
uses: actions/checkout@v3
# Fail if go-fmt recommends any changes.
- name: Run go fmt
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
go-test-postgres:
name: go-test-postgres
runs-on: ubuntu-20.04
env:
# These dummy values are used for testing purposes only.
POSTGRES_URI: postgresql://admin:admin@localhost:5432/admin
services:
postgres:
image: postgres:14.2-alpine3.15
env:
# These dummy values are used for testing purposes only.
POSTGRES_DB: admin
POSTGRES_PASSWORD: admin
POSTGRES_USER: admin
# Set health checks to wait until postgres has started.
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.23"
- name: Checkout branch
uses: actions/checkout@v3
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Install dependencies if not found in cache.
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: go mod download && go install
- name: Build package
run: go build
- name: Run migrations
run: go run scripts/migrate.go migrate
- name: Run go test
run: >-
go test -run TestAssociations -v ./lib &&
go test -run TestDAOCoinLimitOrder -v ./lib &&
go test -run TestFreezingPosts -v ./lib &&
go test -run TestBalanceModelAssociations -v ./lib &&
go test -run TestPGGenesisBlock -v ./lib
- name: Rollback migrations
run: go run scripts/migrate.go rollback