-
Notifications
You must be signed in to change notification settings - Fork 7
249 lines (240 loc) · 7.2 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Build scrt
on:
push:
branches:
- 'main'
tags-ignore:
- '*'
pull_request:
branches:
- '**'
jobs:
build_docker_e2e_image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Save public key to file
run: 'cp .github/docker/scrt_id_rsa.pub ./scrt_id_rsa.pub'
- name: Build Git test container
uses: docker/build-push-action@v4
with:
file: .github/docker/Dockerfile_git+openssh
context: .
tags: scrt-git-test:${{ github.sha }}
outputs: type=docker,dest=/tmp/git-openssh-image.tar
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: git-openssh-image
path: /tmp/git-openssh-image.tar
lint:
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Checkout
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
test:
runs-on: ubuntu-latest
permissions: {}
needs:
- lint
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Checkout
uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Test
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: Install gcov2lcov
run: go install github.com/jandelgado/gcov2lcov@latest
- name: Convert coverage.out to coverage.lcov
run: gcov2lcov -infile coverage.out -outfile coverage.lcov
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
e2e:
runs-on: ubuntu-latest
permissions:
packages: read
services:
minio:
# Use Bitnami image here because default minio image runs the executable
# and GitHub actions won't let us pass args to docker create so we can't
# change the entrypoint
image: bitnami/minio
options: --name=minio
ports:
- 9000:9000
needs:
- lint
- build_docker_e2e_image
steps:
# Setup Go and checkout
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Checkout
uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# Prepare MinIO
- name: Create test bucket
run: docker exec minio mkdir -p /data/test-bucket
# Prepare Git
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: git-openssh-image
path: /tmp
- name: Run git-openssh container
run: |
docker load --input /tmp/git-openssh-image.tar
docker run -d \
--env PUBLIC_KEY_FILE="/config/scrt_id_rsa.pub" \
--env USER_NAME=scrt \
-p 22222:2222 \
scrt-git-test:${{ github.sha }}
- name: Get git container SSH public key
id: git_ssh_public_key
run: |
sleep 3
echo ::set-output name=known_host::$(ssh-keyscan -p 22222 -t ecdsa 127.0.0.1)
- name: Get SSH private key
id: git_ssh_private_key
uses: actions/github-script@v6
with:
script: |
const fs = require('fs')
const buf = fs.readFileSync('.github/docker/scrt_id_rsa')
core.setOutput('private_key', buf.toString())
- name: Add private SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ steps.git_ssh_private_key.outputs.private_key }}
name: scrt_id_rsa
known_hosts: ${{ steps.git_ssh_public_key.outputs.known_host }}
config: |
Host scrt-git-test
HostName 127.0.0.1
Port 22222
User scrt
IdentitiesOnly yes
IdentityFile /home/runner/.ssh/scrt_id_rsa
- name: Output SSH status for debug purposes
run: |
cat /home/runner/.ssh/config
cat /home/runner/.ssh/known_hosts
cat /home/runner/.ssh/scrt_id_rsa
- name: Start SSH Agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ steps.git_ssh_private_key.outputs.private_key }}
# Run tests
- name: Run tests
env:
SCRT_TEST_E2E: y
SCRT_TEST_E2E_S3_ENDPOINT_URL: http://127.0.0.1:9000
SCRT_TEST_E2E_S3_REGION: us-east-1
SCRT_TEST_E2E_GIT_REPOSITORY_URL: scrt@scrt-git-test:repos/scrt-test.git
SCRT_TEST_E2E_GIT_BRANCH: main
AWS_ACCESS_KEY_ID: minio
AWS_SECRET_ACCESS_KEY: miniosecret
run: go test ./e2e
build:
runs-on: ubuntu-latest
permissions: {}
needs:
- lint
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Checkout
uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Build
run: go build -v .
lint-docs:
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: ./.github/actions/setup-node
- name: Lint documentation
working-directory: docs
run: npm run lint
tsc-check-docs:
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: ./.github/actions/setup-node
- name: Run Typescript compiler
working-directory: docs
run: npm run tsc
build-docs:
runs-on: ubuntu-latest
permissions: {}
needs:
- 'lint-docs'
- 'tsc-check-docs'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: ./.github/actions/setup-node
- name: Build static website
working-directory: docs
run: npm run build