Skip to content
Hands-on IT IT Drills

Day 13: Monorepos, lockfiles and PR design

Goal: You maintain a monorepo with npm workspaces and a Go service, with rules per directory, clean lockfiles, meaningful PRs and an additional release branch. · Duration: approx. 120 min · Prerequisite: Day 3, Day 4

Briefing

  • Renovate recognizes npm workspaces by the workspaces field and always regenerates the shared package-lock.json in the root directory.
  • If the same dependency appears in several workspaces, you get one branch and one PR for all occurrences.
  • matchFileNames plus template variables like {{parentDir}} give each directory its own labels, branch prefixes and commit scopes.
  • lockFileMaintenance refreshes transitive versions, gomodTidy cleans up go.sum.
  • baseBranchPatterns additionally maintains release branches, with separate PRs per branch.
 shop-mono/
 ├── package.json               workspaces: ["packages/*"]  ─┐
 ├── package-lock.json          one lockfile for all          │ manager npm
 ├── packages/api/package.json  express, lodash               │
 ├── packages/web/package.json  dayjs, lodash                ─┘
 └── services/worker/go.mod     manager gomod, artifact go.sum

Drill 1: Creating the monorepo

The worker is the Go service from Day 3, just under a new module path. The lockfile is deliberately old (summer 2023), so that there is something to refresh later.

source ~/renovate-lab/setup/env.sh
export RENOVATE_GITHUB_COM_TOKEN=$(gh auth token)   # optional, release notes
mkdir -p ~/renovate-lab/tag13 && cd ~/renovate-lab/tag13
cp -R ~/renovate-lab/code/tag13/shop-mono start-shop-mono
git -C start-shop-mono init -q -b main
git -C start-shop-mono add -A
git -C start-shop-mono commit -qm "Initialer Stand"
git -C start-shop-mono push -q forgejo:shop/shop-mono.git main
R="$FORGEJO/api/v1/repos/shop/shop-mono"
git clone -q forgejo:shop/shop-mono.git
cd shop-mono
cat renovate.json

Expected (abridged):

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "prHourlyLimit": 0,
  "prConcurrentLimit": 0
}

What does Renovate find?

cd ~/renovate-lab/tag13
renovate --dry-run=extract --report-type=file --report-path=extract.json \
  shop/shop-mono > /dev/null
jq -c '.repositories[].packageFiles | keys' extract.json
jq -r '.repositories[].packageFiles[][] | "\(.packageFile) \(.lockFiles)"' extract.json
jq -c '.repositories[].packageFiles.npm[0].managerData.workspaces' extract.json

Expected:

["gomod","npm"]
services/worker/go.mod null
package.json ["package-lock.json"]
packages/api/package.json ["package-lock.json"]
packages/web/package.json ["package-lock.json"]
["packages/*"]

Three package.json files, but only one lockfile, which all three reference. go.sum is not a lockFile in the report; gomod treats it as an artifact (Day 3).

Save your progress? Sign up for free

Drill 2: Workspaces – one update, one PR

LOG_LEVEL=debug renovate shop/shop-mono > lauf1.log 2>&1
grep -oE "Generating package-lock.json for [^ ]+" lauf1.log | sort | uniq -c
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | cut -c1-88
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("lodash")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N/files" \
  | jq -r '.[] | "\(.filename) +\(.additions) -\(.deletions)"'

Expected:

   5 Generating package-lock.json for .
#1 main <- dayjs-1.x  Update dependency dayjs to v1.11.23
#2 main <- github.com-pkg-errors-0.x  Update module github.com/pkg/errors to v0.9.1
#3 main <- express-4.x  Update dependency express to v4.22.3
#4 main <- lodash-monorepo  Update dependency lodash to v4.18.1
#5 main <- prettier-3.x  Update dependency prettier to v3.9.10
#6 main <- github.com-google-uuid-1.x  Update module github.com/google/uuid to v1.6.0
#7 main <- github.com-joho-godotenv-1.x  Update module github.com/joho/godotenv to v1.5.
#8 main <- express-5.x  Update dependency express to v5
package-lock.json +5 -5
packages/api/package.json +1 -1
packages/web/package.json +1 -1

Your target versions will be newer. What matters is the structure:

  • Five npm branches, five times npm install --package-lock-only in the root directory (for .), never in packages/api.
  • PR #4 changes both workspaces and the shared lockfile in one commit. The branch name lodash-monorepo comes from group:monorepos in config:recommended. Without the group, the branch is called renovate/lodash-4.x and likewise contains both workspaces: same branch name, one branch.
  • Issue #9 is the Dependency Dashboard (Forgejo numbers issues and PRs together).

