This repository has been archived by the owner on Dec 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (137 loc) · 3.87 KB
/
build.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
name: build
on:
push:
branches: [ main ]
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', '1.21' ]
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v3
- name: Install Go ${{ matrix.go-version }}
id: install-go
uses: actions/setup-go@v3
- name: Run golangci-lint
id: run-golangci-lint
uses: golangci/golangci-lint-action@v3.5.0
build-server:
name: Build and test server
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', '1.21' ]
needs:
- lint
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v3
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Install Go ${{ matrix.go-version }}
id: install-go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Download go modules
id: download-go-modules
run: go mod download
- name: Build server
id: build-server
run: go build ./cmd/server
- name: Test server
id: test-server
run: go test ./cmd/server/... ./src/server/...
build-client:
name: Build and test client
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', '1.21' ]
node-version: [ '18', '20' ]
needs:
- lint
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v3
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Install Go ${{ matrix.go-version }}
id: install-go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Install Node ${{ matrix.node-version }}
id: install-node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install node modules
id: install-node-modules
uses: bahmutov/npm-install@v1
with:
working-directory: ui
- name: Build UI
id: build-ui
run: npm --prefix ui run build
- name: Copy UI
id: copy-ui
run: cp -r static cmd/client
- name: Build client
id: build-client
run: go build ./cmd/client
- name: Test client
id: test-client
run: go test ./cmd/client/... ./src/client/...
test:
name: Run integration & package unit tests
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', '1.21' ]
mongodb-version: ['5.0', '6.0']
needs:
- build-server
- build-client
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v3
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Install Go ${{ matrix.go-version }}
id: install-go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Start MongoDB
id: start-mongodb
uses: supercharge/mongodb-github-action@1.8.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-db: 'myst'
- name: Run tests
id: run-tests
run: go test ./test/... ./pkg/...