-
Notifications
You must be signed in to change notification settings - Fork 48
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
Repackage to hatch/pyproject.toml #31
Open
Gadgetoid
wants to merge
9
commits into
vitiral:master
Choose a base branch
from
Gadgetoid:repackage
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.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f0e091c
Repackage to hatch/pyproject.toml
Gadgetoid 2feea75
QA: Apply isort suggestions.
Gadgetoid dfae0ca
QA: Apply ruff/black code reformatting suggestions.
Gadgetoid 8e34198
QA: Apply codespell suggestions.
Gadgetoid b341f7a
Packaging: Remove MANIFEST.in
Gadgetoid ac6a1a9
Packaging: Bump required Python version to 3.7.
Gadgetoid b46acb2
Fix permissions error for /sys/class/gpio/export
aSmig 6cceb44
CI: Update tests to match new filemodes.
Gadgetoid c4b9a92
CI: Bump actions versions.
Gadgetoid 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 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,41 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Python ${{ matrix.python }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ['3.9', '3.10', '3.11'] | ||
|
||
env: | ||
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make dev-deps | ||
|
||
- name: Build Packages | ||
run: | | ||
make build | ||
|
||
- name: Upload Packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.RELEASE_FILE }} | ||
path: dist/ |
This file contains 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,36 @@ | ||
name: QA | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: linting & spelling | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TERM: xterm-256color | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python '3,11' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make dev-deps | ||
|
||
- name: Run Quality Assurance | ||
run: | | ||
make qa | ||
|
||
- name: Run Code Checks | ||
run: | | ||
make check |
This file contains 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,32 +1,41 @@ | ||
name: Python Tests | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Python ${{ matrix.python }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: [2.7,3.9] | ||
python: ['3.9', '3.10', '3.11'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade setuptools tox | ||
make dev-deps | ||
|
||
- name: Run Tests | ||
run: | | ||
tox -e py | ||
make pytest | ||
|
||
- name: Coverage | ||
if: ${{ matrix.python == '3.9' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
python -m pip install coveralls | ||
coveralls --service=github | ||
if: ${{ matrix.python == '3.9' }} | ||
|
This file contains 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,26 @@ | ||
2.0.0 | ||
----- | ||
|
||
* Repackage to hatch/pyproject.toml | ||
|
||
1.0.0 | ||
----- | ||
|
||
* Fix overwriting of logging config | ||
* Add active low support | ||
* Performance optimisations and code cleanup | ||
|
||
0.3.0 | ||
----- | ||
|
||
* RPi.GPIO compatibility for cleanup() | ||
|
||
0.2.0 | ||
----- | ||
|
||
* N/A | ||
|
||
0.1.2 | ||
----- | ||
|
||
* N/A |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains 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,60 @@ | ||
LIBRARY_NAME := $(shell hatch project metadata name 2> /dev/null) | ||
LIBRARY_VERSION := $(shell hatch version 2> /dev/null) | ||
|
||
.PHONY: usage install uninstall check pytest qa build-deps check tag wheel sdist clean dist testdeploy deploy | ||
usage: | ||
ifdef LIBRARY_NAME | ||
@echo "Library: ${LIBRARY_NAME}" | ||
@echo "Version: ${LIBRARY_VERSION}\n" | ||
else | ||
@echo "WARNING: You should 'make dev-deps'\n" | ||
endif | ||
@echo "Usage: make <target>, where target is one of:\n" | ||
@echo "install: install the library locally from source" | ||
@echo "uninstall: uninstall the local library" | ||
@echo "dev-deps: install Python dev dependencies" | ||
@echo "check: perform basic integrity checks on the codebase" | ||
@echo "qa: run linting and package QA" | ||
@echo "pytest: run Python test fixtures" | ||
@echo "clean: clean Python build and dist directories" | ||
@echo "build: build Python distribution files" | ||
@echo "testdeploy: build and upload to test PyPi" | ||
@echo "deploy: build and upload to PyPi" | ||
@echo "tag: tag the repository with the current version\n" | ||
|
||
install: | ||
python3 -m pip install . | ||
|
||
uninstall: | ||
python3 -m pip uninstall ${LIBRARY_NAME} | ||
|
||
dev-deps: | ||
python3 -m pip install -r requirements-dev.txt | ||
sudo apt install dos2unix | ||
|
||
check: | ||
@bash check.sh | ||
|
||
qa: | ||
tox -e qa | ||
|
||
pytest: | ||
tox -e py | ||
|
||
nopost: | ||
@bash check.sh --nopost | ||
|
||
tag: | ||
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}" | ||
|
||
build: check | ||
@hatch build | ||
|
||
clean: | ||
-rm -r dist | ||
|
||
testdeploy: build | ||
twine upload --repository testpypi dist/* | ||
|
||
deploy: nopost build | ||
twine upload dist/* |
This file contains 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 contains 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,87 @@ | ||
#!/bin/bash | ||
|
||
# This script handles some basic QA checks on the source | ||
|
||
NOPOST=$1 | ||
LIBRARY_NAME=`hatch project metadata name` | ||
LIBRARY_VERSION=`hatch version | awk -F "." '{print $1"."$2"."$3}'` | ||
POST_VERSION=`hatch version | awk -F "." '{print substr($4,0,length($4))}'` | ||
|
||
success() { | ||
echo -e "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
inform() { | ||
echo -e "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
warning() { | ||
echo -e "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
K="$1" | ||
case $K in | ||
-p|--nopost) | ||
NOPOST=true | ||
shift | ||
;; | ||
*) | ||
if [[ $1 == -* ]]; then | ||
printf "Unrecognised option: $1\n"; | ||
exit 1 | ||
fi | ||
POSITIONAL_ARGS+=("$1") | ||
shift | ||
esac | ||
done | ||
|
||
inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n" | ||
|
||
inform "Checking for trailing whitespace..." | ||
grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO | ||
if [[ $? -eq 0 ]]; then | ||
warning "Trailing whitespace found!" | ||
exit 1 | ||
else | ||
success "No trailing whitespace found." | ||
fi | ||
printf "\n" | ||
|
||
inform "Checking for DOS line-endings..." | ||
grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile | ||
if [[ $? -eq 0 ]]; then | ||
warning "DOS line-endings found!" | ||
exit 1 | ||
else | ||
success "No DOS line-endings found." | ||
fi | ||
printf "\n" | ||
|
||
inform "Checking CHANGELOG.md..." | ||
cat CHANGELOG.md | grep ^${LIBRARY_VERSION} > /dev/null 2>&1 | ||
if [[ $? -eq 1 ]]; then | ||
warning "Changes missing for version ${LIBRARY_VERSION}! Please update CHANGELOG.md." | ||
exit 1 | ||
else | ||
success "Changes found for version ${LIBRARY_VERSION}." | ||
fi | ||
printf "\n" | ||
|
||
inform "Checking for git tag ${LIBRARY_VERSION}..." | ||
git tag -l | grep -E "${LIBRARY_VERSION}$" | ||
if [[ $? -eq 1 ]]; then | ||
warning "Missing git tag for version ${LIBRARY_VERSION}" | ||
fi | ||
printf "\n" | ||
|
||
if [[ $NOPOST ]]; then | ||
inform "Checking for .postN on library version..." | ||
if [[ "$POST_VERSION" != "" ]]; then | ||
warning "Found .$POST_VERSION on library version." | ||
inform "Please only use these for testpypi releases." | ||
exit 1 | ||
else | ||
success "OK" | ||
fi | ||
fi |
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.
typically this kind of thing should NOT be in a makefile. Where is this even used?
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.
Say what? You can put whatever you want in a Makefile 🤣
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.
Or, to more specifically answer your question, where do you put this kind of thing?
This is used in the GitHub workflows to avoid encoding common patterns in GitHub's nonsense yml format. Plus it also makes most of the things you'd want to do during development a
make x
away.The alternative (and a common CI pattern) is to use a shell script, but that has its own unique set of warts and is obnoxiously painful to invoke on a local machine (
source ci/tools.sh && run_some_ci_action
vs justmake run_some_ci_action
),This is a pattern I use across all my libraries so I don't have to know or care how to invoke a bunch of arcane commands. Though, granted,
sudo apt install dos2unix
is very Debian-linux specific which is great for GitHub actions but not so great for hypothetical macOS using developers aaannnd I'm totally not writing this from a mac now 👀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.
I would typically put it in you developer setup documentation. I won't block the CL on this