-
Notifications
You must be signed in to change notification settings - Fork 85
166 lines (153 loc) · 4.83 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
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
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
name: CI
jobs:
test:
runs-on: ubuntu-latest
container: alpine:edge # latest go pls
steps:
- name: checkout
uses: actions/checkout@v3
- name: add dependencies
run: apk add go git
- name: install ctags
run: ./install-ctags-alpine.sh
- name: test
run: go test ./...
fuzz-test:
name: fuzz test
runs-on: ubuntu-latest
container: alpine:edge
steps:
- name: add dependencies
run: apk add bash go
# Pinned a commit to make go version configurable.
# This should be safe to upgrade once this commit is in a released version:
# https://github.com/jidicula/go-fuzz-action/commit/23cc553941669144159507e2cccdbb4afc5b3076
- uses: jidicula/go-fuzz-action@0206b61afc603b665297621fa5e691b1447a5e57
with:
packages: 'github.com/sourcegraph/zoekt' # This is the package where the Protobuf round trip tests are defined
fuzz-time: 30s
fuzz-minimize-time: 1m
go-version: '1.22'
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/[email protected]
shfmt:
name: shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/[email protected]
with:
filter_mode: "nofilter"
fail_on_error: "true"
shfmt_flags: "-i 2 -ci -bn"
lint-protos:
name: "buf lint"
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v2
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GH_TOKEN }}
# Lint your Protobuf sources
- run: .github/workflows/buf-lint-check.sh
format-protos:
name: "buf format"
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v2
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GH_TOKEN }}
# Check to see if the Protobuf sources are formatted
- run: .github/workflows/buf-format-check.sh
generate-protos:
name: "buf generate"
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v2
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GH_TOKEN }}
# Check if the generated code is up-to-date
- run: .github/workflows/buf-generate-check.sh
# We build a shared docker image called "zoekt". This is not pushed, but is
# used for creating the indexserver and webserver images.
docker:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- "test"
- "shellcheck"
steps:
- name: checkout
uses: actions/checkout@v3
- name: version
id: version
run: .github/workflows/docker-version.sh
- name: docker-meta-webserver
id: meta-webserver
uses: docker/metadata-action@v3
with:
images: |
sourcegraph/zoekt-webserver
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: docker-meta-indexserver
id: meta-indexserver
uses: docker/metadata-action@v3
with:
images: |
sourcegraph/zoekt-indexserver
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: build-zoekt
uses: docker/build-push-action@v4
with:
context: .
tags: "zoekt:latest"
push: "false"
build-args: VERSION=${{ steps.version.outputs.value }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build-push-webserver
uses: docker/build-push-action@v4
with:
context: .
tags: sourcegraph/zoekt-webserver:${{ steps.version.outputs.value }}, ${{ steps.meta-webserver.outputs.tags }}, sourcegraph/zoekt-webserver:latest
file: Dockerfile.webserver
cache-from: sourcegraph/zoekt-webserver:latest
push: true
- name: build-push-indexserver
uses: docker/build-push-action@v4
with:
context: .
tags: sourcegraph/zoekt-indexserver:${{ steps.version.outputs.value }}, ${{ steps.meta-indexserver.outputs.tags }}, sourcegraph/zoekt-indexserver:latest
file: Dockerfile.indexserver
cache-from: sourcegraph/zoekt-indexserver:latest
push: true