chore(.github): split build and lint into multiple jobs
@@ -7,18 +7,37 @@ on:
branches:
- master
jobs:
+ # Split build and lint into a few different jobs so they can run in parallel.
build:
- name: Build and Lint
+ name: Build
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Build code
+ # Use find to build all modules. '-execdir ... ;' doesn't set an exit code
+ # based on command results. So, create a file if a build fails and check
+ # if the file exists to set the right exit code.
+ run: |
+ ROOT_DIR=$(pwd) \
+ find . -name go.mod -execdir sh -c 'go build ./... || touch $ROOT_DIR/build_failed.txt' \; ; \
+ test ! -f build_failed.txt
+ lint:
+ name: Lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: '^1.16'
+ - name: Checkout code
+ uses: actions/checkout@v2
- name: Install goimports
run: go get golang.org/x/tools/cmd/goimports
- - name: Check code
- uses: actions/checkout@v2
- run: goimports -w .
- name: Run go mod tidy on all modules
run: find . -name go.mod -execdir go mod tidy \;
@@ -30,6 +49,18 @@ jobs:
git status # Show the files that failed to pass the check.
exit 1
fi
+ - name: shellcheck
+ run: find . -name "*.sh" -exec shellcheck {} \;
+ vet:
+ name: Vet
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: '^1.16'
+ - name: Checkout code
+ uses: actions/checkout@v2
- name: go vet
# Use find to build all modules. '-execdir ... ;' doesn't set an exit code
# based on command results. So, create a file if a build fails and check
@@ -38,16 +69,6 @@ jobs:
ROOT_DIR=$(pwd) \
find . -name go.mod -execdir sh -c 'go vet ./... || touch $ROOT_DIR/vet_failed.txt' \; ; \
test ! -f vet_failed.txt
- - name: Build code
- # Use find to build all modules. '-execdir ... ;' doesn't set an exit code
- # based on command results. So, create a file if a build fails and check
- # if the file exists to set the right exit code.
- run: |
- ROOT_DIR=$(pwd) \
- find . -name go.mod -execdir sh -c 'go build ./... || touch $ROOT_DIR/build_failed.txt' \; ; \
- test ! -f build_failed.txt
- - name: shellcheck
- run: find . -name "*.sh" -exec shellcheck {} \;
test:
name: Root tests
runs-on: ubuntu-latest
