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