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