-
Notifications
You must be signed in to change notification settings - Fork 6
74 lines (64 loc) · 2.07 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: ci
on:
push:
branches: [main]
pull_request:
paths-ignore:
- 'doc/**'
- 'README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
GO_VERSION: 1.17
jobs:
prep-matrix:
name: prep-matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Set matrix
id: set-matrix
run: echo "matrix=$(ls | grep 'operator-v*' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
lint-build-test:
name: lint-build-test
needs: prep-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
folder-path: ${{ fromJson(needs.prep-matrix.outputs.matrix) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: ${{ matrix.folder-path }}/go.sum
- name: Run go fmt
run: go fmt ./...
working-directory: ${{ matrix.folder-path }}
- name: Run go vet
run: go vet ./...
working-directory: ${{ matrix.folder-path }}
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Run golangci-lint
run: golangci-lint run --fix --timeout 5m
working-directory: ${{ matrix.folder-path }}
# Those steps are commented because they require go1.18.
#- name: Install shadow
# run: go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
#- name: Run shadow
# run: shadow ./...
# working-directory: ${{ matrix.folder-path }}
- name: Build binary
run: make build
working-directory: ${{ matrix.folder-path }}
- name: Run tests
run: make test
working-directory: ${{ matrix.folder-path }}