fork of https://github.com/sourcegraph/zoekt
1on:
2 push:
3 branches:
4 - main
5 pull_request:
6 workflow_dispatch:
7name: CI
8jobs:
9 test:
10 runs-on: ubuntu-latest
11 container: alpine:edge # latest go pls
12 steps:
13 - name: checkout
14 uses: actions/checkout@v3
15
16 - name: add dependencies
17 run: apk add go git tar
18
19 - name: Cache ctags
20 uses: actions/cache@v3
21 with:
22 path: /usr/local/bin/universal-ctags
23 key: ${{ runner.os }}-ctags-${{ hashFiles('install-ctags-alpine.sh') }}
24
25 - name: Cache Go modules
26 uses: actions/cache@v3
27 with:
28 path: |
29 ~/.cache/go-build
30 ~/go/pkg/mod
31 key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32 restore-keys: |
33 ${{ runner.os }}-go-
34
35 - name: install ctags
36 run: |
37 if [ ! -f /usr/local/bin/universal-ctags ]; then
38 ./install-ctags-alpine.sh
39 fi
40
41 - name: test
42 run: go test ./...
43
44 fuzz-test:
45 name: fuzz test
46 runs-on: ubuntu-latest
47 container: alpine:edge
48 steps:
49 - name: add dependencies
50 run: apk add bash go
51 # Pinned a commit to make go version configurable.
52 # This should be safe to upgrade once this commit is in a released version:
53 # https://github.com/jidicula/go-fuzz-action/commit/23cc553941669144159507e2cccdbb4afc5b3076
54 - uses: jidicula/go-fuzz-action@0206b61afc603b665297621fa5e691b1447a5e57
55 with:
56 packages: 'github.com/sourcegraph/zoekt' # This is the package where the Protobuf round trip tests are defined
57 fuzz-time: 30s
58 fuzz-minimize-time: 1m
59 go-version: '1.22'
60
61 shellcheck:
62 name: shellcheck
63 runs-on: ubuntu-latest
64 steps:
65 - uses: actions/checkout@v3
66 - name: Run ShellCheck
67 uses: ludeeus/action-shellcheck@1.1.0
68
69 shfmt:
70 name: shfmt
71 runs-on: ubuntu-latest
72 steps:
73 - uses: actions/checkout@v3
74 - uses: reviewdog/action-shfmt@v1.0.2
75 with:
76 filter_mode: "nofilter"
77 fail_on_error: "true"
78 shfmt_flags: "-i 2 -ci -bn"
79
80 lint-protos:
81 name: "buf lint"
82 runs-on: ubuntu-latest
83 steps:
84 # Run `git checkout`
85 - uses: actions/checkout@v2
86 # Install the `buf` CLI
87 - uses: bufbuild/buf-setup-action@v1
88 with:
89 github_token: ${{ secrets.GH_TOKEN }}
90 # Lint your Protobuf sources
91 - run: .github/workflows/buf-lint-check.sh
92
93 format-protos:
94 name: "buf format"
95 runs-on: ubuntu-latest
96 steps:
97 # Run `git checkout`
98 - uses: actions/checkout@v2
99 # Install the `buf` CLI
100 - uses: bufbuild/buf-setup-action@v1
101 with:
102 github_token: ${{ secrets.GH_TOKEN }}
103 # Check to see if the Protobuf sources are formatted
104 - run: .github/workflows/buf-format-check.sh
105
106 generate-protos:
107 name: "buf generate"
108 runs-on: ubuntu-latest
109 steps:
110 # Run `git checkout`
111 - uses: actions/checkout@v2
112 # Install the `buf` CLI
113 - uses: bufbuild/buf-setup-action@v1
114 with:
115 github_token: ${{ secrets.GH_TOKEN }}
116 # Check if the generated code is up-to-date
117 - run: .github/workflows/buf-generate-check.sh
118
119 # We build a shared docker image called "zoekt". This is not pushed, but is
120 # used for creating the indexserver and webserver images.
121 docker:
122 if: github.ref == 'refs/heads/main'
123 runs-on: ubuntu-latest
124 needs:
125 - "test"
126 - "shellcheck"
127 steps:
128 - name: checkout
129 uses: actions/checkout@v3
130
131 - name: version
132 id: version
133 run: .github/workflows/docker-version.sh
134
135 - name: docker-meta-webserver
136 id: meta-webserver
137 uses: docker/metadata-action@v3
138 with:
139 images: |
140 sourcegraph/zoekt-webserver
141 tags: |
142 type=ref,event=branch
143 type=ref,event=pr
144 type=semver,pattern={{version}}
145 type=sha
146 - name: docker-meta-indexserver
147 id: meta-indexserver
148 uses: docker/metadata-action@v3
149 with:
150 images: |
151 sourcegraph/zoekt-indexserver
152 tags: |
153 type=ref,event=branch
154 type=ref,event=pr
155 type=semver,pattern={{version}}
156 type=sha
157
158 - name: build-zoekt
159 uses: docker/build-push-action@v4
160 with:
161 context: .
162 tags: "zoekt:latest"
163 push: "false"
164 build-args: VERSION=${{ steps.version.outputs.value }}
165
166 - name: Login to Docker Hub
167 uses: docker/login-action@v2
168 with:
169 username: ${{ secrets.DOCKERHUB_USERNAME }}
170 password: ${{ secrets.DOCKERHUB_TOKEN }}
171
172 - name: build-push-webserver
173 uses: docker/build-push-action@v4
174 with:
175 context: .
176 tags: sourcegraph/zoekt-webserver:${{ steps.version.outputs.value }}, ${{ steps.meta-webserver.outputs.tags }}, sourcegraph/zoekt-webserver:latest
177 file: Dockerfile.webserver
178 cache-from: sourcegraph/zoekt-webserver:latest
179 push: true
180
181 - name: build-push-indexserver
182 uses: docker/build-push-action@v4
183 with:
184 context: .
185 tags: sourcegraph/zoekt-indexserver:${{ steps.version.outputs.value }}, ${{ steps.meta-indexserver.outputs.tags }}, sourcegraph/zoekt-indexserver:latest
186 file: Dockerfile.indexserver
187 cache-from: sourcegraph/zoekt-indexserver:latest
188 push: true