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