From 2267b21544edbc3b95e573d4bff7898374695dc3 Mon Sep 17 00:00:00 2001 From: Demo Date: Sun, 11 Oct 2026 21:50:03 +0200 Subject: [PATCH] Move script, example-configurations and results (formerly reports) into renovate/ --- .gitignore | 2 +- README.md | 26 ++++++--- .../renovate.all-in-one.json | 0 .../renovate.exclude-api.json | 0 .../renovate.exclude-package.json | 0 .../renovate.per-ecosystem.json | 0 .../renovate.per-project.json | 0 .../renovate.security-only.json | 0 {script => renovate/script}/forgejo-down.ps1 | 0 {script => renovate/script}/forgejo-reset.ps1 | 0 {script => renovate/script}/forgejo-up.ps1 | 0 renovate/script/renovate-check.ps1 | 55 +++++++++++++++++++ .../script}/renovate-update.ps1 | 20 +++---- script/renovate-check.ps1 | 32 ----------- 14 files changed, 83 insertions(+), 52 deletions(-) rename {example-configurations => renovate/example-configurations}/renovate.all-in-one.json (100%) rename {example-configurations => renovate/example-configurations}/renovate.exclude-api.json (100%) rename {example-configurations => renovate/example-configurations}/renovate.exclude-package.json (100%) rename {example-configurations => renovate/example-configurations}/renovate.per-ecosystem.json (100%) rename {example-configurations => renovate/example-configurations}/renovate.per-project.json (100%) rename {example-configurations => renovate/example-configurations}/renovate.security-only.json (100%) rename {script => renovate/script}/forgejo-down.ps1 (100%) rename {script => renovate/script}/forgejo-reset.ps1 (100%) rename {script => renovate/script}/forgejo-up.ps1 (100%) create mode 100644 renovate/script/renovate-check.ps1 rename {script => renovate/script}/renovate-update.ps1 (87%) delete mode 100644 script/renovate-check.ps1 diff --git a/.gitignore b/.gitignore index 121bcfd..b4848b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ node_modules/ bin/ obj/ .forgejo-token -reports/ +renovate/results/ diff --git a/README.md b/README.md index ae31546..c252a26 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,25 @@ npm/utils/ package.json + package-lock.json (dayjs, typescript) dotnet/ global.json, Directory.Packages.props, .config/dotnet-tools.json, src/{Core,Api} with packages.lock.json renovate.json Renovate configuration: one PR for npm and one for NuGet (including major updates) +renovate/ script/ (PowerShell scripts), example-configurations/, results/ (output of every run) ``` Requirements: PowerShell, Node.js >= 24.11 (e.g. `volta install node@24`), Git, Podman, .NET SDK 8 (Renovate runs `dotnet restore` to update the NuGet lock files). -Every run of `renovate-check.ps1` and `renovate-update.ps1` writes `reports//` -with `renovate-report.json` (Renovate report) and `renovate.log` (console output at debug level). +Every run of `renovate-check.ps1` and `renovate-update.ps1` writes `renovate/results//`: + +| File | Content | +|---|---| +| `command.ps1` | the executed Renovate command incl. environment variables (run it from the repository root to repeat the run) | +| `renovate.json` | the Renovate configuration that was used | +| `renovate.log` | console output at debug level | +| `renovate-report.json` | Renovate report | +| `info.json` | `startedAt`, `finishedAt`, `durationSeconds` and (update only) the created `pullRequests` | ## Example configurations -`example-configurations/` contains alternative `renovate.json` files (copy one over `renovate.json` to use it): +`renovate/example-configurations/` contains alternative `renovate.json` files (copy one over `renovate.json` to use it): | File | PRs | |---|---| @@ -33,7 +41,7 @@ with `renovate-report.json` (Renovate report) and `renovate.log` (console output ## Check only ```powershell -.\script\renovate-check.ps1 +.\renovate\script\renovate-check.ps1 ``` Renovate runs with `--platform=local` directly on this directory and lists the available updates. @@ -44,14 +52,14 @@ This platform can only check, it cannot change files. For Renovate to create branches and PRs, a Git server is needed - here a local **Forgejo** in Podman. ```powershell -.\script\forgejo-up.ps1 # start Forgejo (once, or after a reboot) -.\script\renovate-update.ps1 # run Renovate (as often as you like) -.\script\forgejo-down.ps1 # stop Forgejo; with -Purge also delete all data -.\script\forgejo-reset.ps1 # reset Forgejo completely (all repos, PRs, tokens gone) and start fresh +.\renovate\script\forgejo-up.ps1 # start Forgejo (once, or after a reboot) +.\renovate\script\renovate-update.ps1 # run Renovate (as often as you like) +.\renovate\script\forgejo-down.ps1 # stop Forgejo; with -Purge also delete all data +.\renovate\script\forgejo-reset.ps1 # reset Forgejo completely (all repos, PRs, tokens gone) and start fresh ``` - `forgejo-up.ps1` starts Forgejo (`http://localhost:3000`, login `renovate` / `renovate`), - creates the bot user and stores a fresh access token in `script/.forgejo-token`. + creates the bot user and stores a fresh access token in `renovate/script/.forgejo-token`. - `renovate-update.ps1` only knows Forgejo by endpoint, repository name (`renovate/renovate-test`) and `.forgejo-token`. It pushes `main` (the repository is created automatically on the first push), runs Renovate and fetches the branches into the local repository as `forgejo/renovate/*`. Every run creates **new branches + PRs** diff --git a/example-configurations/renovate.all-in-one.json b/renovate/example-configurations/renovate.all-in-one.json similarity index 100% rename from example-configurations/renovate.all-in-one.json rename to renovate/example-configurations/renovate.all-in-one.json diff --git a/example-configurations/renovate.exclude-api.json b/renovate/example-configurations/renovate.exclude-api.json similarity index 100% rename from example-configurations/renovate.exclude-api.json rename to renovate/example-configurations/renovate.exclude-api.json diff --git a/example-configurations/renovate.exclude-package.json b/renovate/example-configurations/renovate.exclude-package.json similarity index 100% rename from example-configurations/renovate.exclude-package.json rename to renovate/example-configurations/renovate.exclude-package.json diff --git a/example-configurations/renovate.per-ecosystem.json b/renovate/example-configurations/renovate.per-ecosystem.json similarity index 100% rename from example-configurations/renovate.per-ecosystem.json rename to renovate/example-configurations/renovate.per-ecosystem.json diff --git a/example-configurations/renovate.per-project.json b/renovate/example-configurations/renovate.per-project.json similarity index 100% rename from example-configurations/renovate.per-project.json rename to renovate/example-configurations/renovate.per-project.json diff --git a/example-configurations/renovate.security-only.json b/renovate/example-configurations/renovate.security-only.json similarity index 100% rename from example-configurations/renovate.security-only.json rename to renovate/example-configurations/renovate.security-only.json diff --git a/script/forgejo-down.ps1 b/renovate/script/forgejo-down.ps1 similarity index 100% rename from script/forgejo-down.ps1 rename to renovate/script/forgejo-down.ps1 diff --git a/script/forgejo-reset.ps1 b/renovate/script/forgejo-reset.ps1 similarity index 100% rename from script/forgejo-reset.ps1 rename to renovate/script/forgejo-reset.ps1 diff --git a/script/forgejo-up.ps1 b/renovate/script/forgejo-up.ps1 similarity index 100% rename from script/forgejo-up.ps1 rename to renovate/script/forgejo-up.ps1 diff --git a/renovate/script/renovate-check.ps1 b/renovate/script/renovate-check.ps1 new file mode 100644 index 0000000..7a2cb3d --- /dev/null +++ b/renovate/script/renovate-check.ps1 @@ -0,0 +1,55 @@ +# Check only: Renovate runs with the "local" platform directly on this repository +# and changes nothing. Found updates are read from the JSON report and printed. +# Everything about the run is stored in renovate/results//: +# command.ps1 the Renovate command that was executed (incl. environment variables) +# renovate.json the Renovate configuration that was used (working directory) +# renovate.log console output at debug level +# renovate-report.json Renovate report +# info.json start, end and duration +# Renovate requires Node.js >= 24.11 +if ([version](node -v).TrimStart('v') -lt [version]'24.11.0') { throw "Renovate requires Node.js >= 24.11, found: $(node -v). E.g.: volta install node@24" } + +$startedAt = Get-Date +$ts = $startedAt.ToString('yyyy-MM-dd-HH-mm-ss-fff') +Push-Location (Join-Path $PSScriptRoot '../..') # repository root +$outDir = "renovate/results/$ts" +New-Item -ItemType Directory -Force -Path $outDir | Out-Null +# The local platform reads the working directory, so store the renovate.json from there +Copy-Item renovate.json "$outDir/renovate.json" + +# Write the Renovate command to command.ps1 and run it. +# LOG_FILE is relative on purpose: Renovate lowercases it, an absolute path would break on case-sensitive file systems. +$command = @' +# Renovate command of run __TS__ - run it from the repository root to repeat it +$env:LOG_FILE = 'renovate/results/__TS__/renovate.log' +$env:LOG_FILE_LEVEL = 'debug' +$env:LOG_FILE_FORMAT = 'pretty' +npx --yes renovate@44.149.3 ` + --platform=local --dry-run=lookup ` + --report-type=file --report-path=renovate/results/__TS__/renovate-report.json +'@ +$command = $command.Replace('__TS__', $ts) +Set-Content -Path "$outDir/command.ps1" -Value $command +& "./$outDir/command.ps1" +Remove-Item Env:LOG_FILE, Env:LOG_FILE_LEVEL, Env:LOG_FILE_FORMAT + +$finishedAt = Get-Date +[ordered]@{ + startedAt = $startedAt.ToString('yyyy-MM-ddTHH:mm:ss.fffzzz') + finishedAt = $finishedAt.ToString('yyyy-MM-ddTHH:mm:ss.fffzzz') + durationSeconds = [math]::Round(($finishedAt - $startedAt).TotalSeconds, 1) +} | ConvertTo-Json | Set-Content -Path "$outDir/info.json" + +Write-Host "`nAvailable updates:" -ForegroundColor Cyan +$packageFiles = (Get-Content "$outDir/renovate-report.json" -Raw -Encoding UTF8 | ConvertFrom-Json).repositories.local.packageFiles +foreach ($manager in $packageFiles.PSObject.Properties) { + foreach ($file in $manager.Value) { + foreach ($dep in $file.deps) { + foreach ($update in $dep.updates) { + Write-Host " [$($manager.Name)] $($file.packageFile): $($dep.depName) $($dep.currentValue) -> $($update.newValue) ($($update.updateType))" + } + } + } +} +Write-Host "Run details: $outDir" +Pop-Location diff --git a/script/renovate-update.ps1 b/renovate/script/renovate-update.ps1 similarity index 87% rename from script/renovate-update.ps1 rename to renovate/script/renovate-update.ps1 index db3aea6..7ee4e6b 100644 --- a/script/renovate-update.ps1 +++ b/renovate/script/renovate-update.ps1 @@ -1,6 +1,6 @@ -# Renovate run against a Forgejo (started locally via script\forgejo-up.ps1). +# Renovate run against a Forgejo (started locally via renovate\script\forgejo-up.ps1). # Every run creates new branches + PRs with a timestamp: renovate/- -# Everything about the run is stored in reports//: +# Everything about the run is stored in renovate/results//: # command.ps1 the Renovate command that was executed (incl. environment variables) # renovate.json the Renovate configuration that was used (committed state of main) # renovate.log console output at debug level @@ -13,8 +13,8 @@ $tokenFile = Join-Path $PSScriptRoot '.forgejo-token' # Renovate requires Node.js >= 24.11 if ([version](node -v).TrimStart('v') -lt [version]'24.11.0') { throw "Renovate requires Node.js >= 24.11, found: $(node -v). E.g.: volta install node@24" } # Forgejo must be running and a token must exist -try { Invoke-WebRequest "$endpoint/api/healthz" -UseBasicParsing | Out-Null } catch { throw "Forgejo is not reachable at $endpoint - run .\script\forgejo-up.ps1 first" } -if (-not (Test-Path $tokenFile)) { throw "$tokenFile is missing - run .\script\forgejo-up.ps1 first" } +try { Invoke-WebRequest "$endpoint/api/healthz" -UseBasicParsing | Out-Null } catch { throw "Forgejo is not reachable at $endpoint - run .\renovate\script\forgejo-up.ps1 first" } +if (-not (Test-Path $tokenFile)) { throw "$tokenFile is missing - run .\renovate\script\forgejo-up.ps1 first" } $token = (Get-Content $tokenFile -Raw).Trim() $startedAt = Get-Date @@ -22,15 +22,15 @@ $ts = $startedAt.ToString('yyyy-MM-dd-HH-mm-ss-fff') # for the branch nam $prTimestamp = $startedAt.ToString('yyyy-MM-dd HH:mm:ss.fff') # for the PR title $gitUrl = $endpoint -replace '://', "://renovate:$token@" $gitUrl = "$gitUrl/$repo.git" -Push-Location (Join-Path $PSScriptRoot '..') # repository root -$outDir = "reports/$ts" +Push-Location (Join-Path $PSScriptRoot '../..') # repository root +$outDir = "renovate/results/$ts" New-Item -ItemType Directory -Force -Path $outDir | Out-Null # 1. Push the local state of main to Forgejo (without credential helper, the credentials are in the URL) git -c credential.helper= push $gitUrl main:main if ($LASTEXITCODE -ne 0) { Pop-Location; throw 'git push failed' } # Renovate reads the configuration from the pushed main, so store exactly that version -git show main:renovate.json --output="$outDir/renovate.json" +git show main:renovate.json | Set-Content -Path "$outDir/renovate.json" # 2. Write the Renovate command to command.ps1 and run it. # Branch prefix with timestamp => every run creates new branches + PRs. @@ -42,13 +42,13 @@ $command = @' # Renovate command of run __TS__ - run it from the repository root to repeat it $env:RENOVATE_GIT_AUTHOR = 'Renovate Bot ' $env:RENOVATE_COMMIT_MESSAGE_SUFFIX = '__PR_TIMESTAMP__' -$env:LOG_FILE = 'reports/__TS__/renovate.log' +$env:LOG_FILE = 'renovate/results/__TS__/renovate.log' $env:LOG_FILE_LEVEL = 'debug' $env:LOG_FILE_FORMAT = 'pretty' npx --yes renovate@44.149.3 ` - --platform=forgejo --endpoint=__ENDPOINT__/api/v1 --token=$((Get-Content script/.forgejo-token -Raw).Trim()) ` + --platform=forgejo --endpoint=__ENDPOINT__/api/v1 --token=$((Get-Content renovate/script/.forgejo-token -Raw).Trim()) ` --branch-prefix=renovate/__TS__- --branch-prefix-old=renovate/__TS__- ` - --report-type=file --report-path=reports/__TS__/renovate-report.json ` + --report-type=file --report-path=renovate/results/__TS__/renovate-report.json ` __REPO__ '@ $command = $command.Replace('__TS__', $ts).Replace('__PR_TIMESTAMP__', $prTimestamp).Replace('__ENDPOINT__', $endpoint).Replace('__REPO__', $repo) diff --git a/script/renovate-check.ps1 b/script/renovate-check.ps1 deleted file mode 100644 index 571d8de..0000000 --- a/script/renovate-check.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -# Check only: Renovate runs with the "local" platform directly on this directory -# and changes nothing. Found updates are read from the JSON report and printed. -# Renovate requires Node.js >= 24.11 -if ([version](node -v).TrimStart('v') -lt [version]'24.11.0') { throw "Renovate requires Node.js >= 24.11, found: $(node -v). E.g.: volta install node@24" } -# Report and debug log of this run: reports// -$ts = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff' -$outDir = Join-Path (Join-Path (Join-Path $PSScriptRoot '..') 'reports') $ts -$report = Join-Path $outDir 'renovate-report.json' -New-Item -ItemType Directory -Force -Path $outDir | Out-Null - -Push-Location (Join-Path $PSScriptRoot '..') # repository root -# Debug log file: console output in the same format, but at debug level -# Relative path on purpose: Renovate lowercases LOG_FILE, an absolute path would break on case-sensitive file systems -$env:LOG_FILE = "reports/$ts/renovate.log" -$env:LOG_FILE_LEVEL = 'debug' -$env:LOG_FILE_FORMAT = 'pretty' -npx --yes renovate@44.149.3 --platform=local --dry-run=lookup --report-type=file --report-path=$report -Remove-Item Env:LOG_FILE, Env:LOG_FILE_LEVEL, Env:LOG_FILE_FORMAT -Pop-Location - -Write-Host "`nAvailable updates:" -ForegroundColor Cyan -$packageFiles = (Get-Content $report -Raw -Encoding UTF8 | ConvertFrom-Json).repositories.local.packageFiles -foreach ($manager in $packageFiles.PSObject.Properties) { - foreach ($file in $manager.Value) { - foreach ($dep in $file.deps) { - foreach ($update in $dep.updates) { - Write-Host " [$($manager.Name)] $($file.packageFile): $($dep.depName) $($dep.currentValue) -> $($update.newValue) ($($update.updateType))" - } - } - } -} -Write-Host "Report and debug log: $outDir"