fork of https://github.com/sourcegraph/zoekt
1on:
2 push:
3 branches:
4 - main
5 pull_request:
6name: CI
7jobs:
8 test:
9 runs-on: ubuntu-latest
10 container: alpine:edge # go1.19 needs > alpine 3.15
11 steps:
12 - name: checkout
13 uses: actions/checkout@v3
14 - name: add dependencies
15 run: apk add go git
16 - name: install ctags
17 run: ./install-ctags-alpine.sh
18 - name: test
19 run: go test ./...
20
21 shellcheck:
22 name: shellcheck
23 runs-on: ubuntu-latest
24 steps:
25 - uses: actions/checkout@v3
26 - name: Run ShellCheck
27 uses: ludeeus/action-shellcheck@1.1.0
28
29 shfmt:
30 name: shfmt
31 runs-on: ubuntu-latest
32 steps:
33 - uses: actions/checkout@v3
34 - uses: reviewdog/action-shfmt@v1.0.2
35 with:
36 filter_mode: "nofilter"
37 fail_on_error: "true"
38 shfmt_flags: "-i 2 -ci -bn"
39
40 lint-protos:
41 name: "buf lint"
42 runs-on: ubuntu-latest
43 steps:
44 # Run `git checkout`
45 - uses: actions/checkout@v2
46 # Install the `buf` CLI
47 - uses: bufbuild/buf-setup-action@v1
48 with:
49 github_token: ${{ secrets.GH_TOKEN }}
50 # Lint your Protobuf sources
51 - run: .github/workflows/buf-lint-check.sh
52
53 format-protos:
54 name: "buf format"
55 runs-on: ubuntu-latest
56 steps:
57 # Run `git checkout`
58 - uses: actions/checkout@v2
59 # Install the `buf` CLI
60 - uses: bufbuild/buf-setup-action@v1
61 with:
62 github_token: ${{ secrets.GH_TOKEN }}
63 # Check to see if the Protobuf sources are formatted
64 - run: .github/workflows/buf-format-check.sh
65
66 generate-protos:
67 name: "buf generate"
68 runs-on: ubuntu-latest
69 steps:
70 # Run `git checkout`
71 - uses: actions/checkout@v2
72 # Install the `buf` CLI
73 - uses: bufbuild/buf-setup-action@v1
74 with:
75 github_token: ${{ secrets.GH_TOKEN }}
76 # Check if the generated code is up-to-date
77 - run: .github/workflows/buf-generate-check.sh
78
79 # We build a shared docker image called "zoekt". This is not pushed, but is
80 # used for creating the indexserver and webserver images.
81 #
82 # While we run this job on main and PRs, the actual push is only done on the main branch.
83 docker:
84 if: github.ref == 'refs/heads/main'
85 runs-on: ubuntu-latest
86 needs:
87 - "test"
88 - "shellcheck"
89 steps:
90 - name: checkout
91 uses: actions/checkout@v3
92
93 - name: version
94 id: version
95 run: .github/workflows/docker-version.sh
96
97 - name: docker-meta-webserver
98 id: meta-webserver
99 uses: docker/metadata-action@v3
100 with:
101 images: |
102 sourcegraph/zoekt-webserver
103 tags: |
104 type=ref,event=branch
105 type=ref,event=pr
106 type=semver,pattern={{version}}
107 type=sha
108 - name: docker-meta-indexserver
109 id: meta-indexserver
110 uses: docker/metadata-action@v3
111 with:
112 images: |
113 sourcegraph/zoekt-indexserver
114 tags: |
115 type=ref,event=branch
116 type=ref,event=pr
117 type=semver,pattern={{version}}
118 type=sha
119
120 - name: build-zoekt
121 uses: docker/build-push-action@v4
122 with:
123 context: .
124 tags: "zoekt:latest"
125 push: "false"
126 build-args: VERSION=${{ steps.version.outputs.value }}
127
128 - name: Login to Docker Hub
129 uses: docker/login-action@v2
130 with:
131 username: ${{ secrets.DOCKERHUB_USERNAME }}
132 password: ${{ secrets.DOCKERHUB_TOKEN }}
133
134 - name: build-push-webserver
135 uses: docker/build-push-action@v4
136 with:
137 context: .
138 tags: sourcegraph/zoekt-webserver:${{ steps.version.outputs.value }}, ${{ steps.meta-webserver.outputs.tags }}, sourcegraph/zoekt-webserver:latest
139 file: Dockerfile.webserver
140 cache-from: sourcegraph/zoekt-webserver:latest
141 push: true
142
143 - name: build-push-indexserver
144 uses: docker/build-push-action@v4
145 with:
146 context: .
147 tags: sourcegraph/zoekt-indexserver:${{ steps.version.outputs.value }}, ${{ steps.meta-indexserver.outputs.tags }}, sourcegraph/zoekt-indexserver:latest
148 file: Dockerfile.indexserver
149 cache-from: sourcegraph/zoekt-indexserver:latest
150 push: true