Go #412
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: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go: ['1.19', '1.x'] | |
steps: | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go }} | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Get non-Go dependencies | |
run: | | |
sudo apt-get install libpcap-dev | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: | | |
go list ./... | egrep -v "magna/(e2e|cmd/(magna|mirror)|otgyang)" | while read l; do | |
dir=`echo $l | sed 's/^github.com\/openconfig\/magna//g'`; | |
fn=`echo $dir | sed 's/\//_/g'`; | |
sudo go test -v .$dir -covermode=count -coverprofile=$fn.cover.profile; | |
done; | |
echo "mode: count" > combined.coverprofile; | |
for i in `ls *.cover.profile`; do | |
tail -n +2 $i >> combined.coverprofile; | |
done; | |
rm *.cover.profile | |
- name: Race Test | |
run: | | |
go list ./... | egrep -v "magna/(e2e|cmd/(magna|mirror)|otgyang)" | while read l; do | |
dir=`echo $l | sed 's/^github.com\/openconfig\/magna//g'`; | |
fn=`echo $dir | sed 's/\//_/g'`; | |
sudo go test -v -race .$dir | |
done; | |
- name: Coveralls | |
if: ${{ matrix.go == '1.x' }} | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: combined.coverprofile | |
static_analysis: | |
name: Static Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.x' | |
id: go | |
- name: Install required static analysis tools | |
run: | | |
go install honnef.co/go/tools/cmd/staticcheck@latest | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Get dependencies | |
run: go get -v -t -d ./... | |
- name: Get C dependencies | |
run: sudo apt-get install libpcap-dev | |
- name: Go vet | |
run: go vet ./... | |
- name: Check gofmt | |
run: diff -u <(echo -n) <(gofmt -d -s .) | |
- name: Staticcheck | |
run: | | |
staticcheck ./... |