From 149a52014d1703dcc12fd22b98ad72371bc96838 Mon Sep 17 00:00:00 2001 From: Adam Brezina Date: Tue, 28 Jul 2026 17:07:40 +0200 Subject: [PATCH 1/2] chore(RHIDP-14706): update archive script in rhdh-plugins References of the archived workspace are now automatically removed from the files: codecov.yml, .github/labeler.yml and .github/pr-labeler.yml Signed-off-by: Adam Brezina --- CONTRIBUTING.md | 2 ++ scripts/archive.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 800fa79251b..cb5573d29be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -444,6 +444,8 @@ Consider archiving when the plugin is unmaintained, has no owner, has unfixable - `ARCHIVED_WORKSPACES.md` - `.github/CODEOWNERS` (full workspace only — removes the `/workspaces/` line) - `.github/renovate.json` and `.github/renovate-presets/workspace/rhdh--presets.json` (full workspace only, when present) + - `.github/labeler.yml` and `.github/pr-labeler.yml` (full workspace only, removes the workspace's entry) + - `codecov.yml` (full workspace only, removes the workspace's entry) It does **not** delete source directories; do that in the next step. diff --git a/scripts/archive.js b/scripts/archive.js index 18daf0e9c2a..8f57004958d 100644 --- a/scripts/archive.js +++ b/scripts/archive.js @@ -39,6 +39,10 @@ const RENOVATE_PRESETS_DIR = path.join( 'workspace', ); +const CODECOV_YML = path.join(ROOT, 'codecov.yml'); +const LABELER_YML = path.join(ROOT, '.github', 'labeler.yml'); +const PR_LABELER_YML = path.join(ROOT, '.github', 'pr-labeler.yml'); + function printUsage() { console.log(`Usage: node scripts/archive.js [plugin-dir-or-package-suffix] ["reason"] @@ -116,6 +120,40 @@ async function removeWorkspaceFromCodeowners(workspace) { console.log('Updated CODEOWNERS'); } +async function removeWorkspaceEntryFromLabelerFile(filePath, workspace) { + const relPath = path.relative(ROOT, filePath); + console.log(`Removing workspace/${workspace} entry from ${relPath}...`); + const content = await fs.readFile(filePath, 'utf8'); + const key = `workspace/${workspace}:`; + const paragraphs = content.split('\n\n'); + const filtered = paragraphs.filter(p => !p.startsWith(key)); + if (filtered.length === paragraphs.length) { + console.log( + `No workspace/${workspace} entry found in ${relPath} (skipping).`, + ); + return; + } + await fs.writeFile(filePath, filtered.join('\n\n')); + console.log(`Updated ${relPath}`); +} + +async function removeWorkspaceFromCodecovYml(workspace) { + console.log(`Removing workspace ${workspace} flag from codecov.yml...`); + const content = await fs.readFile(CODECOV_YML, 'utf8'); + const lines = content.split('\n'); + const pathLine = ` - workspaces/${workspace}/`; + const index = lines.findIndex(line => line === pathLine); + if (index === -1) { + console.log( + `No codecov.yml flag entry found for workspace "${workspace}" (skipping).`, + ); + return; + } + lines.splice(index - 2, 3); + await fs.writeFile(CODECOV_YML, lines.join('\n')); + console.log('Updated codecov.yml'); +} + async function removeWorkspaceFromRenovateJson(workspace) { const presetRef = `github>${REPO_SLUG}//.github/renovate-presets/workspace/rhdh-${workspace}-presets`; const content = await fs.readFile(RENOVATE_JSON, 'utf8'); @@ -289,11 +327,14 @@ async function main() { if (fullWorkspace) { console.log( - '\nFull workspace archival: updating CODEOWNERS and Renovate configuration...', + '\nFull workspace archival: updating CODEOWNERS, Renovate, CI and coverage configuration...', ); await removeWorkspaceFromCodeowners(workspace); await removeRenovatePresetFile(workspace); await removeWorkspaceFromRenovateJson(workspace); + await removeWorkspaceFromCodecovYml(workspace); + await removeWorkspaceEntryFromLabelerFile(LABELER_YML, workspace); + await removeWorkspaceEntryFromLabelerFile(PR_LABELER_YML, workspace); } console.log( From 56cdefeacfb737fec8f745847a72f8ef1411af4c Mon Sep 17 00:00:00 2001 From: Adam Brezina Date: Wed, 29 Jul 2026 09:37:22 +0200 Subject: [PATCH 2/2] changed findIndex() to indexOf() Signed-off-by: Adam Brezina --- scripts/archive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/archive.js b/scripts/archive.js index 8f57004958d..0f2dc63e00b 100644 --- a/scripts/archive.js +++ b/scripts/archive.js @@ -142,7 +142,7 @@ async function removeWorkspaceFromCodecovYml(workspace) { const content = await fs.readFile(CODECOV_YML, 'utf8'); const lines = content.split('\n'); const pathLine = ` - workspaces/${workspace}/`; - const index = lines.findIndex(line => line === pathLine); + const index = lines.indexOf(line => line === pathLine); if (index === -1) { console.log( `No codecov.yml flag entry found for workspace "${workspace}" (skipping).`,