-
Notifications
You must be signed in to change notification settings - Fork 22
ensure testing of built version after deployment #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
orbeckst
wants to merge
3
commits into
master
Choose a base branch
from
improved-deployment-cursor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,86 @@ | ||
| name: 'Wait for PyPI version' | ||
| description: 'Wait for a specific package version to become available on PyPI or TestPyPI' | ||
| inputs: | ||
| repository: | ||
| description: 'PyPI repository type: "pypi" or "testpypi"' | ||
| required: true | ||
| package: | ||
| description: 'Package name' | ||
| required: true | ||
| version: | ||
| description: 'Package version to wait for' | ||
| required: true | ||
| max_attempts: | ||
| description: 'Maximum number of retry attempts' | ||
| required: false | ||
| default: '30' | ||
| wait_seconds: | ||
| description: 'Seconds to wait between attempts' | ||
| required: false | ||
| default: '10' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install requests | ||
| shell: bash | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install requests | ||
|
|
||
| - name: Wait for version to be available | ||
| shell: bash | ||
| env: | ||
| REPOSITORY: ${{ inputs.repository }} | ||
| PACKAGE: ${{ inputs.package }} | ||
| VERSION: ${{ inputs.version }} | ||
| MAX_ATTEMPTS: ${{ inputs.max_attempts }} | ||
| WAIT_SECONDS: ${{ inputs.wait_seconds }} | ||
| run: | | ||
| if [ "$REPOSITORY" = "testpypi" ]; then | ||
| API_URL="https://test.pypi.org/pypi/$PACKAGE/json" | ||
| REPO_NAME="TestPyPI" | ||
| elif [ "$REPOSITORY" = "pypi" ]; then | ||
| API_URL="https://pypi.org/pypi/$PACKAGE/json" | ||
| REPO_NAME="PyPI" | ||
| else | ||
| echo "ERROR: repository must be 'pypi' or 'testpypi', got '$REPOSITORY'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Export shell variables so Python can access them via os.environ | ||
| export API_URL REPO_NAME | ||
|
|
||
| ATTEMPT=0 | ||
| while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do | ||
| if python -c " | ||
| import os | ||
| import requests | ||
| import sys | ||
| try: | ||
| api_url = os.environ['API_URL'] | ||
| version = os.environ['VERSION'] | ||
| repo_name = os.environ['REPO_NAME'] | ||
| r = requests.get(api_url, timeout=10) | ||
| r.raise_for_status() | ||
| versions = r.json().get('releases', {}) | ||
| print('Available versions:', list(versions.keys())[-10:]) # Show last 10 versions | ||
| if version in versions: | ||
| print(f'✓ Version {version} is available on {repo_name}') | ||
| sys.exit(0) | ||
| else: | ||
| print(f'✗ Version {version} is NOT available on {repo_name}') | ||
| sys.exit(1) | ||
| except Exception as e: | ||
| print(f'Error checking version: {e}') | ||
| sys.exit(1) | ||
| " 2>/dev/null; then | ||
| echo "Version $VERSION is now available on $REPO_NAME" | ||
| exit 0 | ||
| fi | ||
| ATTEMPT=$((ATTEMPT + 1)) | ||
| echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Version $VERSION not yet available on $REPO_NAME, waiting $WAIT_SECONDS seconds..." | ||
| sleep $WAIT_SECONDS | ||
| done | ||
| echo "ERROR: Version $VERSION did not become available on $REPO_NAME after $MAX_ATTEMPTS attempts" | ||
| exit 1 | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a brief initial look - it feels like most of this should be doable directly as a python call.
Switchin between bash and python seems less efficient than having more os calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point!
it’s probably also nicer to just write a Python script instead of inline code.