forked from highlight/highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (128 loc) · 5.19 KB
/
backend.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
name: Backend
on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize]
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
code-setup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'backend/go.mod'
code-quality-check:
needs: code-setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'backend/go.mod'
- name: Format
run: if [ "$(gofmt -l -d ./backend | wc -l)" -gt 0 ]; then gofmt -l -d ./backend && exit 1; fi
- name: Check for GORM Debug
run: if [ "$(grep --exclude-dir migrations -rE 'DB.[\s\n]*Debug\(\)' ./backend | wc -l)" -gt 0 ]; then grep --exclude-dir migrations -rE 'DB.[\s\n]*Debug\(\)' ./backend && exit 1; fi
- name: Check for GORM usage without context
run: if [ "$(grep --exclude="*_test.go" --exclude-dir={integrations,jobs,lambda-functions,migrations,model,oauth,retryables,zapier} -rEI '(?i:db)\.(Where|Model|Raw|Create|Update|Preload)' ./backend | grep -v 'WithContext' | wc -l)" -gt 0 ]; then grep --exclude="*_test.go" --exclude-dir={integrations,jobs,lambda-functions,migrations,model,oauth,retryables,zapier} -rEI '(?i:db)\.(Where|Model|Raw|Create|Update|Preload)' ./backend | grep -v 'WithContext' && exit 1; fi
- name: Check for logrus without context
run: if [ "$(grep --exclude-dir migrations --exclude main.go --exclude recovery.go --exclude logging.go -rE '\s+log\.(Debug|Info|Warn|Error|Fatal)' ./backend | grep -v 'WithContext' | grep -v 'Level' | wc -l)" -gt 0 ]; then grep --exclude-dir migrations --exclude main.go --exclude recovery.go --exclude logging.go -rE '\s+log\.(Debug|Info|Warn|Error|Fatal)' ./backend | grep -v 'WithContext' | grep -v 'Level' && exit 1; fi
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
args: --config ./.golangci.yml --timeout 5m
working-directory: backend
# version: latest
# Pinning the version until https://github.com/golangci/golangci-lint/issues/3862 is solved
version: v1.52.2
make-check:
needs: [code-setup]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'backend/go.mod'
- name: copy backend
run: |
mkdir tmp
cp -a backend/. tmp/
- name: Make private graph
run: |
cd backend/
make private-gen
- name: Make public graph
run: |
cd backend/
make public-gen
- name: Diff Check
run: |
diff -r backend/ tmp/
build:
needs: code-quality-check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'backend/go.mod'
- name: Build binary
run: cd backend/ && go build .
test:
needs: code-quality-check
runs-on: ubuntu-latest
services:
postgres:
image: ankane/pgvector
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
clickhouse:
image: clickhouse/clickhouse-server:23.5.1.3174
ports:
- 9000:9000
redis:
image: redis
ports:
- 6379:6379
env:
CLICKHOUSE_ADDRESS: 'localhost:9000'
CLICKHOUSE_DATABASE: 'default'
CLICKHOUSE_TEST_DATABASE: 'test'
CLICKHOUSE_USERNAME: 'default'
CLICKHOUSE_PASSWORD: ''
PSQL_HOST: 'localhost'
PSQL_PORT: '5432'
PSQL_USER: 'postgres'
PSQL_DB: 'postgres'
PSQL_PASSWORD: 'postgres'
ENVIRONMENT: 'test'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'backend/go.mod'
- name: Run tests
run: cd backend && go test -p 1 ./... -v
- name: Run fuzz tests
run: cd backend && make fuzz