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 - uses: jidicula/go-fuzz-action@2d8b802597c47a79764d83dabc27fb672f2fb8d9
52 with:
53 packages: 'github.com/sourcegraph/zoekt' # This is the package where the Protobuf round trip tests are defined
54 fuzz-time: 30s
55 fuzz-minimize-time: 1m
56 go-version: '1.23'
57
58 shellcheck:
59 name: shellcheck
60 runs-on: ubuntu-latest
61 steps:
62 - uses: actions/checkout@v3
63 - name: Run ShellCheck
64 uses: ludeeus/action-shellcheck@1.1.0
65
66 shfmt:
67 name: shfmt
68 runs-on: ubuntu-latest
69 steps:
70 - uses: actions/checkout@v3
71 - uses: reviewdog/action-shfmt@v1.0.2
72 with:
73 filter_mode: "nofilter"
74 fail_on_error: "true"
75 shfmt_flags: "-i 2 -ci -bn"
76
77 lint-protos:
78 name: "buf lint"
79 runs-on: ubuntu-latest
80 steps:
81 # Run `git checkout`
82 - uses: actions/checkout@v2
83 # Install the `buf` CLI
84 - uses: bufbuild/buf-setup-action@v1
85 with:
86 github_token: ${{ secrets.GH_TOKEN }}
87 # Lint your Protobuf sources
88 - run: .github/workflows/buf-lint-check.sh
89
90 format-protos:
91 name: "buf format"
92 runs-on: ubuntu-latest
93 steps:
94 # Run `git checkout`
95 - uses: actions/checkout@v2
96 # Install the `buf` CLI
97 - uses: bufbuild/buf-setup-action@v1
98 with:
99 github_token: ${{ secrets.GH_TOKEN }}
100 # Check to see if the Protobuf sources are formatted
101 - run: .github/workflows/buf-format-check.sh
102
103 generate-protos:
104 name: "buf generate"
105 runs-on: ubuntu-latest
106 steps:
107 # Run `git checkout`
108 - uses: actions/checkout@v2
109 # Install the `buf` CLI
110 - uses: bufbuild/buf-setup-action@v1
111 with:
112 github_token: ${{ secrets.GH_TOKEN }}
113 # Check if the generated code is up-to-date
114 - run: .github/workflows/buf-generate-check.sh
115
116 # We build a shared docker image called "zoekt". This is not pushed, but is
117 # used for creating the indexserver and webserver images.
118 docker:
119 if: github.ref == 'refs/heads/main'
120 runs-on: ubuntu-latest
121 needs:
122 - "test"
123 - "shellcheck"
124 steps:
125 - name: checkout
126 uses: actions/checkout@v3
127
128 - name: version
129 id: version
130 run: .github/workflows/docker-version.sh
131
132 - name: docker-meta-webserver
133 id: meta-webserver
134 uses: docker/metadata-action@v3
135 with:
136 images: |
137 sourcegraph/zoekt-webserver
138 tags: |
139 type=ref,event=branch
140 type=ref,event=pr
141 type=semver,pattern={{version}}
142 type=sha
143 - name: docker-meta-indexserver
144 id: meta-indexserver
145 uses: docker/metadata-action@v3
146 with:
147 images: |
148 sourcegraph/zoekt-indexserver
149 tags: |
150 type=ref,event=branch
151 type=ref,event=pr
152 type=semver,pattern={{version}}
153 type=sha
154
155 - name: build-zoekt
156 uses: docker/build-push-action@v4
157 with:
158 context: .
159 tags: "zoekt:latest"
160 push: "false"
161 build-args: VERSION=${{ steps.version.outputs.value }}
162
163 - name: Login to Docker Hub
164 uses: docker/login-action@v2
165 with:
166 username: ${{ secrets.DOCKERHUB_USERNAME }}
167 password: ${{ secrets.DOCKERHUB_TOKEN }}
168
169 - name: build-push-webserver
170 uses: docker/build-push-action@v4
171 with:
172 context: .
173 tags: sourcegraph/zoekt-webserver:${{ steps.version.outputs.value }}, ${{ steps.meta-webserver.outputs.tags }}, sourcegraph/zoekt-webserver:latest
174 file: Dockerfile.webserver
175 cache-from: sourcegraph/zoekt-webserver:latest
176 push: true
177
178 - name: build-push-indexserver
179 uses: docker/build-push-action@v4
180 with:
181 context: .
182 tags: sourcegraph/zoekt-indexserver:${{ steps.version.outputs.value }}, ${{ steps.meta-indexserver.outputs.tags }}, sourcegraph/zoekt-indexserver:latest
183 file: Dockerfile.indexserver
184 cache-from: sourcegraph/zoekt-indexserver:latest
185 push: true