diff --git a/.github/workflows/build_n_publish.yml b/.github/workflows/build_n_publish.yml new file mode 100644 index 0000000..1a4a70e --- /dev/null +++ b/.github/workflows/build_n_publish.yml @@ -0,0 +1,42 @@ +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + push: + tags: + - '*' + + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/wagtail-parler + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python3 -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish package distributions to PyPi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3c1a080 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,124 @@ +name: Wagtail Parler CI + +on: [push, pull_request] + +permissions: + pull-requests: write + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Current configuration: +# - python 3.7, django 3.2, wagtail 4.1 +# - python 3.7, django 3.2, wagtail 4.2 +# - python 3.7, django 3.2, wagtail 5.0 +# - python 3.9, django 4.2, wagtail 5.0 +# - python 3.9, django 4.2, wagtail 5.1 +# - python 3.11, django 4.2, wagtail 5.1 +# - python 3.11, django main, wagtail main + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + strategy: + matrix: + include: + - python: '3.7' + django: 'Django>=3.2,<3.3' + wagtail: 'wagtail>=4.1,<4.2' + experimental: false + - python: '3.7' + django: 'Django>=3.2,<3.3' + wagtail: 'wagtail>=4.2,<4.3' + experimental: false + - python: '3.7' + django: 'Django>=3.2,<3.3' + wagtail: 'wagtail>=5.0,<5.1' + experimental: false + - python: '3.9' + django: 'Django>=4.2,<4.3' + wagtail: 'wagtail>=5.0,<5.1' + experimental: false + - python: '3.9' + django: 'Django>=4.2,<4.3' + wagtail: 'wagtail>=5.1,<5.2' + experimental: false + - python: '3.11' + django: 'Django>=4.2,<4.3' + wagtail: 'wagtail>=5.1,<5.2' + experimental: false + - python: '3.11' + django: 'git+https://github.com/django/django.git@main#egg=Django' + wagtail: 'git+https://github.com/wagtail/wagtail.git@main#egg=wagtail' + experimental: true + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[testing] + pip install "${{ matrix.django }}" + pip install "${{ matrix.wagtail }}" + - name: Test + run: | + coverage run --parallel-mode ./runtests.py + - name: Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: .coverage.* + + qa: + needs: + - test + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install coverage black flake8 mypy types-requests + + - name: Check black + run: | + black --check ./ + + - name: Check flake8 + run: | + flake8 + + - name: Check mypy + run: | + mypy -p wagtail_parler + + - name: Download coverage data + uses: actions/download-artifact@v3 + with: + name: coverage-data + + - name: Save PR number and combine coverage data + run: | + mkdir -p ./pr + coverage combine + coverage report -m --format="markdown" > ./pr/coverage.md + coverage report --format="total" > ./pr/coverage_total + echo ${{ github.event.number }} > ./pr/NR + + - uses: actions/upload-artifact@v2 + with: + name: pr + path: pr/ diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 0000000..5401901 --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,69 @@ +name: QA + +on: + workflow_run: + workflows: ["Wagtail Parler CI"] + types: + - completed + +jobs: + qa: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: 'Download artifact' + uses: actions/github-script@v3.1.0 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "pr" + })[0]; + var download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); + - run: unzip pr.zip + + - name: 'Comment on PR v1' + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var issue_number = Number(fs.readFileSync('./NR')); + var coverage = fs.readFileSync('./coverage.md'); + var coverage_total = fs.readFileSync('./coverage_total'); + if (coverage_total == 100) { + emoji='🦄'; + } else if (coverage_total >= 95) { + emoji='🏆'; + } else if (coverage_total >= 90) { + emoji='🥇'; + } else if (coverage_total >= 85) { + emoji='🥈'; + } else if (coverage_total >= 80) { + emoji='🥉'; + } else { + emoji='❌'; + } + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: `
${emoji} coverage ${coverage_total} % + + ${coverage} + +
` + }); diff --git a/tbump.toml b/tbump.toml index fde61fd..c0a52b4 100644 --- a/tbump.toml +++ b/tbump.toml @@ -1,5 +1,5 @@ [version] -current = "0.0.0" +current = "0.1.0" # valid versions: # we use semver diff --git a/tox.ini b/tox.ini index 3fdb8e8..7cec310 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,8 @@ [tox] envlist = - py{37,39}-django32-wagtail{41,42,50}, - py{39,311}-django42-wagtail{50,51}, + py37-django32-wagtail{41,42,50}, + py39-django42-wagtail{50,51}, + py311-django42-wagtail51, ; py{39,311}-django42-wagtailmain qa diff --git a/wagtail_parler/__init__.py b/wagtail_parler/__init__.py index 6c8e6b9..3dc1f76 100644 --- a/wagtail_parler/__init__.py +++ b/wagtail_parler/__init__.py @@ -1 +1 @@ -__version__ = "0.0.0" +__version__ = "0.1.0"