diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8973c5b..55c7767 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,28 +1,63 @@ name: safeio -on: - push: - branches: - main - pull_request: +on: [workflow_dispatch, push] + +env: + GO_VERSION: '1.20' + +# This workflow runs for not-yet-reviewed external contributions and so it +# intentionally has no write access and only limited read access to the +# repository. +permissions: + contents: read jobs: unit-tests: - name: unit-tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '1.19' + go-version: ${{env.GO_VERSION}} + check-latest: true + cache: true + - run: go test ./... - golangci: - name: lint + - run: go test ./... -race + + lint: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.19 - - uses: actions/checkout@v3 + go-version: ${{env.GO_VERSION}} + check-latest: true + cache: true + + - name: "go fmt check" + shell: bash + run: | + files=$(go fmt ./...) + if [ -n "$files" ]; then + echo "The following file(s) do not conform to go fmt:" + echo "$files" + exit 1 + fi + + - name: "go vet" + shell: bash + run: | + go vet ./... + + - name: "go.mod and go.sum consistency check" + shell: bash + run: | + go mod tidy + if [[ -n "$(git status --porcelain)" ]]; then + echo >&2 "ERROR: go.mod/go.sum are not up-to-date. Run 'go mod tidy' and then commit the updated files." + exit 1 + fi + - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/go.mod b/go.mod index 1930365..4de64ca 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/rboyer/safeio -go 1.19 +go 1.20 -require github.com/stretchr/testify v1.8.1 +require github.com/stretchr/testify v1.8.2 require ( github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/go.sum b/go.sum index 2ec90f7..6a56e69 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=