From 716ed0be613fa7cb829975defb132516414b8a14 Mon Sep 17 00:00:00 2001 From: Wen Bo Li <50884368+wenovus@users.noreply.github.com> Date: Fri, 11 Aug 2023 15:04:18 -0400 Subject: [PATCH] Use the automatic caching by setup-go and fix staticcheck caching (#1989) * Run static_analysis on main branch * trigger build to test caching --- .github/workflows/go.yml | 51 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 51 ------------------------------ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8bb6522c958..7dbb2b1614f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -47,3 +47,54 @@ jobs: uses: shogo82148/actions-goveralls@v1 with: path-to-profile: profile.cov + + static_analysis: + name: Static Analysis + runs-on: ubuntu-latest + steps: + - name: Install go + uses: actions/setup-go@v2 + with: + go-version: '1.19' + - name: Checkout code + uses: actions/checkout@v3 + - name: Cache + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/.cache/staticcheck + key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ github.job }}-${{ runner.os }}-go-build- + - name: Go vet + run: GOGC=30 go vet ./... + - name: Gofmt + run: | + # gofmt always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + if gofmt -d -s . | grep '^'; then + exit 1 + fi + - name: Get goimports + run: go install golang.org/x/tools/cmd/goimports@latest + - name: Goimports + run: | + # goimports always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + # + # goimports does not support "gofmt -s" so both goimports and gofmt are + # required. + if goimports -d . | grep '^'; then + exit 1 + fi + - name: Get revive + run: go install github.com/mgechev/revive@latest + - name: Run revive + run: revive ./... + - name: Get staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Run staticcheck + run: GOGC=30 staticcheck ./... diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fb1dbbf3755..141a200e01d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -45,57 +45,6 @@ jobs: exit 1 fi - static_analysis: - name: Static Analysis - runs-on: ubuntu-latest - steps: - - name: Install go - uses: actions/setup-go@v2 - with: - go-version: '1.19' - - name: Checkout code - uses: actions/checkout@v3 - - name: Cache - uses: actions/cache@v2 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/.cache/staticcheck - key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ github.job }}-${{ runner.os }}-go-build- - - name: Go vet - run: GOGC=30 go vet ./... - - name: Gofmt - run: | - # gofmt always returns true, so we use grep '^' which returns - # true on non-empty output, but will otherwise passthrough all - # output lines. - if gofmt -d -s . | grep '^'; then - exit 1 - fi - - name: Get goimports - run: go install golang.org/x/tools/cmd/goimports@latest - - name: Goimports - run: | - # goimports always returns true, so we use grep '^' which returns - # true on non-empty output, but will otherwise passthrough all - # output lines. - # - # goimports does not support "gofmt -s" so both goimports and gofmt are - # required. - if goimports -d . | grep '^'; then - exit 1 - fi - - name: Get revive - run: go install github.com/mgechev/revive@latest - - name: Run revive - run: revive ./... - - name: Get staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@latest - - name: Run staticcheck - run: GOGC=30 staticcheck ./... - otg_changes: name: OTG Changes Required runs-on: ubuntu-latest