-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
352 additions
and
80 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
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,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
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,99 @@ | ||
name: Publish Python distribution to PyPI | ||
|
||
on: | ||
push: | ||
tags: ['v*.*.*'] | ||
|
||
jobs: | ||
build: | ||
name: Build distribution | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: build | ||
run: make build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
release: | ||
name: Release to Github | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 5 | ||
- run: | | ||
gh release create "${{ github.ref_name }}" --verify-tag | ||
env: | ||
GITHUB_TOKEN: ${{ github.TOKEN }} | ||
shell: bash | ||
name: Create a release in GitHub | ||
sign: | ||
name: >- | ||
Sign the Python distribution | ||
and upload them to GitHub Release | ||
needs: | ||
- release | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/gh-action-sigstore-python@v2.0.1 | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' | ||
publish-to-pypi: | ||
name: Publish Python distribution to PyPI | ||
needs: | ||
- sign | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/httplint | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
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,35 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 2 | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache venv | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: ${{ runner.os }}-${{ matrix.python-version }}-venv-${{ hashFiles('**/requirements.txt') }} | ||
- name: Set up venv | ||
run: make venv | ||
- name: Typecheck | ||
run: make typecheck | ||
- name: Lint | ||
run: make lint |
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 |
---|---|---|
|
@@ -8,4 +8,4 @@ __pycache__ | |
/.mypy_cache | ||
/.pytest_cache | ||
/.venv | ||
/httplint.egg-info | ||
/*.egg-info |
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,19 @@ | ||
Copyright (c) Mark Nottingham | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,50 +1,18 @@ | ||
PROJECT=httplint | ||
PROJECT = httplint | ||
|
||
# for running from IDEs (e.g., TextMate) | ||
.PHONY: run | ||
run: test | ||
|
||
.PHONY: test | ||
test: $(TESTS) venv | ||
PYTHONPATH=.:$(VENV) $(VENV)/python test/smoke.py | ||
PYTHONPATH=.:$(VENV) $(VENV)/python test/syntax.py | ||
|
||
.PHONY: typecheck | ||
typecheck: venv | ||
PYTHONPATH=$(VENV) $(VENV)/python -m mypy $(PROJECT) | ||
|
||
.PHONY: tidy | ||
tidy: venv | ||
$(VENV)/black $(PROJECT) | ||
|
||
.PHONY: lint | ||
lint: venv | ||
PYTHONPATH=$(VENV) $(VENV)/pylint --output-format=colorized $(PROJECT) | ||
|
||
.PHONY: clean | ||
clean: | ||
find . -d -type d -name __pycache__ -exec rm -rf {} \; | ||
rm -rf build dist MANIFEST $(PROJECT).egg-info .venv .mypy_cache *.log | ||
|
||
|
||
############################################################################# | ||
## Distribution | ||
clean: clean_py | ||
|
||
.PHONY: version | ||
version: venv | ||
$(eval VERSION=$(shell $(VENV)/python -c "import $(PROJECT); print($(PROJECT).__version__)")) | ||
.PHONY: lint | ||
lint: lint_py | ||
|
||
.PHONY: build | ||
build: clean venv | ||
$(VENV)/python -m build | ||
.PHONY: typecheck | ||
typecheck: typecheck_py | ||
|
||
.PHONY: upload | ||
upload: build test typecheck version | ||
git tag $(PROJECT)-$(VERSION) | ||
git push | ||
git push --tags origin | ||
$(VENV)/python -m twine upload dist/* | ||
.PHONY: tidy | ||
tidy: tidy_py | ||
|
||
|
||
|
||
include Makefile.venv | ||
include Makefile.pyproject |
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,118 @@ | ||
# | ||
# Common Makefile for Python projects | ||
# | ||
# | ||
# Insert `include Makefile.pyproject` at the bottom of your Makefile to enable these | ||
# rules. Requires Makefile.venv to also be present. | ||
# | ||
# Requires $PROJECT to be set to the name of the project, and for that to be the source folder. | ||
# | ||
# This Makefile provides the following targets: | ||
# | ||
# clean_py | ||
# Clean Python-related temporary files | ||
# tidy_py | ||
# Run black on Python files in $PROJECT | ||
# lint_py | ||
# Run pylint on $PROJECT, and validate pyproject.toml | ||
# typecheck_py | ||
# Run mypy on $PROJECT | ||
# bump-calver | ||
# Bump the __version__ in $PROJECT/__init__.py using calver (https://calver.org/) | ||
# bump-semver-[major,minor,micro] | ||
# Bump the __version__ in $PROJECT/__init__.py using semver (https://semver.org/) | ||
# build | ||
# Build the project | ||
# release | ||
# Release the project on Pypi and Github releases (requires /.github/workflows/release.yml) | ||
# | ||
# See also Makefile.venv. | ||
# | ||
# | ||
# Make sure the following are in requirements.txt: | ||
# - pylint | ||
# - mypy | ||
# - black | ||
# - build | ||
# - validate-pyproject | ||
|
||
|
||
YEAR=`date +%Y` | ||
MONTH=`date +%m` | ||
|
||
|
||
.PHONY: clean_py | ||
clean_py: clean-venv | ||
find . -d -type d -name __pycache__ -exec rm -rf {} \; | ||
rm -rf build dist MANIFEST $(PROJECT).egg-info .mypy_cache *.log | ||
|
||
.PHONY: tidy_py | ||
tidy_py: venv | ||
$(VENV)/black $(PROJECT) | ||
|
||
.PHONY: lint_py | ||
lint_py: venv | ||
PYTHONPATH=$(VENV) $(VENV)/pylint --output-format=colorized $(PROJECT) | ||
$(VENV)/validate-pyproject pyproject.toml | ||
|
||
.PHONY: typecheck_py | ||
typecheck_py: venv | ||
PYTHONPATH=$(VENV) $(VENV)/python -m mypy $(PROJECT) | ||
|
||
## Distribution | ||
|
||
.PHONY: version_py | ||
version_py: venv | ||
$(eval VERSION=$(shell $(VENV)/python -c "import $(PROJECT); print($(PROJECT).__version__)")) | ||
$(eval VER_MAJOR=$(shell echo $(VERSION) | cut -d. -f1)) | ||
$(eval VER_MINOR=$(shell echo $(VERSION) | cut -d. -f2)) | ||
$(eval VER_MICRO=$(shell echo $(VERSION) | cut -d. -f3)) | ||
## for calendar-based versioning | ||
$(eval NEXT_CALMICRO=$(shell \ | ||
if [[ $(YEAR) != $(VER_MAJOR) || $(MONTH) != $(VER_MINOR) ]] ; then \ | ||
echo "1"; \ | ||
else \ | ||
echo $$(( $(VER_MICRO) + 1 )); \ | ||
fi; \ | ||
)) | ||
## for semantic versioning | ||
$(eval NEXT_SEMMAJOR=$(shell \ | ||
echo $$(( $(VER_MAJOR) + 1 )); \ | ||
)) | ||
$(eval NEXT_SEMMINOR=$(shell \ | ||
echo $$(( $(VER_MINOR) + 1 )); \ | ||
)) | ||
$(eval NEXT_SEMMICRO=$(shell \ | ||
echo $$(( $(VER_MICRO) + 1 )); \ | ||
)) | ||
|
||
.PHONY: bump-calver | ||
bump-calver: version_py | ||
sed -i "" -e "s/$(VERSION)/$(YEAR).$(MONTH).$(NEXT_CALMICRO)/" $(PROJECT)/__init__.py | ||
|
||
.PHONY: bump-semver-micro | ||
bump-semver-micro: version_py | ||
sed -i "" -e "s/$(VERSION)/$(VER_MAJOR).$(VER_MINOR).$(NEXT_SEMMICRO)/" $(PROJECT)/__init__.py | ||
|
||
.PHONY: bump-semver-minor | ||
bump-semver-minor: version_py | ||
sed -i "" -e "s/$(VERSION)/$(VER_MAJOR).$(NEXT_SEMMINOR).0/" $(PROJECT)/__init__.py | ||
|
||
.PHONY: bump-semver-major | ||
bump-semver-major: version_py | ||
sed -i "" -e "s/$(VERSION)/$(NEXT_SEMMAJOR).0.0/" $(PROJECT)/__init__.py | ||
|
||
|
||
.PHONY: build | ||
build: clean venv | ||
$(VENV)/python -m build | ||
|
||
# requires /.github/workflows/release.yml | ||
.PHONY: release | ||
release: typecheck_py lint_py test version_py | ||
git tag -a "v$(VERSION)" -m "v$(VERSION)" | ||
git push | ||
git push --tags origin # github action will push to pypi and create a release | ||
|
||
|
||
include Makefile.venv |
Oops, something went wrong.