Skip to content

Commit ef6e1d6

Browse files
committed
ci: run check into the past
1 parent 9000f5b commit ef6e1d6

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

.github/workflows/verify-packages.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,37 @@ jobs:
2222
- name: Install tsx globally
2323
run: npm install -g tsx
2424

25-
- name: Check for mismatches
25+
- name: Get tags older than 6 months
26+
id: get_tags
2627
run: |
27-
if grep -q "DIFFERS" <<< "$(npx tsx ./build-packages.ts)"; then
28-
echo "❌ Found package build mismatches with npm registry!"
29-
exit 1
30-
else
31-
echo "✅ All package builds match npm registry versions"
32-
fi
28+
TAGS=$(git for-each-ref --sort=-taggerdate --format '%(refname:short) %(taggerdate:iso8601)' refs/tags | \
29+
awk -v date="$(date -d '6 months ago' +%Y-%m-%d)" '$2 < date {print $1}')
30+
echo "tags<<EOF" >> $GITHUB_OUTPUT
31+
echo "$TAGS" >> $GITHUB_OUTPUT
32+
echo "EOF" >> $GITHUB_OUTPUT
33+
34+
- name: Verify packages for each tag
35+
id: verify_tags
36+
run: |
37+
set -e
38+
mkdir -p results
39+
echo "| Tag | Result | Differing Packages |" > results/summary.md
40+
echo "|-----|--------|--------------------|" >> results/summary.md
41+
for TAG in ${{ steps.get_tags.outputs.tags }}; do
42+
echo "Checking out $TAG"
43+
git checkout $TAG
44+
npm ci || { echo "| $TAG | npm ci failed | - |" >> results/summary.md; continue; }
45+
DIFFERS_JSON=$(npx tsx ./build-packages.ts)
46+
if [ "$DIFFERS_JSON" != "[]" ]; then
47+
# Remove brackets and quotes for markdown table
48+
DIFFERS_LIST=$(echo $DIFFERS_JSON | jq -r '. | join(", ")')
49+
echo "| $TAG | ❌ Mismatch | $DIFFERS_LIST |" >> results/summary.md
50+
else
51+
echo "| $TAG | ✅ Match | - |" >> results/summary.md
52+
fi
53+
done
54+
git checkout $GITHUB_SHA # Return to original commit
55+
56+
- name: Print summary table
57+
run: |
58+
cat results/summary.md

build-packages.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const packages = fs.readdirSync(PACKAGES_DIR).filter(item => {
1313
return fs.statSync(itemPath).isDirectory() && !item.startsWith('.');
1414
});
1515

16-
console.log(`Found ${packages.length} packages to process`);
16+
// console.debug(`Found ${packages.length} packages to process`);
17+
18+
const NPM_VERSION_TAG = (process.env.NPM_VERSION_TAG || 'latest').replace(/^v/, '');
1719

1820
// Process all packages
1921
const results = packages
@@ -22,11 +24,11 @@ const results = packages
2224
const pkg = JSON.parse(fs.readFileSync(json, 'utf8'));
2325

2426
if (pkg.private === true) {
25-
console.log(`Skipping package: ${pkg.name}`);
27+
// console.debug(`Skipping package: ${pkg.name}`);
2628
return null;
2729
}
2830

29-
console.log(`\nProcessing package: ${pkg.name}`);
31+
// console.debug(`\nProcessing package: ${pkg.name}`);
3032
process.chdir(path.join(PACKAGES_DIR, dir));
3133

3234
// Run npm publish dry-run
@@ -40,34 +42,36 @@ const results = packages
4042
/npm notice integrity:\s+(sha\d+-[A-Za-z0-9+/=]+(?:\[\.\.\.\][A-Za-z0-9+/=]*==?)?)/
4143
);
4244

43-
console.log(` Package: ${pkg.name}`);
44-
console.log(` Tarball hash: ${integrity}`);
45-
console.log(` Shasum: ${shasum}`);
45+
// console.debug(` Package: ${pkg.name}`);
46+
// console.debug(` Tarball hash: ${integrity}`);
47+
// console.debug(` Shasum: ${shasum}`);
4648

47-
// Check latest published version on npm registry
48-
const registryCheck = spawnSync('curl', [`https://registry.npmjs.org/${pkg.name}/latest`], {
49+
const registryUrl = `https://registry.npmjs.org/${pkg.name}/${NPM_VERSION_TAG}`;
50+
const registryCheck = spawnSync('curl', [registryUrl], {
4951
encoding: 'utf8',
5052
});
5153
const registryData = JSON.parse(registryCheck.stdout);
5254
const registryShasum = registryData.dist?.shasum;
5355

54-
const status = registryShasum === shasum ? 'matches' : `DIFFERS`;
55-
console.log(` ${status}`);
56-
5756
return {
5857
name: pkg.name,
5958
tarballHash: integrity,
6059
shasum,
60+
differs: registryShasum === shasum,
6161
};
6262
})
63-
.filter(Boolean) as PackageInfo[];
63+
.filter(Boolean) as (PackageInfo & { differs: boolean })[];
6464

6565
// Restore original directory
6666
process.chdir(ORIGINAL_DIR);
6767

6868
// Output final results
69-
console.log('\n=== PACKAGE BUILD RESULTS ===');
70-
console.table(results);
69+
// console.debug('\n=== PACKAGE BUILD RESULTS ===');
70+
// console.debug(results);
71+
72+
// Output JSON array of differing packages
73+
const differingPackages = results.filter(r => r.differs).map(r => r.name);
74+
console.log(JSON.stringify(differingPackages));
7175

7276
// HELPERS
7377
function extractFromOutput(output: string, regex: RegExp): string {

0 commit comments

Comments
 (0)