Static route to BGP redistribution (#2569) #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/[email protected] | |
with: | |
go-version: 1.21.x | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build- | |
- name: Build | |
run: go build -v ./... | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/[email protected] | |
with: | |
go-version: 1.21.x | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build- | |
# Dependency for Go module github.com/google/gopacket | |
- name: Install libpcap-dev | |
run: sudo apt-get -y install libpcap-dev | |
- run: go test -v -coverprofile=profile.cov $(go list ./... | grep -v /.*test.*) | |
- name: Send coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: profile.cov | |
static_analysis: | |
name: Static Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.21' | |
# Go & staticcheck build cache require a lot of disk space. Reclaim extra | |
# space for the container by removing unnecessary tooling. | |
- name: Free additional disk space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/hostedtoolcache/CodeQL | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
~/.cache/staticcheck | |
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build- | |
# Dependency for Go module github.com/google/gopacket | |
- name: Install libpcap-dev | |
run: sudo apt-get -y install libpcap-dev | |
- name: Go vet | |
run: GOGC=30 go vet ./... | |
- name: Gofmt | |
run: | | |
# gofmt always returns true, so we use grep '^' which returns | |
# true on non-empty output, but will otherwise passthrough all | |
# output lines. | |
if gofmt -d -s . | grep '^'; then | |
exit 1 | |
fi | |
- name: Get goimports | |
run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: Goimports | |
run: | | |
# goimports always returns true, so we use grep '^' which returns | |
# true on non-empty output, but will otherwise passthrough all | |
# output lines. | |
# | |
# goimports does not support "gofmt -s" so both goimports and gofmt are | |
# required. | |
if goimports -d . | grep '^'; then | |
exit 1 | |
fi | |
- name: Get revive | |
run: go install github.com/mgechev/[email protected] | |
- name: Run revive | |
run: revive ./... | |
- name: Get staticcheck | |
run: go install honnef.co/go/tools/cmd/staticcheck@latest | |
- name: Run staticcheck | |
run: GOGC=30 staticcheck ./... |