Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: API compatibility check fails in CI pipeline (#19069)
This is a re-roll of #19070, fixing a bug introduced in that one. In the master build, we do a version bump which turns `1.146.0` into `1.146.0-rc.0`, which makes the API compatibility checker try to install packages with those versions. Because none of those packages exist, the list of packages ends up empty, which turns our `npm install $PACKAGES` command into `npm install`, which subsequently complains that there's no `package.json`. In order to make this work properly, we need to query the ACTUAL released version numbers on GitHub so we can properly find the version to diff against. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
3 changed files
with
62 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Find the latest CDK release on GitHub matching a particular semver range | ||
// | ||
// The range can be something like '<1.2.3' to find the latest release before a given version, | ||
// or '2' to find the latest v2 release. | ||
// | ||
// Only searches the most recent 100 GitHub releases, so only use this to query fairly recent versions. | ||
const cp = require('child_process'); | ||
const semver = require('semver'); | ||
|
||
async function main(matchRange) { | ||
if (matchRange === undefined) { | ||
throw new Error('Usage: find-latest-release.js RANGE'); | ||
} | ||
const range = semver.validRange(matchRange); | ||
if (!range) { | ||
throw new Error(`Not a valid range: ${matchRange}`); | ||
} | ||
|
||
const { stdout, error } = cp.spawnSync('curl', ['https://api.github.com/repos/aws/aws-cdk/releases?per_page=100'], { maxBuffer: 10_000_000 }); | ||
if (error) { throw error; } | ||
const releases = JSON.parse(stdout); | ||
const versions = releases.map(r => r.name.replace(/^v/, '')); // v1.2.3 -> 1.2.3 | ||
|
||
const sat = semver.maxSatisfying(versions, range); | ||
if (!sat) { | ||
throw new Error(`No range satisfied ${range} (on the first page of GitHub releases)`); | ||
} | ||
console.log(sat); | ||
} | ||
|
||
main(process.argv[2]).catch(e => { | ||
console.error(e); | ||
process.exitCode = 1; | ||
}); |