From 5b9e3d22f56d1e186a279b353f0b2d7b8bf32d8c Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Fri, 18 Oct 2024 11:06:40 +0300 Subject: [PATCH 1/2] remove downloaded files --- .github/workflows/Versioning.yml | 2 +- .gitignore | 3 ++- .../server/scripts/validate-external-api-versioning.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Versioning.yml b/.github/workflows/Versioning.yml index 375dc78d8d7..13ea0f6c6f3 100644 --- a/.github/workflows/Versioning.yml +++ b/.github/workflows/Versioning.yml @@ -58,7 +58,7 @@ jobs: run: | git config --global user.name "timolegros" git config --global user.email "timothee@ualberta.ca" - git add ./libs/api-client/package.json ./packages/commonwealth/server/external-api-config.json + git add libs/api-client/package.json packages/commonwealth/server/external-api-config.json git commit -m "chore: update client SDK version" git push origin HEAD # May need to add a `repo` scoped personal access token diff --git a/.gitignore b/.gitignore index aafaaa0feba..d7256dac6a7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ redis-data *coverage **/*.dump.sql **/*.dump.sql.gz -external-production-openapi.json \ No newline at end of file +external-production-openapi.json +external-openapi.json \ No newline at end of file diff --git a/packages/commonwealth/server/scripts/validate-external-api-versioning.ts b/packages/commonwealth/server/scripts/validate-external-api-versioning.ts index c0c14000883..6b99b421691 100644 --- a/packages/commonwealth/server/scripts/validate-external-api-versioning.ts +++ b/packages/commonwealth/server/scripts/validate-external-api-versioning.ts @@ -160,6 +160,7 @@ async function validateExternalApiVersioning() { format: 'openapi3', }, }); + await Promise.all([unlink(productionOasPath), unlink(localOasPath)]); if (result.breakingDifferencesFound) { throw Error('External API has breaking changes, update the Major version'); @@ -191,7 +192,6 @@ async function validateExternalApiVersioning() { return; } - await Promise.all([unlink(productionOasPath), unlink(localOasPath)]); console.log(`No version updated: ${readableVersion(oldVersion)}`); } From f2b508076836839ea32193b92ad4eafd6aaadf81 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Fri, 18 Oct 2024 11:13:46 +0300 Subject: [PATCH 2/2] added logs for visibility --- .../server/scripts/validate-external-api-versioning.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/commonwealth/server/scripts/validate-external-api-versioning.ts b/packages/commonwealth/server/scripts/validate-external-api-versioning.ts index 6b99b421691..5ab40138242 100644 --- a/packages/commonwealth/server/scripts/validate-external-api-versioning.ts +++ b/packages/commonwealth/server/scripts/validate-external-api-versioning.ts @@ -137,6 +137,10 @@ async function validateExternalApiVersioning() { ? parseSemVer(newOas.info.version) : parseSemVer(process.argv[2]); + console.log( + `Files downloaded and versions parsed. \nNew Version: ${newVersion}\nOld Version: ${oldVersion}`, + ); + if (oldVersion.major < newVersion.major) { if (newVersion.minor !== 0 || newVersion.patch !== 0) { const newMajorVersion = `${newVersion.major}.0.0`; @@ -145,6 +149,7 @@ async function validateExternalApiVersioning() { `Bumped OAS version from ${readableVersion(oldVersion)} to ${newMajorVersion}`, ); } + console.log('Major version already bumped.'); return; // Breaking change, this is valid regardless of schema changes } @@ -161,6 +166,7 @@ async function validateExternalApiVersioning() { }, }); await Promise.all([unlink(productionOasPath), unlink(localOasPath)]); + console.log('OpenAPI spec diff:', result); if (result.breakingDifferencesFound) { throw Error('External API has breaking changes, update the Major version');