| 1 |
# |
| 2 |
# Copyright 2022 Google LLC |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 |
# use this file except in compliance with the License. You may obtain a copy of |
| 6 |
# the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations under |
| 14 |
# the License. |
| 15 |
# |
| 16 |
|
| 17 |
name: CI |
| 18 |
on: |
| 19 |
push: |
| 20 |
tags: |
| 21 |
- v* |
| 22 |
branches: [main] |
| 23 |
pull_request: |
| 24 |
branches: [main] |
| 25 |
|
| 26 |
jobs: |
| 27 |
build: |
| 28 |
strategy: |
| 29 |
matrix: |
| 30 |
go-version: [1.21.x, 1.22.x] |
| 31 |
os: [macos-latest, ubuntu-latest] |
| 32 |
|
| 33 |
name: Build/Test (${{ matrix.os}}, Go ${{ matrix.go-version }}) |
| 34 |
runs-on: ${{ matrix.os }} |
| 35 |
steps: |
| 36 |
- uses: actions/checkout@v3 |
| 37 |
- name: Setup Go |
| 38 |
uses: actions/setup-go@v3 |
| 39 |
with: |
| 40 |
go-version: ${{ matrix.go-version }} |
| 41 |
- name: Install Protoc |
| 42 |
uses: arduino/setup-protoc@v3 |
| 43 |
with: |
| 44 |
repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 45 |
version: "27.2" |
| 46 |
- name: Install protoc-gen-go |
| 47 |
run: go install google.golang.org/protobuf/cmd/[email protected] |
| 48 |
- name: Check Protobuf Generation |
| 49 |
run: | |
| 50 |
go generate ./... |
| 51 |
git diff -G'^[^/]' --exit-code |
| 52 |
- name: Generate all protobufs |
| 53 |
run: go generate ./... |
| 54 |
- name: Build all packages |
| 55 |
run: go build -v ./... |
| 56 |
- name: Test all packages |
| 57 |
run: go test -v -race ./... |
| 58 |
- name: Run Go Vet |
| 59 |
run: go vet ./... |
| 60 |
|
| 61 |
lint: |
| 62 |
strategy: |
| 63 |
matrix: |
| 64 |
go-version: [1.21.x] |
| 65 |
os: [ubuntu-latest] |
| 66 |
|
| 67 |
name: Lint ${{ matrix.dir }} (${{ matrix.os }}, Go ${{ matrix.go-version }}) |
| 68 |
runs-on: ${{ matrix.os }} |
| 69 |
steps: |
| 70 |
- uses: actions/checkout@v3 |
| 71 |
- uses: actions/setup-go@v2 |
| 72 |
with: |
| 73 |
go-version: ${{ matrix.go-version }} |
| 74 |
- name: Run golangci-lint |
| 75 |
uses: golangci/[email protected] |
| 76 |
with: |
| 77 |
version: latest |
| 78 |
working-directory: ./ |
| 79 |
args: > |
| 80 |
-D errcheck |
| 81 |
-E stylecheck |
| 82 |
-E goimports |
| 83 |
-E misspell |
| 84 |
-E revive |
| 85 |
-E gofmt |
| 86 |
-E goimports |
| 87 |
--out-format=colored-line-number |
| 88 |
--exclude-use-default=false |
| 89 |
--max-same-issues=0 |
| 90 |
--max-issues-per-linter=0 |
| 91 |
--timeout 2m |
| 92 |
|
| 93 |
lintc: |
| 94 |
strategy: |
| 95 |
matrix: |
| 96 |
go-version: [1.21.x] |
| 97 |
os: [ubuntu-latest] |
| 98 |
|
| 99 |
name: Lint CGO (${{ matrix.os}}, Go ${{ matrix.go-version }}) |
| 100 |
runs-on: ${{ matrix.os }} |
| 101 |
steps: |
| 102 |
- uses: actions/checkout@v3 |
| 103 |
- uses: actions/setup-go@v2 |
| 104 |
with: |
| 105 |
go-version: ${{ matrix.go-version }} |
| 106 |
- name: Check for CGO Warnings (gcc) |
| 107 |
run: CGO_CFLAGS=-Werror CC=gcc go build ./... |
| 108 |
- name: Check for CGO Warnings (clang) |
| 109 |
run: CGO_CFLAGS=-Werror CC=clang go build ./... |