Skip to content

Commit

Permalink
Wait for PyPi package to be available (#25)
Browse files Browse the repository at this point in the history
* Wait for PyPi package to be available

Fixes #24

* Limit PyPi waiting to 15 minutes
  • Loading branch information
danielrbradley authored Jul 26, 2024
1 parent ae81691 commit 7fa110c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/verifyRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ async function installPipPackageVersion(
core.debug(`Failed to uninstall ${packageRef}`)
}

// Wait for up to 15 minutes for the package to be available on PyPI
const startTime = Date.now()
while (!isPypiPackageAvailable(cwd, pip, packageRef, opts.packageVersion)) {
core.debug(
`Waiting for ${packageRef}==${opts.packageVersion} to be available on PyPI`
)
if (Date.now() - startTime > 15 * 60 * 1000) {
throw new Error(
`Timed out waiting for ${packageRef}==${opts.packageVersion} to be available on PyPI`
)
}
await new Promise(resolve => setTimeout(resolve, 5000)) // 5 seconds
}

const packageVersionRef = `${packageRef}==${opts.packageVersion}`
const installCmd = `${pip} install ${packageVersionRef}`
core.debug(`Installing pip package: ${installCmd}`)
Expand All @@ -131,6 +145,19 @@ async function installPipPackageVersion(
}
}

function isPypiPackageAvailable(
cwd: string,
pip: string,
packageRef: string,
packageVersion: string
): boolean {
const versions = shell.exec(`${pip} index versions --pre "${packageRef}"`, {
cwd,
silent: true
}).stdout
return versions.includes(packageVersion)
}

async function installDotnetPackageVersion(
cwd: string,
opts: VerifyReleaseOptions
Expand Down

0 comments on commit 7fa110c

Please sign in to comment.