From 5083734ac9b2cebaa8c71c8fda8fa46e1b35ba96 Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:24:33 +0200 Subject: [PATCH] ci: check for go mod tidy (#741) This ensures that go.mod is always tidied. --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ renovate.json | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6119373c..6f9081bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,3 +69,23 @@ jobs: - if: failure() run: echo "::error::Check failed, please run 'go generate ./...' and commit the changes." + + go-mod-tidy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Run go mod tidy + run: go mod tidy + + - name: Check uncommitted changes + run: git diff --exit-code + + - if: failure() + run: echo "::error::Check failed, please run 'go mod tidy' and commit the changes." diff --git a/renovate.json b/renovate.json index 5805c99a..5b7ccc2c 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,5 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>hetznercloud/.github//renovate/default"] + "extends": ["github>hetznercloud/.github//renovate/default"], + "postUpdateOptions": ["gomodTidy"] }