From 7823d0b0801998cc9e76f667c8e3ffebff556328 Mon Sep 17 00:00:00 2001 From: Jimmi Dyson Date: Thu, 3 Nov 2022 13:58:58 +0000 Subject: [PATCH] ci: Refactor checks to remove more asdf stuff --- .github/workflows/checks.yml | 47 +++++++++++++++++++++--------------- .pre-commit-config.yaml | 11 +++------ .tool-versions | 1 + 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b0a955ce..4dd7f134 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -46,9 +46,6 @@ jobs: - name: Install asdf uses: asdf-vm/actions/setup@v1 - - name: Install go - run: make install-tool.golang - - name: Run e2e tests run: make e2e-test @@ -58,28 +55,22 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Output required tool versions - id: tool-versions - run: | - echo "go=$(grep -E '^golang ' .tool-versions | cut -d' ' -f2 | sed -e 's/^\([0-9]\+\.[0-9]\+\)$/\1.0/')" >> $GITHUB_OUTPUT - echo "golangci-lint=v$(grep -E '^golangci-lint ' .tool-versions | cut -d' ' -f2)" >> $GITHUB_OUTPUT - - - uses: actions/setup-go@v3 - with: - go-version: ${{ steps.tool-versions.outputs.go }} - check-latest: false - cache: true - - name: Ensure dummy skopeo files run: make ensure-static-skopeo env: SKIP_ASDF_CHECK: 1 + - name: Gather tool versions + uses: endorama/asdf-parse-tool-versions@v1 + id: versions + - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: reviewdog/action-golangci-lint@v2 with: - version: ${{ steps.tool-versions.outputs.golangci-lint }} - only-new-issues: ${{ github.event_name == 'pull_request' }} + fail_on_error: true + reporter: github-pr-review + go_version: ${{ fromJson(steps.versions.outputs.tools).golangci }} + golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }} pre-commit: runs-on: ubuntu-latest @@ -87,8 +78,24 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Install asdf - uses: asdf-vm/actions/setup@v1 + - name: Ensure dummy skopeo files + run: make ensure-static-skopeo + env: + SKIP_ASDF_CHECK: 1 + + - name: Gather tool versions + uses: endorama/asdf-parse-tool-versions@v1 + id: versions + + - uses: actions/setup-go@v3 + with: + go-version: ${{ fromJson(steps.versions.outputs.tools).golang }} + check-latest: false + cache: true + + - uses: mfinelli/setup-shfmt@v2 + with: + shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }} - uses: pre-commit/action@v3.0.0 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 076546c2..b2c7e321 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,19 +4,16 @@ repos: - repo: local hooks: - - id: go-mod-tidy - name: go mod tidy - entry: make mod-tidy - files: "(.*\\.go|go.mod|go.sum)$" - language: system - stages: [commit] - pass_filenames: false - id: golangci-lint name: golangci-lint entry: make lint language: system files: "(.*\\.go|go.mod|go.sum)$" pass_filenames: false +- repo: https://github.com/tekwizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-mod-tidy-repo - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: diff --git a/.tool-versions b/.tool-versions index fc65d82b..6a82ff59 100644 --- a/.tool-versions +++ b/.tool-versions @@ -6,3 +6,4 @@ golang 1.19.2 helm 3.10.1 pre-commit 2.20.0 upx 3.96 +shfmt 3.5.1