From e4ceb0f9a4a113476d7f586914b654d6cbbb0336 Mon Sep 17 00:00:00 2001 From: rosstimothy <39066650+rosstimothy@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:42:04 -0400 Subject: [PATCH] Update lint action to catch any untidy go module (#44392) (#44457) * Update lint action to catch any untidy go module Due to integrations/terraform and integrations/event-handler importing teleport and replacing with ../.. any updates to go.mod need to be kept in sync with the integrations modules. The go mod tidiness check in the lint step only compared teleport and the api modules, which allowed things to get out of sync and possibly break integrations builds. The tidiness check now validates that any go module in the repository is tidy. --- .github/workflows/lint.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index ce166662b5867..8a39298975b5c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,12 +27,18 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Run `go mod tidy` - run: rm go.sum api/go.sum && go mod tidy && (cd api && go mod tidy) + - name: Check for untidy go modules + shell: bash + run: | + find . -path ./e -prune -o -name go.mod -print | while read f; do + echo "checking $f" + pushd $(dirname "$f") > /dev/null; + go mod tidy; + popd > /dev/null; + done - - name: Check for no changes after `go mod tidy` - # We have to add the current directory as a safe directory or else git commands will not work as expected. - run: git config --global --add safe.directory $( realpath . ) && git diff --exit-code -- go.mod go.sum api/go.mod api/go.sum + # We have to add the current directory as a safe directory or else git commands will not work as expected. + git config --global --add safe.directory $( realpath . ) && git diff --exit-code; - name: Set linter versions run: |