Skip to content

Commit

Permalink
Merge branch 'ka.externalApiVersioning' into tim/test-version-bump-1
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros committed Oct 18, 2024
2 parents 72ccd98 + f2b5080 commit 5ed8e09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
git config --global user.name "timolegros"
git config --global user.email "[email protected]"
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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ redis-data
*coverage
**/*.dump.sql
**/*.dump.sql.gz
external-production-openapi.json
external-production-openapi.json
external-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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
}

Expand All @@ -160,6 +165,8 @@ async function validateExternalApiVersioning() {
format: 'openapi3',
},
});
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');
Expand Down Expand Up @@ -191,7 +198,6 @@ async function validateExternalApiVersioning() {
return;
}

await Promise.all([unlink(productionOasPath), unlink(localOasPath)]);
console.log(`No version updated: ${readableVersion(oldVersion)}`);
}

Expand Down

0 comments on commit 5ed8e09

Please sign in to comment.