Updated github workflows

master
Ian Davis 2022-09-20 13:32:43 +01:00
parent f9a084323d
commit 52a051450d
No known key found for this signature in database
GPG Key ID: F3B290C645FE1783
3 changed files with 164 additions and 0 deletions

66
.github/workflows/autodep.yml vendored 100644
View File

@ -0,0 +1,66 @@
env:
GO_VERSION: 1.19
on:
workflow_dispatch:
schedule:
- cron: "15 6 * * 1" # 6:15 UTC weekly on Monday
jobs:
dep_update:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout
uses: actions/checkout@v3
- name: Update minor and patch-level dependencies
run: go get -t -u ./...
- name: Tidy
run: go mod tidy
- name: Create pull request
uses: peter-evans/create-pull-request@v4
with:
title: "Update package dependencies + tidy"
body: |
This is a change initiated automatically on a weekly basis by a
GitHub Action that updates the projects dependencies to their latest
minor and patch-level versions. This lets us stay up to date
incrementally so that updates are less effort to get merged compared
to large monolithic updates, and gets us security updates more
expediently.
If the build passes, you are probably A-OK to merge and deploy this.
If not, try to dig into what's not working and see if you can fix it
so that the dep train stays on its rails.
Note that although minor/patch level changes are handled
automatically, notably major version changes like you'd find in
stripe-go are not and those upgrades need to be performed manually.
That should theoretically not be a problem if fixes are backported
to all previous majors, but in practice they are often not, so it's
worthwhile to occasionally look for new majors and integrate them.
branch: "dep-update"
commit-message: |
Update package dependencies + tidy
Weekly update to the project's package dependencies initiated by an
automatic GitHub Action running on cron. Keeps upgrades less of a
monolithic task and lets security-related patches trickle in more
quickly.
author: "Bot <bot@iandavis.com>"
committer: "Bot <bot@iandavis.com>"
delete-branch: true
draft: true
reviewers: |
iand
assignees: |
iand

48
.github/workflows/check.yml vendored 100644
View File

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

50
.github/workflows/test.yml vendored 100644
View File

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