generated from pimoroni/boilerplate-python
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repackage to match latest boilerplate.
- Loading branch information
Showing
34 changed files
with
461 additions
and
593 deletions.
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@v3 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make build-deps | ||
- name: Build Packages | ||
run: | | ||
make dist | ||
- name: Upload Packages | ||
uses: actions/upload-artifact@v3 | ||
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,32 @@ | ||
name: QA | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: linting & spelling | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python '3,11' | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make test-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,37 +1,41 @@ | ||
name: Python Tests | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Python ${{ matrix.python }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: [2.7, 3.5, 3.7, 3.9] | ||
python: ['3.9', '3.10', '3.11'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade setuptools tox | ||
make test-deps | ||
- name: Run Tests | ||
working-directory: library | ||
run: | | ||
tox -e py | ||
make pytest | ||
- name: Coverage | ||
if: ${{ matrix.python == '3.9' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
working-directory: library | ||
run: | | ||
python -m pip install coveralls | ||
coveralls --service github | ||
if: ${{ matrix.python == '3.9' }} | ||
coveralls --service=github | ||
File renamed without changes.
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,71 +1,68 @@ | ||
LIBRARY_VERSION=$(shell grep version library/setup.cfg | awk -F" = " '{print $$2}') | ||
LIBRARY_NAME=$(shell grep name library/setup.cfg | awk -F" = " '{print $$2}') | ||
PACKAGE_NAME=$(shell grep packages library/setup.cfg | awk -F" = " '{print $$2}') | ||
LIBRARY_NAME="ioexpander" | ||
LIBRARY_VERSION=$(shell grep __version__ ${LIBRARY_NAME}/__init__.py | awk -F" = " '{print substr($$2,2,length($$2)-2)}' | awk -F"." '{print $$1"."$$2"."$$3}') | ||
|
||
.PHONY: usage install uninstall | ||
.PHONY: usage install uninstall check pytest qa build-deps check tag wheel sdist clean dist testdeploy deploy | ||
usage: | ||
@echo "Library: ${LIBRARY_NAME}" | ||
@echo "Version: ${LIBRARY_VERSION}\n" | ||
@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 "check: peform basic integrity checks on the codebase" | ||
@echo "python-readme: generate library/README.md from README.md + library/CHANGELOG.txt" | ||
@echo "python-wheels: build python .whl files for distribution" | ||
@echo "python-sdist: build python source distribution" | ||
@echo "python-clean: clean python build and dist directories" | ||
@echo "python-dist: build all python distribution files" | ||
@echo "python-testdeploy: build all and deploy to test PyPi" | ||
@echo "tag: tag the repository with the current version" | ||
@echo "install: install the library locally from source" | ||
@echo "uninstall: uninstall the local library" | ||
@echo "build-deps: install essential python build dependencies" | ||
@echo "test-deps: install essential python test dependencies" | ||
@echo "check: perform basic integrity checks on the codebase" | ||
@echo "qa: run linting and package QA" | ||
@echo "pytest: run python test fixtures" | ||
@echo "wheel: build python .whl files for distribution" | ||
@echo "sdist: build python source distribution" | ||
@echo "clean: clean python build and dist directories" | ||
@echo "dist: build all python distribution files" | ||
@echo "testdeploy: build all and deploy to test PyPi" | ||
@echo "deploy: build all and deploy to PyPi" | ||
@echo "tag: tag the repository with the current version" | ||
|
||
install: | ||
./install.sh | ||
./install.sh --unstable | ||
|
||
uninstall: | ||
./uninstall.sh | ||
|
||
check: | ||
@echo "Checking for trailing whitespace" | ||
@! grep -IUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO | ||
@echo "Checking for DOS line-endings" | ||
@! grep -lIUrn --color "" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile | ||
@echo "Checking library/CHANGELOG.txt" | ||
@cat library/CHANGELOG.txt | grep ^${LIBRARY_VERSION} | ||
@echo "Checking library/${PACKAGE_NAME}/__init__.py" | ||
@cat library/${PACKAGE_NAME}/__init__.py | grep "^__version__ = '${LIBRARY_VERSION}'" | ||
build-deps: | ||
python3 -m pip install build | ||
|
||
tag: | ||
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}" | ||
test-deps: | ||
python3 -m pip install tox | ||
sudo apt install dos2unix | ||
|
||
python-readme: library/README.md | ||
check: | ||
@bash check.sh | ||
|
||
python-license: library/LICENSE.txt | ||
qa: | ||
tox -e qa | ||
|
||
library/README.md: README.md library/CHANGELOG.txt | ||
cp README.md library/README.md | ||
printf "\n\n# Changelog\n\n" >> library/README.md | ||
cat library/CHANGELOG.txt >> library/README.md | ||
pytest: | ||
tox -e py | ||
|
||
library/LICENSE.txt: LICENSE | ||
cp LICENSE library/LICENSE.txt | ||
nopost: | ||
@bash check.sh --nopost | ||
|
||
tag: | ||
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}" | ||
|
||
python-wheels: python-readme python-license | ||
cd library; python3 setup.py bdist_wheel | ||
cd library; python setup.py bdist_wheel | ||
wheel: check | ||
python3 -m build --wheel | ||
|
||
python-sdist: python-readme python-license | ||
cd library; python setup.py sdist | ||
sdist: check | ||
python3 -m build --sdist | ||
|
||
python-clean: | ||
-rm -r library/dist | ||
-rm -r library/build | ||
-rm -r library/*.egg-info | ||
clean: | ||
-rm -r dist | ||
|
||
python-dist: python-clean python-wheels python-sdist | ||
ls library/dist | ||
dist: clean wheel sdist | ||
ls dist | ||
|
||
python-testdeploy: python-dist | ||
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/* | ||
testdeploy: dist | ||
twine upload --repository-url https://test.pypi.org/legacy/ dist/* | ||
|
||
python-deploy: check python-dist | ||
twine upload library/dist/* | ||
deploy: nopost dist | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
# This script handles some basic QA checks on the source | ||
|
||
NOPOST=$1 | ||
LIBRARY_NAME="ioexpander" | ||
LIBRARY_VERSION=`grep __version__ $LIBRARY_NAME/__init__.py | awk -F" = " '{print substr($2,2,length($2)-2)}' | awk -F "." '{print $1"."$2"."$3}'` | ||
POST_VERSION=`grep __version__ $LIBRARY_NAME/__init__.py | awk -F" = " '{print substr($2,2,length($2)-2)}' | 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 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.