Updated github workflows

pull/15/head
Ian Davis 2023-03-03 10:40:09 +00:00
parent a9974e706d
commit 3dad76a6cc
4 changed files with 102 additions and 103 deletions

View File

@ -13,7 +13,7 @@ jobs:
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}

View File

@ -4,7 +4,7 @@ env:
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: [opened, reopened,ready_for_review,synchronize] types: [opened, reopened, ready_for_review, synchronize]
push: push:
branches: branches:
- main - main
@ -14,35 +14,35 @@ jobs:
check: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- name: Get StaticCheck - name: Get StaticCheck
run: go install honnef.co/go/tools/cmd/staticcheck@7586196b2bb05a248f1934d8087c759d05910e60 # Version 2022.1.2 (v0.3.2) run: go install honnef.co/go/tools/cmd/staticcheck@2eef17617de2b0c8051063b2c590a6a91459a19a # Version 2023.1.2 (v0.4.2)
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: recursive submodules: recursive
- name: Gomod - name: Gomod
run: | run: |
go mod tidy go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy" echo "go.sum was added by go mod tidy"
exit 1 exit 1
fi fi
git diff --exit-code -- go.sum go.mod git diff --exit-code -- go.sum go.mod
- name: Gofmt - name: Gofmt
if: ${{ success() || failure() }} # run this step even if the previous one failed if: ${{ success() || failure() }} # run this step even if the previous one failed
run: | run: |
out=$(gofmt -s -l .) out=$(gofmt -s -l .)
if [[ -n "$out" ]]; then if [[ -n "$out" ]]; then
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}' echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
exit 1 exit 1
fi fi
- name: Vet - name: Vet
if: ${{ success() || failure() }} # run this step even if the previous one failed if: ${{ success() || failure() }} # run this step even if the previous one failed
run: go vet ./... run: go vet ./...
- name: StaticCheck - name: StaticCheck
if: ${{ success() || failure() }} # run this step even if the previous one failed if: ${{ success() || failure() }} # run this step even if the previous one failed
run: staticcheck ./... run: staticcheck ./...

View File

@ -1,8 +1,7 @@
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: [opened, reopened,ready_for_review,synchronize] types: [opened, reopened, ready_for_review, synchronize]
push: push:
branches: branches:
- main - main
@ -12,36 +11,36 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.20.x go-version: 1.20.x
- name: Install Go tip - name: Install Go tip
run: | run: |
go install golang.org/dl/gotip@latest go install golang.org/dl/gotip@latest
gotip download gotip download
gotip version gotip version
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: recursive submodules: recursive
- id: Cache - id: Cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: | path: |
~/go/pkg/mod # Module download cache ~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux) ~/.cache/go-build # Build cache (Linux)
key: ubuntu-go-${{ hashFiles('**/go.sum') }} key: ubuntu-go-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
ubuntu-go- ubuntu-go-
- name: Dependencies - name: Dependencies
run: gotip mod download run: gotip mod download
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
- name: Test - name: Test
run: gotip test ./... run: gotip test ./...
- name: Test 32 bit - name: Test 32 bit
env: env:
GOARCH: 386 GOARCH: 386
run: gotip test ./... run: gotip test ./...
- name: Test with race detector - name: Test with race detector
run: gotip test -race ./... run: gotip test -race ./...

View File

@ -2,7 +2,7 @@
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: [opened, reopened,ready_for_review,synchronize] types: [opened, reopened, ready_for_review, synchronize]
push: push:
branches: branches:
- main - main
@ -13,38 +13,38 @@ jobs:
strategy: strategy:
matrix: matrix:
go-version: [1.19.x, 1.20.x] go-version: [1.19.x, 1.20.x]
os: [ "ubuntu", "windows", "macos" ] os: ["ubuntu", "windows", "macos"]
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: recursive submodules: recursive
- id: Cache - id: Cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: | path: |
~/go/pkg/mod # Module download cache ~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux) ~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac) ~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows) '%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
${{ runner.os }}-go- ${{ runner.os }}-go-
- name: Dependencies - name: Dependencies
run: go mod download run: go mod download
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
- name: Test - name: Test
run: go test ./... run: go test ./...
- name: Test 32 bit - name: Test 32 bit
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX. if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
env: env:
GOARCH: 386 GOARCH: 386
run: go test ./... run: go test ./...
- name: Test with race detector - name: Test with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
run: go test -race ./... run: go test -race ./...