From 114812c70e08f3c8ae7f7640f5b595c9c9749e84 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 3 Oct 2026 18:42:09 +0100 Subject: [PATCH] feat(autoupdate): update only the directories that are tested Renovate updated every go.mod and package.json in a repo, while the tests cover one module and one Node project. An update outside them would merge untested. Restrict the managers to the configured directories, and add go and node switches for a repo that has no Go code or no frontend to test. --- .github/workflows/renovate-autoupdate.yaml | 34 ++++++++++++++++++---- README.md | 8 +++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/renovate-autoupdate.yaml b/.github/workflows/renovate-autoupdate.yaml index 8ca2db6..00ee4df 100644 --- a/.github/workflows/renovate-autoupdate.yaml +++ b/.github/workflows/renovate-autoupdate.yaml @@ -13,8 +13,13 @@ on: required: false type: string default: ">=1.24" + go: + description: "Update and test the Go module. Turn off for a repo with no Go code." + required: false + type: boolean + default: true go-working-directory: - description: "Directory that holds go.mod" + description: "Directory that holds go.mod. Only this module is updated and tested." required: false type: string default: "." @@ -23,8 +28,13 @@ on: required: false type: string default: "22" + node: + description: "Update and test the Node project. Turn off for a repo with no frontend to test." + required: false + type: boolean + default: true node-working-directory: - description: "Directory that holds package.json" + description: "Directory that holds package.json. Only this project is updated and tested." required: false type: string default: "." @@ -106,6 +116,10 @@ jobs: env: MIN_AGE: ${{ inputs.minimum-release-age }} MAJOR_UPDATES: ${{ inputs.major-updates }} + USE_GO: ${{ inputs.go }} + USE_NODE: ${{ inputs.node }} + GO_DIR: ${{ inputs.go-working-directory }} + NODE_DIR: ${{ inputs.node-working-directory }} CONFIG_FILE: ${{ runner.temp }}/renovate-autoupdate-config.json run: | jq -n \ @@ -113,14 +127,22 @@ jobs: --arg age "$MIN_AGE" \ --arg branch_prefix "${BATCH_BRANCH%%/*}/" \ --arg majors "$MAJOR_UPDATES" \ + --argjson use_go "$USE_GO" \ + --argjson use_node "$USE_NODE" \ + --arg go_dir "$GO_DIR" \ + --arg node_dir "$NODE_DIR" \ ' + # A regex for files directly inside a directory, so only what the tests cover is updated. + def prefix($d): (if $d == "." or $d == "" then "" else ($d | ltrimstr("./") | rtrimstr("/")) + "/" end) | gsub("\\."; "\\."); { platform: "github", repositories: [$repo], onboarding: false, requireConfig: "optional", branchPrefix: $branch_prefix, - enabledManagers: ["gomod", "npm"], + enabledManagers: ((if $use_go then ["gomod"] else [] end) + (if $use_node then ["npm"] else [] end)), + gomod: {managerFilePatterns: ["/^" + prefix($go_dir) + "go\\.mod$/"]}, + npm: {managerFilePatterns: ["/^" + prefix($node_dir) + "package\\.json$/", "/^" + prefix($node_dir) + "pnpm-workspace\\.yaml$/"]}, dependencyDashboard: false, # Branches only: with no dashboard, no PR is ever opened. The workflow opens it after the tests. prCreation: "approval", @@ -248,12 +270,14 @@ jobs: env: GO_DIR: ${{ inputs.go-working-directory }} NODE_DIR: ${{ inputs.node-working-directory }} + USE_GO: ${{ inputs.go }} + USE_NODE: ${{ inputs.node }} run: | go=false node=false pm=npm - if [ -f "$GO_DIR/go.mod" ]; then go=true; fi - if [ -f "$NODE_DIR/package.json" ]; then + if [ "$USE_GO" = true ] && [ -f "$GO_DIR/go.mod" ]; then go=true; fi + if [ "$USE_NODE" = true ] && [ -f "$NODE_DIR/package.json" ]; then node=true if [ -f "$NODE_DIR/pnpm-lock.yaml" ]; then pm=pnpm elif [ -f "$NODE_DIR/yarn.lock" ]; then pm=yarn diff --git a/README.md b/README.md index bee70c7..d51779e 100644 --- a/README.md +++ b/README.md @@ -137,9 +137,11 @@ The workflow finds `go.mod` and `package.json` itself and tests what exists. A r | Input | Default | Description | |-------|---------|-------------| | `go-version` | `>=1.24` | Go version | -| `go-working-directory` | `.` | Directory that holds `go.mod` | +| `go` | `true` | Update and test the Go module. Turn off for a repo with no Go code. | +| `go-working-directory` | `.` | Directory that holds `go.mod`. Only this module is updated and tested. | | `node-version` | `22` | Node.js version | -| `node-working-directory` | `.` | Directory that holds `package.json` | +| `node` | `true` | Update and test the Node project. Turn off for a repo with no frontend to test. | +| `node-working-directory` | `.` | Directory that holds `package.json`. Only this project is updated and tested. | | `node-scripts` | `lint,typecheck,test,build` | Scripts to run in order. A missing script is skipped. | | `require-node-tests` | `true` | Fail when there is no `test` script, so an untested update never merges | | `major-updates` | `separate` | `separate`: each major gets its own branch, tested and merged on its own. `batch`: majors join the batch. `ignore`: skip majors. | @@ -152,6 +154,8 @@ The workflow finds `go.mod` and `package.json` itself and tests what exists. A r **Failing updates.** The last 50 KB of the test output goes into a comment on one issue titled "Dependency updates failing tests". Each failing branch has its own comment, updated on every run, and a header with the commit and the run link. When a branch passes and merges, its comment is removed. When no failing branch is left, the issue closes. The output is also in the run summary. Without `issues: write` the run still works, but the issue is skipped. +**Only what is tested is updated.** Renovate manages one Go module and one Node project: the ones in `go-working-directory` and `node-working-directory`. A second `package.json` (docs, e2e tests, another frontend) or a second `go.mod` is left alone, because nothing would test its updates. + **Branches run one at a time**, so each one is tested on top of the ones merged before it. A branch that conflicts with the default branch is skipped, and Renovate rebases it on the next run. **Package manager.** pnpm is used when `pnpm-lock.yaml` exists, yarn for `yarn.lock`, otherwise npm. The install step never changes the lockfile (`--frozen-lockfile`, `--immutable`, `npm ci`), so a lockfile that does not match `package.json` fails the run. pnpm and yarn run through Corepack, so set `packageManager` in `package.json`.