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

Open
wants to merge 46 commits into
base: main
Choose a base branch
from

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
@thomasrockhu-codecov
Copy link
Contributor Author

@webknjaz if you have some time, would love another look at this PR

pyproject.toml Outdated Show resolved Hide resolved
@thomasrockhu-codecov
Copy link
Contributor Author

@webknjaz, I'd like to send you some swag from Codecov/Sentry for all the help on this PR (and all the issues you've created over the years), you can email me at [email protected].

@@ -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)

@@ -1,2 +1,3 @@
include languages/treesitterjavascript/src/tree_sitter/parser.h
include languages/treesitterpython/src/tree_sitter/parser.h
include requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future: include the entire repo. Well, except GHA automation and some helper scripts that aren't needed for running tests/building docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahhh, is that the preferred way of doing this?

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]>
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
2 participants