Save your progress? Sign up for free

Drill 3: Rules per directory

The worker belongs to a different team. Its PRs should get their own labels and their own branch prefix. {{parentDir}} is the name of the directory of the package file (worker); {{packageFileDir}} would be the full path (services/worker). Forgejo silently discards unknown labels; mklabels creates them beforehand.

for l in deps web worker go backport; do
  curl -s -u "$ADMIN" -X POST --json "{\"name\":\"$l\",\"color\":\"#1d76db\"}" \
    "$R/labels" | jq -r .name
done
cd ~/renovate-lab/tag13/shop-mono
cat > renovate.json <<'EOF'
{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "prHourlyLimit": 0,
  "prConcurrentLimit": 0,
  "labels": ["deps"],
  "packageRules": [
    {
      "description": "Go-Worker",
      "matchFileNames": ["services/worker/**"],
      "addLabels": ["worker", "go"],
      "additionalBranchPrefix": "{{parentDir}}-"
    },
    {
      "description": "Web-Frontend",
      "matchFileNames": ["packages/web/**"],
      "addLabels": ["web"]
    }
  ]
}
EOF
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Regeln pro Verzeichnis"
git push -q origin HEAD
cd .. && renovate shop/shop-mono 2>&1 | grep -oE "PR created|Autoclosing PR" \
  | sort | uniq -c
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | grep worker | cut -c1-88
curl -s -u "$ADMIN" "$R/pulls?state=closed" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | cut -c1-88
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("dayjs")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("lodash")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'

Expected:

deps web worker go backport
   3 Autoclosing PR
   3 PR created
#10 main <- worker-github.com-pkg-errors-0.x  Update module github.com/pkg/errors to v0.
#11 main <- worker-github.com-google-uuid-1.x  Update module github.com/google/uuid to v
#12 main <- worker-github.com-joho-godotenv-1.x  Update module github.com/joho/godotenv 
#2 main <- refs/pull/2/head  Update module github.com/pkg/errors to v0.9.1 - autoclosed
#6 main <- refs/pull/6/head  Update module github.com/google/uuid to v1.6.0 - autoclosed
#7 main <- refs/pull/7/head  Update module github.com/joho/godotenv to v1.5.1 - autoclos
#1 labels=deps,web assignees= reviewers=
#4 labels=deps,web assignees= reviewers=
#10 labels=deps,go,worker assignees= reviewers=
  • labels applies to all, addLabels adds per directory (Day 2).
  • The lodash PR #4 gets web because one of its two upgrades lives in packages/web. One matching occurrence is enough.
  • A new branch name means a new branch: Renovate opens new PRs and closes the old ones with “- autoclosed”. So don’t change branch prefixes casually in a repo full of open PRs.

Save your progress? Sign up for free

Drill 4: Cleaning up go.sum with gomodTidy

On Day 3 you saw that go get leaves the old checksums in go.sum. postUpdateOptions: ["gomodTidy"] runs go mod tidy afterwards.

B=renovate/worker-github.com-pkg-errors-0.x
curl -s -u "$ADMIN" "$R/raw/services/worker/go.sum?ref=$B" | grep pkg/errors | cut -c1-50
cd shop-mono
jq '(.packageRules[] | select(.description == "Go-Worker"))
  += {postUpdateOptions: ["gomodTidy"]}' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Worker: go mod tidy"
git push -q origin HEAD
cd ..
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -r .body > pr.md
sed -i '' 's/- \[ \] <!-- rebase-check/- [x] <!-- rebase-check/' pr.md
jq -Rs '{body: .}' pr.md > pr.json
curl -s -u "$ADMIN" -X PATCH --json @pr.json "$R/pulls/$N" | jq -r .number
LOG_LEVEL=debug renovate shop/shop-mono > lauf3.log 2>&1
grep -E "Branch updated|\"command\": \"go" lauf3.log | uniq | cut -c1-80
curl -s -u "$ADMIN" "$R/raw/services/worker/go.sum?ref=$B" | grep pkg/errors | cut -c1-50

Expected:

