Repository navigation
chore: modernize Python tooling (uv, pyproject.toml, src layout, semantic release) #283
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f7f5568
chore: migrate package metadata to pyproject.toml (PEP 621)
salman2013 c3d50a9
chore: switch dependency management from pip-tools to uv
salman2013 a812d53
chore: add python-semantic-release and replace pypi-publish workflow
salman2013 a33c0e3
refactor: migrate to src layout
salman2013 09f827f
fix: resolve CI failures from flake8 violations and test env setup
salman2013 91962a2
fix: address review findings from modernize-python-tooling migration
salman2013 9e69fd1
chore: resolve merge conflicts — bump checkout to v7.0.1, keep pypi-p…
salman2013 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
This file was deleted.
Oops, something went wrong.
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,74 @@ | ||
| name: Semantic Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| run_tests: | ||
| uses: ./.github/workflows/ci.yml | ||
| secrets: inherit | ||
| permissions: | ||
| contents: read | ||
|
|
||
| release: | ||
| needs: run_tests | ||
| if: github.ref_name == 'master' | ||
| runs-on: ubuntu-latest | ||
| concurrency: | ||
| group: ${{ github.workflow }}-release | ||
| cancel-in-progress: false | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.ref_name }} | ||
| - run: git reset --hard ${{ github.sha }} | ||
| - name: Python Semantic Release | ||
| id: release | ||
| uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| git_committer_name: "github-actions" | ||
| git_committer_email: "github-actions@github.com" | ||
| changelog: "false" | ||
| vcs_release: "false" | ||
| - name: Create GitHub Release with Assets | ||
| if: steps.release.outputs.released == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| RELEASE_NOTES: ${{ steps.release.outputs.release_notes }} | ||
| TAG: ${{ steps.release.outputs.tag }} | ||
| run: | | ||
| printf '%s' "$RELEASE_NOTES" > "$RUNNER_TEMP/release_notes.md" | ||
| gh release create "$TAG" \ | ||
| --verify-tag \ | ||
| --title "$TAG" \ | ||
| --notes-file "$RUNNER_TEMP/release_notes.md" \ | ||
| dist/* | ||
| - name: Upload dist | ||
| if: steps.release.outputs.released == 'true' | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| outputs: | ||
| released: ${{ steps.release.outputs.released }} | ||
| version: ${{ steps.release.outputs.version }} | ||
| release_notes: ${{ steps.release.outputs.release_notes }} | ||
|
|
||
| publish_to_pypi: | ||
| needs: release | ||
| if: needs.release.outputs.released == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - uses: pypa/gh-action-pypi-publish@release/v1 |
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 |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| include crowdsourcehinter_correct.png crowdsourcehinter_hint.png crowdsourcehinter_setup.png | ||
| include requirements/constraints.txt | ||
|
|
||
| prune .github | ||
| prune htmlcov | ||
| exclude .coverage coverage.xml |
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
This file was deleted.
Oops, something went wrong.
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,104 @@ | ||
| [build-system] | ||
| requires = ["setuptools", "setuptools-scm>8.1"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "crowdsourcehinter-xblock" | ||
| dynamic = ["version"] | ||
| description = "crowdsourcehinter XBlock" | ||
| readme = "README.md" | ||
| license = "AGPL-3.0" | ||
| license-files = ["LICENSE"] | ||
| requires-python = ">=3.12" | ||
| dependencies = [ | ||
| "six>=1.16.0", | ||
| "xblock>=6.2.0", | ||
| ] | ||
| keywords = ["crowdsourcehinter", "xblock"] | ||
| classifiers = [ | ||
| "Development Status :: 3 - Alpha", | ||
| "Intended Audience :: Developers", | ||
| "Topic :: Software Development :: Build Tools", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: Implementation :: CPython", | ||
| ] | ||
|
|
||
| [project.entry-points."xblock.v1"] | ||
| crowdsourcehinter = "crowdsourcehinter:CrowdsourceHinter" | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/openedx/crowdsourcehinter" | ||
|
|
||
| [tool.setuptools_scm] | ||
| version_scheme = "only-version" | ||
| local_scheme = "no-local-version" | ||
| fallback_version = "0.0.0.dev0" | ||
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["src"] | ||
| include = ["crowdsourcehinter*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| "crowdsourcehinter" = [ | ||
| "static/**", | ||
| "public/**", | ||
| ] | ||
|
|
||
| [tool.setuptools.exclude-package-data] | ||
| "*" = ["tests*", "*.tests*"] | ||
|
|
||
| [dependency-groups] | ||
| # Base test packages, no Django version pinned | ||
| test-base = ["pytest-cov"] | ||
| # Default test group: current supported Django version | ||
| test = [{include-group = "test-base"}, "Django>=5.2,<6.0"] | ||
| # Legacy Django 4.2 support | ||
| django42 = [{include-group = "test-base"}, "Django>=4.2,<5.0"] | ||
| quality = [{include-group = "test"}, "flake8"] | ||
| ci = ["tox", "tox-uv>=1"] | ||
| dev = [{include-group = "quality"}, {include-group = "ci"}] | ||
|
|
||
| [tool.uv] | ||
| package = true | ||
| default-groups = [] | ||
| conflicts = [ | ||
| [ | ||
| {group = "test"}, | ||
| {group = "django42"}, | ||
| ], | ||
| ] | ||
|
|
||
| # DO NOT EDIT constraint-dependencies DIRECTLY. | ||
| # This list is managed by `edx_lint write_uv_constraints` | ||
| # and will be overwritten the next time `make upgrade` is run. | ||
| # - GLOBAL constraints: edit edx_lint/files/common_constraints.txt | ||
| # - REPO-SPECIFIC constraints: edit [tool.edx_lint].uv_constraints in this file | ||
| constraint-dependencies = [ | ||
| "Django<6.0", | ||
| "elasticsearch<7.14.0", | ||
| ] | ||
| [tool.edx_lint] | ||
| uv_constraints = [] | ||
|
|
||
| [tool.coverage.run] | ||
| branch = true | ||
| source_pkgs = ["crowdsourcehinter"] | ||
| omit = ["*/tests/*", "*/migrations/*", "*/__pycache__/*"] | ||
|
|
||
| [tool.coverage.report] | ||
| show_missing = true | ||
| exclude_lines = [ | ||
| "pragma: no cover", | ||
| "def __repr__", | ||
| "raise AssertionError", | ||
| "raise NotImplementedError", | ||
| "if __name__ == .__main__.:", | ||
| "if TYPE_CHECKING:", | ||
| ] | ||
|
|
||
| [tool.coverage.html] | ||
| directory = "htmlcov" | ||
|
|
||
| [tool.semantic_release] | ||
| build_command = "python -m pip install --upgrade build && SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION python -m build" |
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| [pytest] | ||
| addopts = --cov . --cov-report term-missing --cov-report xml | ||
| addopts = --cov=crowdsourcehinter --cov-report term-missing --cov-report xml |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
CI should also run on merges to master to make sure we did have a bad merge.