Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions packages/database/src/check-build-consistency.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Consistency checker / updater for the status field in the builds table:
// - Finds "scheduled" builds older than 10 hours.
// - Verifies Android artifacts exist in the Maven repo.
// - Verifies artifacts exist in the Maven repo.
// - Updates build status to completed/failed when run with --write (dry run otherwise).
import { SupabaseClient } from '@supabase/supabase-js';
import { sanitizePackageName } from '@rnrepo/config';
Expand All @@ -19,21 +19,23 @@ interface BuildRow {
updated_at: string;
}

function buildAndroidArtifactUrl(
function buildArtifactUrl(
build: BuildRow,
baseRepositoryUrl: string
): string {
): string[] {
const repositoryUrl = baseRepositoryUrl.replace(/\/+$/, '');
const artifactId = sanitizePackageName(build.package_name);
const classifier = `rn${build.rn_version}${
build.worklets_version ? `-worklets${build.worklets_version}` : ''
}`;
const encodedVersion = encodeURIComponent(build.version);
const fileName = `${artifactId}-${build.version}-${classifier}.aar`;

return `${repositoryUrl}/org/rnrepo/public/${artifactId}/${encodedVersion}/${encodeURIComponent(
fileName
)}`;

const commonPath = `${repositoryUrl}/org/rnrepo/public/${artifactId}/${encodeURIComponent(build.version)}`;
const fileName = `${artifactId}-${build.version}-${classifier}`;

const variants = build.platform === 'android'
? ['.aar']
: ['-debug.zip', '-release.zip'];
return variants.map(suffix => `${commonPath}/${encodeURIComponent(fileName + suffix)}`);
}

async function artifactExists(url: string): Promise<boolean> {
Expand Down Expand Up @@ -114,16 +116,8 @@ async function main() {
} [${build.platform}]`;
console.log(`\n▢️ Checking ${info} (current: ${build.status})`);

if (build.platform !== 'android') {
console.warn(
`⚠️ Platform ${build.platform} not supported for Maven check. Skipping.`
);
skippedCount++;
continue;
}

const artifactUrl = buildAndroidArtifactUrl(build, baseRepositoryUrl);
const exists = await artifactExists(artifactUrl);
const artifactUrls = buildArtifactUrl(build, baseRepositoryUrl);
const exists = (await Promise.all(artifactUrls.map(artifactExists))).every(Boolean);

if (exists) {
completedCount++;
Expand Down
Loading