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