From b83f86b976cfeb216edc3044f9e201358704d48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20=C5=BDivkovi=C4=87?= Date: Thu, 21 Dec 2023 13:36:06 +0100 Subject: [PATCH] ci: add Dependabot recursive go mod tidy support (#1412) ## Description This PR introduces a simple workflow that tidies go mod files on Dependabot PRs, and turns off the mod check for those PRs (to avoid overlapping workflows).
Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--------- Co-authored-by: Guilhem Fanton <8671905+gfanton@users.noreply.github.com> Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com> --- .github/workflows/dependabot-tidy.yml | 41 +++++++++++++++++++++++++++ .github/workflows/lint.yml | 3 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dependabot-tidy.yml diff --git a/.github/workflows/dependabot-tidy.yml b/.github/workflows/dependabot-tidy.yml new file mode 100644 index 00000000000..e13390fa831 --- /dev/null +++ b/.github/workflows/dependabot-tidy.yml @@ -0,0 +1,41 @@ +name: Dependabot Tidy Go Mods + +on: + pull_request: + paths: + - '.github/workflows/**' + - '**/go.mod' + - '**/go.sum' + +jobs: + tidy_go_mods: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: 1.21.x + + - name: Tidy all Go mods + run: | + set -e + # Find all go.mod files + gomods=$(find . -type f -name go.mod) + + # Tidy each go.mod file + for modfile in $gomods; do + dir=$(dirname "$modfile") + + # Run go mod tidy in the directory + (cd "$dir" && go mod tidy -v) || exit 1 + done + + - name: Commit changes, if any + uses: stefanzweifel/git-auto-commit-action@v5 + with: + skip_dirty_check: false # Enable dirty check, and skip unnecessary committing + commit_message: "Run 'go mod tidy' via GitHub Actions" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a4c5b6dc85e..b874159473e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -58,8 +58,9 @@ jobs: else echo 'Succeeded.' fi - modtidy: + mod_tidy_check: runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} steps: - name: Checkout code uses: actions/checkout@v4