Merge pull request #26 from ythadhani/typedef_extensions #537
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: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
go: ['1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.x'] | |
steps: | |
- name: Install protobuf | |
uses: arduino/setup-protoc@v1 | |
with: | |
version: '3.x' | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go }} | |
id: go | |
- if: ${{ matrix.go == '1.13' || matrix.go == '1.14' || matrix.go == '1.15' }} | |
name: Install protoc-gen-go, goimports, Staticcheck | |
run: | | |
GO111MODULE=on go get google.golang.org/protobuf/cmd/protoc-gen-go@latest | |
GO111MODULE=on go get golang.org/x/tools/cmd/goimports@latest | |
- if: ${{ !(matrix.go == '1.13' || matrix.go == '1.14' || matrix.go == '1.15') }} | |
name: Install protoc-gen-go, goimports, Staticcheck | |
run: | | |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | |
go install golang.org/x/tools/cmd/goimports@latest | |
- name: Check out code | |
uses: actions/checkout@v2 | |
with: | |
path: go/src/github.com/openconfig/ygot | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
working-directory: go/src/github.com/openconfig/ygot | |
- name: Generate dependencies | |
run: make generate | |
working-directory: go/src/github.com/openconfig/ygot | |
- name: Build packages | |
run: go build -v ./... | |
working-directory: go/src/github.com/openconfig/ygot | |
- name: Run Tests | |
run: go test -v ./... | |
working-directory: go/src/github.com/openconfig/ygot | |
- name: Run race tests | |
run: go test -race -v ./... | |
working-directory: go/src/github.com/openconfig/ygot | |
- name: Check that Go integration test files compile | |
working-directory: go/src/github.com/openconfig/ygot | |
run: | | |
function test-go-build() { | |
cwd=$(pwd) | |
tmpdir=$(mktemp -d -p $cwd) | |
for f in "$@"; do | |
name=$(basename $f) | |
cp "$f" "$tmpdir"/"${name}.go" | |
done | |
cd $tmpdir | |
goimports -w *.go | |
go build | |
cd $cwd | |
rm -r $tmpdir | |
} | |
skipped=( | |
# fake ygot and ytype paths specified in generation options. | |
"openconfig-options-explicit.formatted-txt.go" | |
) | |
for f in ygen/testdata/schema/*.formatted-txt; do | |
if [[ ${skipped[@]} =~ $(basename $f) ]]; then | |
continue | |
fi | |
test-go-build $f | |
done | |
skipped=( | |
) | |
for f in ygen/testdata/structs/*.formatted-txt; do | |
if [[ ${skipped[@]} =~ $(basename $f) ]]; then | |
continue | |
fi | |
test-go-build $f | |
done | |
skipped=( | |
# GoStructs in a separate package, harder to set-up. | |
"openconfig-augmented.path-txt" | |
"openconfig-withlist-separate-package.path-txt" | |
) | |
for f in ypathgen/testdata/structs/*.path-txt; do | |
if [[ ${skipped[@]} =~ $(basename $f) ]]; then | |
continue | |
fi | |
filename=$(basename $f) | |
f_prefix="${filename%%.*}" | |
ygen_file="ygen/testdata/structs/${f_prefix}.formatted-txt" | |
test-go-build $f $ygen_file | |
done | |
static_analysis: | |
name: Static Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.18' | |
id: go | |
- name: Install required static analysis tools | |
run: | | |
go install github.com/go-playground/overalls@latest | |
go install github.com/mattn/goveralls@latest | |
go install honnef.co/go/tools/cmd/staticcheck@latest | |
- name: Check out ygot code | |
uses: actions/checkout@v2 | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
- name: Run coverage | |
run: | | |
overalls -project ${GITHUB_WORKSPACE} -covermode=count -ignore=".git,vendor,integration_tests,ygot/schema_tests,ygen/schema_tests,ypathgen/path_tests,demo,experimental/ygotutils,generator,ytypes/schema_tests,ypathgen/generator" | |
- name: Submit coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: overalls.coverprofile | |
- name: Go vet | |
run: | | |
for i in util ygen ytypes ygot/pathtranslate ypathgen; do | |
go vet ./$i | |
done | |
for j in ygot testcmp testutil; do | |
go vet -composites=false ./$j | |
done | |
- name: Gofmt | |
run: | | |
for i in util ygot ygen ytypes ygot/pathtranslate testutil testcmp ypathgen; do | |
diff -u <(echo -n) <(gofmt -d -s ./$i) | |
done | |
- name: Staticcheck | |
run: | | |
checkstr="" | |
for i in util ygot ygen ytypes ygot/pathtranslate testutil testcmp ypathgen; do | |
checkstr="$checkstr github.com/openconfig/ygot/$i/..." | |
done | |
staticcheck $checkstr |