Skip to content
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

chore(release): update pypi packaging #604

Merged
merged 51 commits into from
Feb 6, 2025

Conversation

thomasrockhu-codecov
Copy link
Contributor

@thomasrockhu-codecov thomasrockhu-codecov commented Jan 26, 2025

  • splits build_assets and build_for_pypi into separate workflows that run on
  • they also run on new tags
  • adds pyproject.toml because its what should be used over setup.py
  • splits the build and deploy job for the build_for_pypi workflow
  • small opentelem thing to not run on tests

fixes #466

Copy link

codecov bot commented Jan 26, 2025

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
3560 5 3555 0
View the top 3 failed tests by shortest run time
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError
api.temp.calculator.test_calculator::test_divide
Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

github-actions bot commented Jan 26, 2025

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@thomasrockhu-codecov thomasrockhu-codecov changed the title feat: first pass at new packaging chore(release): update pypi packaging Jan 27, 2025
@@ -18,7 +18,7 @@ jobs:
- id: get-release-vars
name: Configure Release Vars
run: |
echo release_version=v$(grep -E "version=\"[0-9]+\.[0-9]+\.[0-9]+\"" setup.py | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") >> "$GITHUB_OUTPUT"
echo release_version=v$(grep -E "version=\"[0-9]+\.[0-9]+\.[0-9]+\"" pyproject.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") >> "$GITHUB_OUTPUT"
echo previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) >> "$GITHUB_OUTPUT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Python version in this job is 3.11+, you can just use the stdlib module for reading TOML:

Suggested change
echo previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) >> "$GITHUB_OUTPUT"
echo previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) >> "$GITHUB_OUTPUT"
- name: Extract hardcoded dist version from PEP 621 config
id: dist-meta
run: |
from os import environ
from pathlib import Path
from tomllib import loads as convert_toml_text_to_dict
FILE_APPEND_MODE = 'a'
pyproject_toml_txt = Path("pyproject.toml").read_text(encoding="utf-8")
pyproject_toml = convert_toml_text_to_dict(pyproject_toml_txt)
version_string = pyproject_toml["project"]["version"]
with Path(environ['GITHUB_OUTPUT']).open(
mode=FILE_APPEND_MODE,
) as outputs_file:
print(f'release-version={version_string !s}', file=outputs_file)
shell: python

(if not — call actions/setup-python earlier to ensure it's modern enough)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note that I'm setting release-version over release_version, and a new step ID here because it's usually helpful to have kebab-case identifiers in GHA, making it easier to distinguish them from identifiers from other embedded scripts)

MANIFEST.in Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@webknjaz
Copy link
Contributor

@thomasrockhu-codecov short of the broken regex, the rest should be ready even without implementing improvement suggestions in other comments — they can be declared out of the scope and filed as separate issues, I suppose.

@webknjaz
Copy link
Contributor

you can email me at [email protected].

Thanks! I've emailed you.

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Copy link
Contributor

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that the environment isn't set. Here's a patch to fix this. Additionally, add required reviewers to the environment called pypi in the repo settings.

.github/workflows/build_for_pypi.yml Show resolved Hide resolved
thomasrockhu-codecov and others added 2 commits February 5, 2025 18:18
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
@webknjaz
Copy link
Contributor

webknjaz commented Feb 6, 2025

@thomasrockhu-codecov additionally to that incorrect URL that I suggested initially, could you confirm you've enabled required reviewers in the environment called pypi? There's been discussions about this topic recently, when TP was being integrated into pip: pypa/pip#13048 (comment). I recommend having this gate just to be in control of the process.

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
@thomasrockhu-codecov
Copy link
Contributor Author

@webknjaz

image

Copy link
Contributor

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasrockhu-codecov thomasrockhu-codecov merged commit 1bd492c into main Feb 6, 2025
27 of 28 checks passed
@thomasrockhu-codecov thomasrockhu-codecov deleted the th/rebuild-packaging branch February 6, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GHA+PyPI+packaging shortcomings
3 participants