github.com/pkg/errors v0.9.0 h1:J8lpUdobwIeCI7OiSx
github.com/pkg/errors v0.9.0/go.mod h1:bwawxfHBFNV
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7q
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV
10
       "command": "go get -t ./...",
       "command": "go mod tidy",
 INFO: Branch updated (repository=shop/shop-mono, branch=renovate/worker-github.
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7q
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV

Four lines before, two after: the checksums for v0.9.0 are gone. A changed config alone does not rebuild existing branches (the debug log says “Branch does not need rebasing”). Only the rebase checkbox in the PR body forces the rebuild; the other two worker PRs follow at the next conflict or rebase.

Save your progress? Sign up for free

Drill 5: Lock file maintenance

Direct dependencies are pinned exactly, but their transitive dependencies are not. lockFileMaintenance rebuilds the lockfile completely. The default schedule is “before 4am on monday”; for the lab it is “at any time”.

cd shop-mono
jq '.lockFileMaintenance = {enabled: true, schedule: ["at any time"]}' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Lock file maintenance"
git push -q origin HEAD
cd .. && renovate shop/shop-mono 2>&1 | grep "PR created" | cut -c1-80
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("Lock file")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | grep -i lock
sleep 5
curl -s -u "$ADMIN" "$R/pulls/$N/files" \
  | jq -r '.[] | "\(.filename) +\(.additions) -\(.deletions)"'
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -r .body | sed -n 3,6p

Expected:

 INFO: PR created (repository=shop/shop-mono, branch=renovate/lock-file-maintena
#13 main <- lock-file-maintenance  Lock file maintenance
package-lock.json +200 -41
#13 labels=deps,web assignees= reviewers=
| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |

What changed? A version comparison of both lockfiles:

curl -s -u "$ADMIN" "$R/raw/package-lock.json?ref=main" > main.lock
curl -s -u "$ADMIN" "$R/raw/package-lock.json?ref=renovate/lock-file-maintenance" > lfm.lock
jq -rn --slurpfile a main.lock --slurpfile b lfm.lock '
  $a[0].packages as $alt | $b[0].packages | to_entries[]
  | select($alt[.key] and $alt[.key].version != .value.version)
  | "\(.key | ltrimstr("node_modules/")): \($alt[.key].version) -> \(.value.version)"'

Expected:

function-bind: 1.1.1 -> 1.1.2
get-intrinsic: 1.2.1 -> 1.3.0
has-symbols: 1.0.3 -> 1.1.0
object-inspect: 1.12.3 -> 1.13.4
proxy-addr: 2.0.7 -> 2.0.8
side-channel: 1.0.4 -> 1.1.1

On top of that come 13 new transitive packages. No package.json changes. Two details:

  • The PR contains all npm package files, which is why the web rule applies as well.
  • There is no lockfile maintenance for go.sum: the gomod manager does not support lockFileMaintenance; only npm, Cargo, Poetry, Bundler, Helm and others with a real lockfile do.

Save your progress? Sign up for free

Drill 6: Semantic commits

With semanticCommits: "auto" (default), Renovate looks at the Git history. Here you set it explicitly and assign type and scope per directory. commitMessagePrefix replaces the semantic prefix completely.

cd shop-mono
jq '.semanticCommits = "enabled"
  | (.packageRules[] | select(.description == "Go-Worker"))
      += {semanticCommitType: "build", semanticCommitScope: "worker"}
  | .packageRules += [
      {description: "Workspaces", matchFileNames: ["packages/**"],
       semanticCommitScope: "{{parentDir}}"},
      {description: "Majors", matchUpdateTypes: ["major"],
       commitMessagePrefix: "feat(deps)!:"}]' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Semantische Commits"
git push -q origin HEAD
cd .. && renovate shop/shop-mono 2>&1 | grep -c "PR updated"
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | cut -c1-88
curl -s -u "$ADMIN" "$R/commits?sha=renovate/dayjs-1.x&limit=1" | jq -r '.[0].commit.message'

Expected:

9
#1 main <- dayjs-1.x  fix(web): update dependency dayjs to v1.11.23
#3 main <- express-4.x  fix(api): update dependency express to v4.22.3
#4 main <- lodash-monorepo  fix(web): update dependency lodash to v4.18.1
#5 main <- prettier-3.x  chore(deps): update dependency prettier to v3.9.10
#8 main <- express-5.x  feat(deps)!: Update dependency express to v5
#10 main <- worker-github.com-pkg-errors-0.x  build(worker): update module github.com/pk
#11 main <- worker-github.com-google-uuid-1.x  build(worker): update module github.com/g
#12 main <- worker-github.com-joho-godotenv-1.x  build(worker): update module github.com
#13 main <- lock-file-maintenance  chore(web): lock file maintenance
Update dependency dayjs to v1.11.23
  • fix for dependencies, chore for the rest: this comes from :semanticPrefixFixDepsChoreOthers in config:recommended. The worker rule comes later and wins with build.
  • The scope is {{parentDir}}, i.e. api or web. prettier lives in the root package.json; the rule does not match there, so it stays at the default deps.
  • With a custom commitMessagePrefix, the lowercasing is dropped, hence “Update”.
  • Renovate only updated the PR titles. The commit message in the branch stays old until the next rebuild.

Warning: Tools like semantic-release treat fix: as a patch release. If you don’t want releases for dependency updates, set semanticCommitType: "chore" for all of them.

Save your progress? Sign up for free

Drill 7: Commit message and PR body

The commit message is composed of {{commitMessagePrefix}} {{commitMessageAction}} {{commitMessageTopic}} {{commitMessageExtra}} {{commitMessageSuffix}}. The PR title inherits from it. First the attempt to set the title directly:

cd ~/renovate-lab/tag13/shop-mono
jq '(.packageRules[] | select(.description == "Go-Worker"))
  += {prTitle: "Worker: {{{depName}}} auf {{{newValue}}}"}' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json > ../val.log; echo "exit=$?"
grep -oE '"message": .{0,60}' ../val.log
git checkout -q renovate.json

Expected:

exit=1
"message": "Direct editing of prTitle is now deprecated. Please edit co

prTitle is deprecated; ship would abort here. Instead, you change the building blocks. On top of that come a fixed note in the PR body (prBodyNotes) and a custom table column (prBodyColumns with prBodyDefinitions).

jq '.commitMessageAction = "Bump"
  | .prBodyNotes = ["Betreut von Team Shop, Fragen im Kanal #shop-deps."]
  | .prBodyDefinitions = {Datei: "`{{{packageFile}}}`"}
  | (.packageRules[] | select(.description == "Go-Worker")) += {
      commitMessageTopic: "{{{depName}}}",
      commitMessageExtra: "{{{currentValue}}} -> {{{newValue}}}"}
  | .packageRules += [{description: "PR-Tabelle", matchPackageNames: ["*"],
      prBodyColumns: ["Package", "Change", "Datei"]}]' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Commit-Nachricht und PR-Text"
git push -q origin HEAD
cd ..
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -r .body > pr.md
sed -i '' 's/- \[ \] <!-- rebase-check/- [x] <!-- rebase-check/' pr.md
jq -Rs '{body: .}' pr.md > pr.json
curl -s -u "$ADMIN" -X PATCH --json @pr.json "$R/pulls/$N" | jq -r .number
renovate shop/shop-mono 2>&1 | grep -E "Branch updated" | cut -c1-80
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | grep -E "#(1|8|10) " | cut -c1-88
curl -s -u "$ADMIN" "$R/commits?sha=renovate/worker-github.com-pkg-errors-0.x&limit=1" | jq -r '.[0].commit.message'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -r .body | sed -n 3,7p | cut -c1-88

Expected:

10
 INFO: Branch updated (repository=shop/shop-mono, branch=renovate/worker-github.
#1 main <- dayjs-1.x  fix(web): bump dependency dayjs to v1.11.23
#8 main <- express-5.x  feat(deps)!: Bump dependency express to v5
#10 main <- worker-github.com-pkg-errors-0.x  build(worker): bump github.com/pkg/errors 
build(worker): bump github.com/pkg/errors v0.9.0 -> v0.9.1

| Package | Change | Datei |
|---|---|---|
| [github.com/pkg/errors](https://github.com/pkg/errors) | `v0.9.0` → `v0.9.1` | `servic

Betreut von Team Shop, Fragen im Kanal #shop-deps.

Why is prBodyColumns in a packageRule instead of at the top? config:recommended brings along, via mergeConfidence:age-confidence-badges, a rule with its own columns (Age, Confidence). Rules override the top-level values, and a later rule of your own overrides the preset rule. The table merges identical packages into one row: the lodash PR lists only one file, although it changes two.

Save your progress? Sign up for free

Drill 8: Reviewers and assignees

On Forgejo, Renovate sets reviewers via the API’s requested_reviewers. The people need at least read access to the repo.

docker exec forgejo forgejo admin user create --username alice \
  --password lab-alice-pw-123 --email [email protected] --must-change-password=false
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X PUT \
  "$R/collaborators/alice" --json '{"permission":"read"}'
cd shop-mono
jq '.reviewers = ["alice"]
  | (.packageRules[] | select(.description == "Go-Worker")) += {assignees: ["alice"]}' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Reviewer und Assignees"
git push -q origin HEAD
cd .. && LOG_LEVEL=debug renovate shop/shop-mono > lauf5.log 2>&1
grep -c "addParticipants" lauf5.log; grep -c "Processing existing PR" lauf5.log
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("dayjs")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'

Expected:

New user 'alice' has been successfully created!
0
9
#10 labels=deps,go,worker assignees= reviewers=
#1 labels=deps,web assignees= reviewers=

Nothing happens, and that is correct: Renovate only sets reviewers and assignees when creating a PR. Existing PRs remain untouched, as do PRs with automerge (unless assignAutomerge: true is set or the status is red). The next drill creates new PRs.

Save your progress? Sign up for free

Drill 9: Maintaining a release branch too

baseBranchPatterns (formerly baseBranches) takes names and regexes. For every matching branch, Renovate runs through completely. Switching over a repo full of open PRs after the fact is turbulent (see the warning below). That is why you set up shop-mono from scratch, right away with the finished config from Drills 3 to 8 plus baseBranchPatterns.

cd ~/renovate-lab/tag13
rm -rf neu && cp -R ~/renovate-lab/code/tag13/shop-mono neu
cp ~/renovate-lab/code/tag13/renovate.json neu/
grep baseBranch neu/renovate.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$R"
git -C neu init -q -b main
git -C neu add -A
git -C neu commit -qm "Initialer Stand"
git -C neu push -q forgejo:shop/shop-mono.git main
for l in deps web worker go backport; do
  curl -s -u "$ADMIN" -X POST --json "{\"name\":\"$l\",\"color\":\"#1d76db\"}" \
    "$R/labels" | jq -r .name
done
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X PUT \
  "$R/collaborators/alice" --json '{"permission":"read"}'
curl -s -u "$ADMIN" -X POST "$R/branches" \
  --json '{"new_branch_name":"release/1.x","old_branch_name":"main"}' | jq -r .name
LOG_LEVEL=debug renovate shop/shop-mono > lauf6.log 2>&1
grep -A1 '"baseBranches"' lauf6.log | head -2
grep -c " INFO: PR created" lauf6.log
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[].base.ref' | sort | uniq -c
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r 'sort_by(.number)[] | "#\(.number) \(.base.ref) <- \(.head.ref)  \(.title)"' \
  | grep dayjs | cut -c1-88
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("pkg/errors.*release")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("dayjs.*release")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'

Expected:

  "baseBranchPatterns": ["main", "/^release\\/.+/"],
deps web worker go backport
release/1.x
DEBUG: baseBranches (repository=shop/shop-mono)
       "baseBranches": ["main", "release/1.x"]
18
   9 main
   9 release/1.x
#2 main <- main-dayjs-1.x  fix(web): bump dependency dayjs to v1.11.23 (main)
#11 release/1.x <- release/1.x-dayjs-1.x  fix(web): bump dependency dayjs to v1.11.23 (r
#10 labels=deps,go,worker assignees=alice reviewers=alice
#11 labels=deps,web assignees= reviewers=alice
  • Every update exists twice. Branch names get the target branch as a prefix (renovate/main-…, renovate/release/1.x-…), titles a suffix (main) or (release/1.x).
  • New PRs get the reviewer alice; worker PRs additionally get the assignee.
  • Renovate reads the config only from the default branch. If every release branch should have its own renovate.json, there is useBaseBranchConfig: "merge".

Warning: Observed live when switching over a repo with open PRs: in the first run, Renovate takes over the old branches (debug “Found existing branch with branchPrefixOld”), retargets PRs to release/1.x and closes them as “autoclosed”. Only the second run opens clean PRs for both branches. Make such a switch with an empty PR list, or announce the wave.

Save your progress? Sign up for free

Checkpoint

The extract found three package.json files and one go.mod:

cd ~/renovate-lab/tag13
R="$FORGEJO/api/v1/repos/shop/shop-mono"
jq '[.repositories[].packageFiles[][]] | length' extract.json

Expected:

4

The open PRs: lock file maintenance, semantic titles with scope worker, PRs against both base branches:

curl -s -u "$ADMIN" "$R/pulls" | jq -r '.[] | "\(.base.ref) \(.title)"' | sort

Expected (abridged):

R13_KP1

The lodash PR changes both workspaces and the root lockfile; alice is a reviewer on the dayjs PR:

N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("lodash.*main")) | .number')
curl -s -u "$ADMIN" "$R/pulls/$N/files" | jq -r '.[].filename'
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("dayjs.*main")) | .number')
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '[.requested_reviewers[].login]'

Expected:

R13_KP2

go.sum in the worker PR no longer contains the leftover v0.9.0 (gomodTidy):

B=renovate/main-worker-github.com-pkg-errors-0.x
curl -s -u "$ADMIN" "$R/raw/services/worker/go.sum?ref=$B" | grep -c 'errors v0.9.0'

Expected:

0

Challenge

Only patch updates should land on release/1.x from now on, with the additional label backport, and there should be no lockfile maintenance there. main stays unchanged.

Hint: matchBaseBranches exists in packageRules. Without separateMinorPatch, the patch is part of the minor update and disappears along with it.

Solution

The complete config is in ~/renovate-lab/code/tag13/challenge/renovate.json.

cd ~/renovate-lab/tag13 && rm -rf shop-mono
git clone -q forgejo:shop/shop-mono.git
cd shop-mono
jq '.packageRules += [
  {description: "Release: Patches einzeln, Label backport",
   matchBaseBranches: ["/^release\\/.+/"],
   separateMinorPatch: true, addLabels: ["backport"]},
  {description: "Release: keine Minor/Major, keine Lockfile-Pflege",
   matchBaseBranches: ["/^release\\/.+/"],
   matchUpdateTypes: ["major", "minor", "lockFileMaintenance"], enabled: false}]' renovate.json > tmp.json
mv tmp.json renovate.json
renovate-config-validator --no-global renovate.json >/dev/null
git add -A
git commit -qm "Release-Branch: nur Patches"
git push -q origin HEAD
cd .. && renovate shop/shop-mono 2>&1 | grep -oE "PR created|Autoclosing PR" \
  | sort | uniq -c
curl -s -u "$ADMIN" "$R/pulls?state=open&limit=50" \
  | jq -r '.[] | select(.base.ref == "release/1.x") | .title' | sort
curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[].base.ref' | sort | uniq -c
N=$(curl -s -u "$ADMIN" "$R/pulls" \
  | jq -r '.[] | select(.title | test("dayjs.*release")) | .number' | tail -1)
curl -s -u "$ADMIN" "$R/pulls/$N" | jq -c '{labels: [.labels[].name],
  assignees: [.assignees[]?.login], reviewers: [.requested_reviewers[]?.login]}'

