Merge pull request #64 from washeck/django50 #331
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
name: Tests & Publish | |
on: | |
push: | |
branches-ignore: | |
- '*-no-ci' | |
tags: | |
- '*' | |
pull_request: | |
schedule: | |
# * is a special character in YAML and must be quoted | |
- cron: '55 2 */7 * *' | |
# Manually triggered workflow | |
workflow_dispatch: | |
inputs: | |
target_repo: | |
description: 'The repository to publish the package' | |
required: true | |
default: 'pypi.org' | |
type: choice | |
options: | |
- pypi.org | |
- test.pypi.org | |
env: | |
# Note: Poetry 1.2.* requires Python >= 3.7 | |
# Poetry 1.6.* requires Python >= 3.8 | |
INSTALL_POETRY_VERSION: 1.5.* | |
POETRY_INSTALLER_PARALLEL: true | |
POETRY_VIRTUALENVS_CREATE: true | |
# Hide warning about outdated pip version | |
PIP_DISABLE_PIP_VERSION_CHECK: 1 | |
jobs: | |
debug: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print env information | |
run: | | |
echo "github.event_name = ${{ github.event_name }}" | |
echo "github.ref = ${{ github.ref }}" | |
echo "is a tag = ${{ startsWith(github.ref, 'refs/tags/') }}" | |
echo "is a manual run = ${{ github.event.inputs.target_repo != '' }}" | |
tests: | |
name: Python ${{ matrix.python }} × Django ${{ matrix.django }} | |
runs-on: ubuntu-latest | |
needs: debug | |
strategy: | |
matrix: | |
python: ["3.12", "3.11", "3.10", "3.9", "3.8", "3.7"] | |
django: ["5.0", "4.2", "4.1", "4.0", "3.2", "3.1", "3.0", "2.2", "2.1"] | |
exclude: | |
# See https://docs.djangoproject.com/en/4.2/faq/install/#what-python-version-can-i-use-with-django | |
# See https://docs.djangoproject.com/en/3.2/faq/install/#what-python-version-can-i-use-with-django | |
# See https://docs.djangoproject.com/en/2.2/faq/install/#what-python-version-can-i-use-with-django | |
- { python: "3.12", django: "4.1" } | |
- { python: "3.12", django: "4.0" } | |
- { python: "3.12", django: "3.2" } | |
- { python: "3.12", django: "3.1" } | |
- { python: "3.12", django: "3.0" } | |
- { python: "3.12", django: "2.2" } | |
- { python: "3.12", django: "2.1" } | |
- { python: "3.11", django: "4.0" } | |
- { python: "3.11", django: "3.2" } | |
- { python: "3.11", django: "3.1" } | |
- { python: "3.11", django: "3.0" } | |
- { python: "3.11", django: "2.2" } | |
- { python: "3.11", django: "2.1" } | |
- { python: "3.10", django: "3.1" } | |
- { python: "3.10", django: "3.0" } | |
- { python: "3.10", django: "2.2" } | |
- { python: "3.10", django: "2.1" } | |
- { python: "3.9", django: "5.0" } | |
- { python: "3.9", django: "2.1" } | |
- { python: "3.8", django: "5.0" } | |
- { python: "3.8", django: "2.1" } | |
- { python: "3.7", django: "5.0" } | |
- { python: "3.7", django: "4.2" } | |
- { python: "3.7", django: "4.1" } | |
- { python: "3.7", django: "4.0" } | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ env.INSTALL_POETRY_VERSION }} | |
- name: Install dependencies in Python ${{ matrix.python }} environment | |
run: | | |
poetry install --no-interaction | |
poetry run pip install -U "django==${{ matrix.django }}.*" | |
- name: Pytest | |
run: | | |
echo "Django version: $(poetry run django-admin --version)" | |
poetry run pytest --cov=modernrpc --cov-report=term --cov-report=xml:coverage.xml . | |
- name: Upload coverage results | |
if: github.event_name != 'pull_request' | |
continue-on-error: true | |
run: | | |
pip install codacy-coverage coveralls | |
# Submit coverage results to codacy.com | |
python-codacy-coverage -r coverage.xml | |
# Submit coverage results to coveralls | |
coveralls | |
env: | |
CODACY_PROJECT_TOKEN : ${{ secrets.CODACY_PROJECT_TOKEN }} | |
COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_REPO_TOKEN }} | |
black: | |
runs-on: ubuntu-latest | |
needs: debug | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ env.INSTALL_POETRY_VERSION }} | |
- name: Install dependencies | |
run: poetry install --no-interaction --with code-analysis | |
- name: Black (check) | |
run: poetry run black --check . | |
mypy: | |
runs-on: ubuntu-latest | |
needs: debug | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ env.INSTALL_POETRY_VERSION }} | |
- name: Install dependencies | |
run: poetry install --no-interaction --with code-analysis | |
- name: Mypy | |
run: poetry run mypy . | |
linters: | |
runs-on: ubuntu-latest | |
needs: debug | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ env.INSTALL_POETRY_VERSION }} | |
- name: Install dependencies | |
run: poetry install --no-interaction --with code-analysis | |
- name: Ruff | |
run: poetry run ruff check . | |
- name: Pylint | |
run: poetry run pylint --exit-zero modernrpc | |
publish: | |
runs-on: ubuntu-latest | |
needs: [tests, black, mypy, linters] | |
# Only ran on tag push and manual trigger | |
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event.inputs.target_repo != '' | |
env: | |
# inputs.target_repo is set only when workflow was manually triggered. Default to 'pypi.org' for tags push | |
pypi_repository: ${{ github.event.inputs.target_repo || 'pypi.org' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ env.INSTALL_POETRY_VERSION }} | |
- name: Publish on Pypi | |
if: env.pypi_repository == 'pypi.org' | |
run: | | |
echo "Publish on ${{ env.pypi_repository }}" | |
poetry publish --build -u __token__ -p ${{ secrets.PYPI_AUTH_TOKEN }} | |
- name: Publish on TestPypi | |
if: env.pypi_repository == 'test.pypi.org' | |
run: | | |
echo "Publish on ${{ env.pypi_repository }}" | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry publish --build -u __token__ -p ${{ secrets.PYPI_AUTH_TOKEN_TEST }} -r testpypi |