From aaacbab37cf938fed73831f8492f5d597f41786b Mon Sep 17 00:00:00 2001 From: Ian Davis <18375+iand@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:58:53 +0000 Subject: [PATCH] Updated github workflows --- .github/workflows/autodep.yml | 12 ++++---- .github/workflows/check.yml | 45 --------------------------- .github/workflows/gotip.yml | 46 --------------------------- .github/workflows/test.yml | 58 +++++++++++++++++++++++------------ .github/workflows/version.yml | 13 +++++--- 5 files changed, 53 insertions(+), 121 deletions(-) delete mode 100644 .github/workflows/check.yml delete mode 100644 .github/workflows/gotip.yml diff --git a/.github/workflows/autodep.yml b/.github/workflows/autodep.yml index e2a625a..332c146 100644 --- a/.github/workflows/autodep.yml +++ b/.github/workflows/autodep.yml @@ -7,13 +7,13 @@ jobs: timeout-minutes: 10 steps: - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' - name: Update minor and patch-level dependencies run: go get -t -u ./... diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index f483fe6..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,45 +0,0 @@ -on: - workflow_dispatch: - pull_request: - types: [opened, reopened, ready_for_review, synchronize] - push: - branches: - - main - - master -name: Run checks -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - name: Get StaticCheck - run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.2 # Version 2023.1.2 (v0.4.2) - - name: Checkout - uses: actions/checkout@v3 - 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 ./... diff --git a/.github/workflows/gotip.yml b/.github/workflows/gotip.yml deleted file mode 100644 index d85ccf4..0000000 --- a/.github/workflows/gotip.yml +++ /dev/null @@ -1,46 +0,0 @@ -on: - workflow_dispatch: - pull_request: - types: [opened, reopened, ready_for_review, synchronize] - push: - branches: - - main - - master -name: Test Go tip -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - name: Install Go tip - run: | - go install golang.org/dl/gotip@latest - gotip download - gotip version - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - id: Cache - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod # Module download cache - ~/.cache/go-build # Build cache (Linux) - key: ubuntu-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ubuntu-go- - - name: Dependencies - run: gotip mod download - if: steps.cache.outputs.cache-hit != 'true' - - name: Test - run: gotip test ./... - - name: Test 32 bit - env: - GOARCH: 386 - run: gotip test ./... - - name: Test with race detector - run: gotip test -race ./... diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0677fe..8a9de41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,39 +11,59 @@ jobs: test: strategy: matrix: - go-version: [1.19.x, 1.20.x] os: ["ubuntu", "windows", "macos"] runs-on: ${{ matrix.os }}-latest steps: - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - id: Cache - uses: actions/cache@v3 + + - name: Install Go + uses: actions/setup-go@v4 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' + go-version-file: 'go.mod' + + - name: Get StaticCheck + if: ${{ matrix.os == 'ubuntu' }} + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Gomod + if: ${{ matrix.os == 'ubuntu' }} + 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: ${{ matrix.os == 'ubuntu' && (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: ${{ matrix.os == 'ubuntu' && (success() || failure()) }} # run this step even if the previous one failed + run: go vet ./... + + - name: StaticCheck + if: ${{ matrix.os == 'ubuntu' && (success() || failure()) }} # run this step even if the previous one failed + run: staticcheck ./... + - 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 ./... diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 91f3bc6..e7eb5cb 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -1,15 +1,18 @@ name: Bump version on: workflow_dispatch: - push: - branches: - - main - - master + workflow_run: + workflows: ["Run tests"] + types: + - completed + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + - name: Bump version and push tag id: tag_version uses: mathieudutour/github-tag-action@v6.1