Expected:

   9 Autoclosing PR
   6 PR created
build(worker): bump github.com/google/uuid v1.3.0 -> v1.3.1 (release/1.x)
build(worker): bump github.com/pkg/errors v0.9.0 -> v0.9.1 (release/1.x)
chore(deps): bump dependency prettier to v3.0.3 (release/1.x)
fix(api): bump dependency express to v4.18.3 (release/1.x)
fix(web): bump dependency dayjs to v1.11.23 (release/1.x)
fix(web): bump dependency lodash to v4.17.23 (release/1.x)
   9 main
   6 release/1.x
#24 labels=backport,deps,web assignees= reviewers=alice

All nine old release PRs are closed, because separateMinorPatch changes the branch names (express-4.18.x instead of express-4.x). Six patch PRs replace them, and the lockfile maintenance on release/1.x is gone. On main everything stays as it was.

Save your progress? Sign up for free

Enterprise Note

  • Instead of fixed reviewers lists, teams maintain a CODEOWNERS file and use reviewersFromCodeOwners: true. When people change, only one file changes.
  • Lockfile maintenance belongs in a fixed time window (default Mondays before 4 a.m.) and, with green CI, is a good automerge candidate (Day 5).
  • In large monorepos, every npm branch regenerates the entire lockfile. Plan for run time, cache and branchConcurrentLimit (Day 4, Day 9).
  • Align semanticCommitType with the release tooling: fix(deps) triggers a patch release in semantic-release.
  • Release branches double the PR load. Limit them via matchBaseBranches to patches and security updates, and clean up baseBranchPatterns when a release reaches end of life.