Skip to content

Commit fe4aa48

Browse files
authored
chore: update renovate config with current set of core repo experimental packages (#3146)
I also started a 'bitrot' script for having a place to little 'is this thing out of date' checks that don't merit their own full automation yet.
1 parent 333e026 commit fe4aa48

File tree

2 files changed

+130
-8
lines changed

2 files changed

+130
-8
lines changed

renovate.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,32 @@
1919
{
2020
"groupName": "OTel Core experimental",
2121
"matchPackageNames": [
22-
"@opentelemetry/api-events",
2322
"@opentelemetry/api-logs",
2423
"@opentelemetry/exporter-logs-otlp-grpc",
2524
"@opentelemetry/exporter-logs-otlp-http",
2625
"@opentelemetry/exporter-logs-otlp-proto",
27-
"@opentelemetry/exporter-trace-otlp-grpc",
28-
"@opentelemetry/exporter-trace-otlp-http",
29-
"@opentelemetry/exporter-trace-otlp-proto",
30-
"@opentelemetry/browser-detector",
3126
"@opentelemetry/exporter-metrics-otlp-grpc",
3227
"@opentelemetry/exporter-metrics-otlp-http",
3328
"@opentelemetry/exporter-metrics-otlp-proto",
3429
"@opentelemetry/exporter-prometheus",
30+
"@opentelemetry/exporter-trace-otlp-grpc",
31+
"@opentelemetry/exporter-trace-otlp-http",
32+
"@opentelemetry/exporter-trace-otlp-proto",
3533
"@opentelemetry/instrumentation",
3634
"@opentelemetry/instrumentation-fetch",
3735
"@opentelemetry/instrumentation-grpc",
3836
"@opentelemetry/instrumentation-http",
3937
"@opentelemetry/instrumentation-xml-http-request",
40-
"@opentelemetry/sdk-node",
38+
"@opentelemetry/opentelemetry-browser-detector",
4139
"@opentelemetry/otlp-exporter-base",
4240
"@opentelemetry/otlp-grpc-exporter-base",
43-
"@opentelemetry/otlp-proto-exporter-base",
4441
"@opentelemetry/otlp-transformer",
42+
"@opentelemetry/sampler-composite",
43+
"@opentelemetry/sampler-jaeger-remote",
4544
"@opentelemetry/sdk-logs",
46-
"@opentelemetry/shim-opencensus"
45+
"@opentelemetry/sdk-node",
46+
"@opentelemetry/shim-opencensus",
47+
"@opentelemetry/web-common"
4748
],
4849
"rangeStrategy": "bump",
4950
"schedule": ["before 3am every weekday"]

scripts/bitrot.mjs

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env node
2+
/*
3+
* Copyright The OpenTelemetry Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* A script to check if some things (e.g. config files) have out of date data.
20+
* This can be useful for checking things where fully automated updating isn't
21+
* worth it.
22+
*
23+
* See "BITROT:" comments for things that are checked.
24+
*
25+
* Usage:
26+
* node scripts/bitrot.mjs
27+
*/
28+
29+
import * as assert from 'assert';
30+
import { execSync } from 'child_process';
31+
import * as fs from 'fs';
32+
import * as path from 'path';
33+
import { fileURLToPath } from 'url';
34+
import { globSync } from 'glob';
35+
36+
const TOP = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '..');
37+
const USE_COLOR = process.stdout.isTTY && !process.env.NO_COLOR?.length > 0;
38+
const BUILD_DIR = path.join(TOP, 'build', 'bitrot');
39+
40+
let numProbs = 0;
41+
function problem(...args) {
42+
numProbs += 1;
43+
if (USE_COLOR) {
44+
process.stdout.write('\x1b[31m');
45+
}
46+
args.unshift('bitrot error:');
47+
console.log(...args);
48+
if (USE_COLOR) {
49+
process.stdout.write('\x1b[39m');
50+
}
51+
}
52+
53+
function gitCloneSync(repo, dir) {
54+
execSync(`git clone ${repo} "${dir}"`)
55+
}
56+
function gitPullSync(cwd) {
57+
execSync('git pull', {cwd})
58+
}
59+
60+
function isPublicPackage(pj) {
61+
if (pj.private === true) {
62+
return false;
63+
} else if (pj.publishConfig?.access) {
64+
return (pj.publishConfig.access === 'public');
65+
} else {
66+
// Default is *false* for scoped packages.
67+
return (!pj.name.startsWith('@'));
68+
}
69+
}
70+
71+
/**
72+
* BITROT: Check that the `"groupName": "OTel Core experimental",`
73+
* group in renovate.json matches the actual current set of experimental
74+
* packages from the core repo.
75+
*/
76+
function bitrotRenovateCoreExperimental() {
77+
const renovateJson = path.join(TOP, 'renovate.json');
78+
const renovate = JSON.parse(fs.readFileSync(renovateJson));
79+
const group = renovate.packageRules.filter(r => r.groupName === 'OTel Core experimental')[0];
80+
assert.ok(group, `found "OTel Core experimental" group in ${renovateJson}`);
81+
82+
const ojDir = path.join(BUILD_DIR, 'opentelemetry-js');
83+
if (fs.existsSync(ojDir)) {
84+
gitPullSync(ojDir);
85+
} else {
86+
gitCloneSync('https://github.com/open-telemetry/opentelemetry-js.git', ojDir);
87+
}
88+
89+
const pkgNames = globSync(path.join(ojDir, 'experimental/packages/*/package.json'))
90+
.map(packageJson => JSON.parse(fs.readFileSync(packageJson)))
91+
.filter(pj => isPublicPackage(pj))
92+
.map(pj => pj.name);
93+
94+
const pkgNamesSet = new Set(pkgNames);
95+
const renovateSet = new Set(group.matchPackageNames);
96+
const missing = pkgNamesSet.difference(renovateSet); // requires Node.js >=22
97+
const extraneous = renovateSet.difference(pkgNamesSet);
98+
99+
const issues = [];
100+
if (missing.size) {
101+
issues.push(`missing entries: ${JSON.stringify(Array.from(missing))}`);
102+
}
103+
if (extraneous.size) {
104+
issues.push(`extraneous entries: ${JSON.stringify(Array.from(extraneous))}`);
105+
}
106+
if (issues.length) {
107+
problem(`${renovateJson}: "matchPackageNames" in the "OTel Core experimental" group does not match the current set experimental packages from the opentelemetry-js.git repo:\n - ${issues.join('\n - ')}\nThe "matchPackageNames" should be:\n${JSON.stringify(pkgNames.sort(), null, 2)}`);
108+
}
109+
}
110+
111+
function bitrot() {
112+
bitrotRenovateCoreExperimental();
113+
}
114+
115+
// ---- mainline
116+
117+
await bitrot();
118+
if (numProbs > 0) {
119+
process.exitCode = 1;
120+
}
121+

0 commit comments

Comments
 (0)