-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add workflows for Python projects (#175)
# Description Adds a default workflow to build Python projects and publish them to PyPi.org.
- Loading branch information
Showing
6 changed files
with
202 additions
and
9 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CODEOWNERS | ||
Hapag | ||
nullglob | ||
pypi |
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,77 @@ | ||
--- | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
|
||
# USE_WORKFLOW | ||
# yamllint disable rule:comments | ||
# yamllint disable-line rule:truthy | ||
on: | ||
workflow_call: | ||
inputs: | ||
pypi-url: | ||
type: string | ||
required: true | ||
description: "The URL of the PyPI project, e.g. https://pypi.org/p/my-fancy-package" | ||
python-version: | ||
type: string | ||
required: true | ||
description: "The minimum Python version to support" | ||
# /USE_WORKFLOW | ||
# USE_REPOSITORY | ||
## | ||
## Global variables from project settings: | ||
## PYPI_URL: The URL of the PyPI project, e.g. https://pypi.org/p/my-fancy-package | ||
## PYTHON_VERSION: The minimum Python version to support. | ||
## | ||
# | ||
## yamllint disable-line rule:truthy | ||
#on: | ||
# release: | ||
# types: [published] | ||
# /USE_REPOSITORY | ||
# yamllint enable rule:comments | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
cache: "pip" | ||
cache-dependency-path: setup.cfg | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m pip install build --user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: ${{ inputs.pypi-url }} | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | ||
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,83 @@ | ||
--- | ||
name: Python build | ||
|
||
# USE_WORKFLOW | ||
# yamllint disable rule:comments | ||
# yamllint disable-line rule:truthy | ||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
type: string | ||
required: true | ||
description: "The minimum Python version to support" | ||
python-versions: | ||
type: string | ||
required: true | ||
description: "The Python versions to test. Usually a list of newer versions we support." | ||
# /USE_WORKFLOW | ||
# USE_REPOSITORY | ||
## | ||
## Global variables from project settings: | ||
## PYTHON_VERSION: The minimum Python version to support. | ||
## PYTHON_VERSIONS: The Python versions to test. Usually a list of newer versions we support. | ||
## | ||
# | ||
## yamllint disable-line rule:truthy | ||
#on: pull_request | ||
# /USE_REPOSITORY | ||
# yamllint enable rule:comments | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
cache: "pip" | ||
cache-dependency-path: setup.cfg | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install -e "." | ||
- uses: astral-sh/ruff-action@e6390afda04da2e9ef69fe1e2ae0264164550c21 # v3.0.1 | ||
name: Lint on ${{ inputs.python-version }} | ||
with: | ||
args: "check" | ||
# renovate: datasource=github-releases depName=astral-sh/ruff | ||
version: "0.8.6" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ${{ fromJSON(inputs.python-versions) }} | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
cache-dependency-path: setup.cfg | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install -e ".[test]" | ||
- name: Run docker-compose | ||
uses: hoverkraft-tech/compose-action@v2.0.1 | ||
with: | ||
compose-file: "./tests/docker-compose.yml" | ||
|
||
- name: Test on ${{ matrix.python-version }} | ||
run: | | ||
pytest -v --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html |
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