2020-12-12 03:06:59 +03:00
|
|
|
name: Go
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build and Lint
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-12-12 15:23:33 +03:00
|
|
|
|
|
|
|
# Setup
|
2020-12-12 03:06:59 +03:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: '^1.15'
|
2020-12-12 15:26:05 +03:00
|
|
|
- name: Install protoc
|
2020-12-12 15:23:33 +03:00
|
|
|
uses: arduino/setup-protoc@v1
|
2020-12-12 15:26:05 +03:00
|
|
|
- name: Install protoc-gen-go
|
|
|
|
run: go get -u github.com/golang/protobuf/protoc-gen-go
|
2020-12-12 15:23:33 +03:00
|
|
|
- name: Checkout code
|
2020-12-12 03:06:59 +03:00
|
|
|
uses: actions/checkout@v2
|
2020-12-12 15:23:33 +03:00
|
|
|
|
|
|
|
# Formatting, go mod tidy, and re-generate proto extension code
|
2020-12-12 12:28:25 +03:00
|
|
|
- name: Run go fmt on all modules
|
2020-12-12 19:16:43 +03:00
|
|
|
run: go fmt ./...
|
2020-12-12 03:06:59 +03:00
|
|
|
- name: Run go mod tidy on all modules
|
2020-12-12 19:16:43 +03:00
|
|
|
run: go mod tidy
|
2020-12-12 19:12:06 +03:00
|
|
|
- name: Verify no changes from go fmt and go mod tidy. If you're reading this please re-run locally before PR.
|
2020-12-12 03:06:59 +03:00
|
|
|
run: |
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
|
|
git status # Show the files that failed to pass the check.
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-12 15:23:33 +03:00
|
|
|
|
2020-12-12 03:06:59 +03:00
|
|
|
- name: go vet
|
2020-12-12 19:16:43 +03:00
|
|
|
run: go vet ./...
|
2020-12-12 03:06:59 +03:00
|
|
|
- name: Build code
|
2020-12-12 19:16:43 +03:00
|
|
|
run: go build
|
2020-12-12 15:23:33 +03:00
|
|
|
- name: Run examples
|
2020-12-16 19:35:57 +03:00
|
|
|
run: |
|
|
|
|
protoc -I. -Iexamples --plugin=./protoc-gen-bq-schema --bq-schema_out=examples examples/foo.proto
|
|
|
|
protoc -I. -Iexamples --plugin=./protoc-gen-bq-schema --bq-schema_out=examples examples/foo-proto3.proto
|
2021-08-18 06:41:42 +03:00
|
|
|
protoc -I. -Iexamples --plugin=./protoc-gen-bq-schema --bq-schema_out=examples --bq-schema_opt=single-message examples/single_message.proto
|
2020-12-12 15:23:33 +03:00
|
|
|
- name: Verify examples are working
|
|
|
|
run: |
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
|
|
git status # Show the files that failed to pass the check.
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-18 06:41:42 +03:00
|
|
|
|
2020-12-12 03:06:59 +03:00
|
|
|
test:
|
|
|
|
name: Root tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-08-18 06:41:42 +03:00
|
|
|
go-version: '^1.16'
|
2020-12-12 03:06:59 +03:00
|
|
|
- name: Check code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- run: go test -v
|