From 3dad76a6cc4c950067a4ff69e966b3517236a8b3 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 3 Mar 2023 10:40:09 +0000 Subject: [PATCH] Updated github workflows --- .github/workflows/autodep.yml | 2 +- .github/workflows/check.yml | 66 ++++++++++++++++----------------- .github/workflows/gotip.yml | 69 +++++++++++++++++------------------ .github/workflows/test.yml | 68 +++++++++++++++++----------------- 4 files changed, 102 insertions(+), 103 deletions(-) diff --git a/.github/workflows/autodep.yml b/.github/workflows/autodep.yml index 2ef3bfb..d69c03b 100644 --- a/.github/workflows/autodep.yml +++ b/.github/workflows/autodep.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ env.GO_VERSION }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2eb8c77..4e3a0f2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -4,7 +4,7 @@ env: on: workflow_dispatch: pull_request: - types: [opened, reopened,ready_for_review,synchronize] + types: [opened, reopened, ready_for_review, synchronize] push: branches: - main @@ -14,35 +14,35 @@ 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 ./... + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - name: Get StaticCheck + run: go install honnef.co/go/tools/cmd/staticcheck@2eef17617de2b0c8051063b2c590a6a91459a19a # Version 2023.1.2 (v0.4.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 ./... diff --git a/.github/workflows/gotip.yml b/.github/workflows/gotip.yml index b618b68..1835f9c 100644 --- a/.github/workflows/gotip.yml +++ b/.github/workflows/gotip.yml @@ -1,8 +1,7 @@ - on: workflow_dispatch: pull_request: - types: [opened, reopened,ready_for_review,synchronize] + types: [opened, reopened, ready_for_review, synchronize] push: branches: - main @@ -12,36 +11,36 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v2 - 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@v2 - with: - submodules: recursive - - id: Cache - uses: actions/cache@v2 - 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 ./... + - 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@v2 + with: + submodules: recursive + - id: Cache + uses: actions/cache@v2 + 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 cd181ae..0fbb658 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ on: workflow_dispatch: pull_request: - types: [opened, reopened,ready_for_review,synchronize] + types: [opened, reopened, ready_for_review, synchronize] push: branches: - main @@ -13,38 +13,38 @@ jobs: strategy: matrix: go-version: [1.19.x, 1.20.x] - os: [ "ubuntu", "windows", "macos" ] + 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 ./... + - name: Install Go + uses: actions/setup-go@v3 + 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 ./...