From d7b3b6db43d476155c7765e12b9b40757cb74cef Mon Sep 17 00:00:00 2001 From: Conor Holden Date: Wed, 30 Oct 2024 17:24:56 +0100 Subject: [PATCH] :construction_worker: update GitHub actions --- .github/workflows/ci.yml | 65 ++++++++++++++++++------------ .github/workflows/code_quality.yml | 33 +++++++++++++++ 2 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/code_quality.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99e6171..6df67c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,41 +13,54 @@ on: jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.10', '3.11', '3.12'] + django: ['4.2'] - name: Test the creation of a Django project from the template + name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}) steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: ${{ matrix.python }} - - name: Install Django 4.2 - run: pip install django~=4.2.0 + - name: Install dependencies + run: pip install tox tox-gh-actions - - name: Run the startproject command - run: | - mkdir tmp - django-admin startproject \ - --template . \ - --extension=py-tpl,rst,gitignore,in,ini,cfg,toml,yml,yaml \ - --name LICENSE \ - -x tmp \ - -x .github \ - defaultapp tmp/ - - - name: Run basic checks (following README instructions) - run: | - pip install -e .[tests] - django-admin check - pytest + - name: Run tests + run: tox env: - PYTHONPATH: . - DJANGO_SETTINGS_MODULE: testapp.settings - working-directory: tmp + PYTHON_VERSION: ${{ matrix.python }} + DJANGO: ${{ matrix.django }} + + - name: Publish coverage report + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + publish: + name: Publish package to PyPI + runs-on: ubuntu-latest + needs: tests + environment: release + permissions: + id-token: write + + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - - name: Run dummy package build + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Build sdist and wheel run: | - pip install build + pip install build --upgrade python -m build - working-directory: tmp + + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 0000000..0433b75 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,33 @@ +name: Code quality checks + +# Run this workflow every time a new commit pushed to your repository +on: + push: + branches: + - main + tags: + - '*' + paths: + - '**.py' + pull_request: + paths: + - '**.py' + workflow_dispatch: + +jobs: + linting: + name: Code-quality checks + runs-on: ubuntu-latest + strategy: + matrix: + toxenv: [isort, black, flake8, docs] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: pip install tox + - run: tox + env: + TOXENV: ${{ matrix.toxenv }}