-
Notifications
You must be signed in to change notification settings - Fork 25
Modernize Python repo: pyproject.toml + uv + semantic-release #388
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
base: master
Are you sure you want to change the base?
Changes from all commits
720583e
9010c2d
0a07f1d
4ea922c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| 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: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.ref_name }} | ||
|
|
||
| - name: Reset to triggered commit | ||
| 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[bot]" | ||
| git_committer_email: "github-actions[bot]@users.noreply.github.com" | ||
| changelog: "false" | ||
|
|
||
| - name: Upload dist artifacts | ||
| 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 }} | ||
|
|
||
| publish_to_pypi: | ||
| needs: release | ||
| if: needs.release.outputs.released == 'true' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Download dist artifacts | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ pip-log.txt | |
|
|
||
| # Unit test / coverage reports | ||
| .coverage | ||
| coverage.xml | ||
| .tox | ||
| nosetests.xml | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,2 @@ | ||
| include requirements/base.in | ||
| include NOTICE | ||
| include LICENSE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove this |
||
| include requirements/constraints.txt | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,57 +4,33 @@ REPO_NAME := DoneXBlock | |
| DOCKER_NAME := donexblock | ||
|
|
||
| # For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html | ||
| BROWSER := python -m webbrowser file://$(CURDIR)/ | ||
| BROWSER := uv run python -m webbrowser file://$(CURDIR)/ | ||
|
|
||
| help: ## display this help message | ||
| @echo "Please use \`make <target>' where <target> is one of" | ||
| @awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort | ||
|
|
||
| install-test: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have decided to not to drop the make file targets, we can provide their alternatives. |
||
| pip install -q -r requirements/test.txt | ||
|
|
||
| install-dev: | ||
| pip install -q -r requirements/dev.txt | ||
|
|
||
| install: install-test | ||
|
|
||
| quality: ## Run the quality checks | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are not adding ruff in this scope because it needs to add more files formatting, so i removed that. |
||
| pylint --rcfile=pylintrc done | ||
| python setup.py -q sdist | ||
| twine check dist/* | ||
| uv run pylint --rcfile=pylintrc src/done | ||
| uv run python -m build --sdist | ||
| uv run twine check dist/* | ||
|
|
||
| test: ## Run the tests | ||
| mkdir -p var | ||
| rm -rf .coverage | ||
| python -m coverage run --rcfile=.coveragerc -m pytest | ||
| uv run python -m coverage run -m pytest | ||
| uv run python -m coverage xml | ||
|
|
||
| covreport: ## Show the coverage results | ||
| python -m coverage report -m --skip-covered | ||
|
|
||
| upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade | ||
| upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in | ||
| pip install -q -r requirements/pip-tools.txt | ||
| pip install -q -r requirements/pip.txt | ||
| pip-compile --upgrade --allow-unsafe -o requirements/pip.txt requirements/pip.in | ||
| pip-compile --upgrade -o requirements/pip-tools.txt requirements/pip-tools.in | ||
| pip install -q -r requirements/pip.txt | ||
| pip install -q -r requirements/pip-tools.txt | ||
| pip-compile --upgrade -o requirements/base.txt requirements/base.in | ||
| pip-compile --upgrade -o requirements/dev.txt requirements/dev.in | ||
| pip-compile --upgrade -o requirements/test.txt requirements/test.in | ||
| pip-compile --upgrade -o requirements/quality.txt requirements/quality.in | ||
| pip-compile --upgrade -o requirements/tox.txt requirements/tox.in | ||
| pip-compile --upgrade -o requirements/ci.txt requirements/ci.in | ||
| pip-compile --upgrade -o requirements/docs.txt requirements/docs.in | ||
| # lets tox controls the django versions. | ||
| sed -i.tmp '/^[d|D]jango==/d' requirements/test.txt | ||
| rm requirements/test.txt.tmp | ||
| uv run python -m coverage report -m --skip-covered | ||
|
|
||
| upgrade: ## update uv.lock and regenerate uv constraint-dependencies | ||
| uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml | ||
| uv lock --upgrade | ||
|
|
||
| .PHONY: requirements | ||
| requirements: ## install development environment requirements | ||
| pip install -r requirements/pip.txt | ||
| pip install -qr requirements/pip-tools.txt | ||
| pip install -r requirements/dev.txt | ||
| uv sync --group dev | ||
|
|
||
| dev.clean: | ||
| -docker rm $(DOCKER_NAME)-dev | ||
|
|
@@ -68,7 +44,7 @@ dev.run: dev.clean dev.build ## Clean, build and run test image | |
|
|
||
| ## Localization targets | ||
|
|
||
| WORKING_DIR := done | ||
| WORKING_DIR := src/done | ||
| EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES | ||
| EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po | ||
| EXTRACTED_TEXT := $(EXTRACT_DIR)/django.po | ||
|
|
||
This file was deleted.
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.
we should update it to latest version