Setup basic test suite #10
Workflow file for this run
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: Test & Lint | |
# Inspired by https://github.com/wagtail/wagtail-bakery/blob/0bfff2a7446e6119156279d22cfac2137960145d/.github/workflows/test.yml | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_call: # Allow for the publish workflows to run the tests by calling this workflow | |
env: | |
FORCE_COLOR: "1" # Make tools pretty. | |
TOX_TESTENV_PASSENV: FORCE_COLOR | |
PIP_DISABLE_PIP_VERSION_CHECK: "1" | |
PIP_NO_PYTHON_VERSION_WARNING: "1" | |
jobs: | |
qa_javascript: | |
name: Build JavaScript | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# Disabled because there is an issue caching dependencies, probably related to this action. | |
# Possibly related: https://github.com/actions/setup-node/issues/1137 | |
# cache: "yarn" | |
# cache-dependency-path: client/yarn.lock | |
- name: Install dependencies | |
working-directory: client | |
run: | | |
yarn install --frozen-lockfile | |
- name: Compile JavaScript | |
working-directory: client | |
run: | | |
yarn build | |
pre-commit: | |
name: Run pre-commit hooks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
cache: "pip" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: pre-commit/action@v3.0.1 | |
test_python: | |
name: Test on Python ${{ matrix.python}} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: "pip" | |
- name: Install additional system packages | |
run: | | |
sudo apt-get update -y | |
# Need `gettext` to compile translations | |
sudo apt-get install gettext | |
- name: Install dependencies | |
run: | | |
python -m pip install .[testing] tox coverage | |
- name: Compile translations | |
run: /bin/sh ./compile_translations.sh | |
# This step runs only for jobs NOT in the include matrix | |
- name: Run tox targets for Python ${{ matrix.python }} | |
run: | | |
# Run only the tox environments that match the Python version | |
tox run -f py$(echo ${{ matrix.python }} | tr -d .) | |
coverage combine | |
coverage report | |
# Codecov does not support the .coverage file generated by coverage. | |
# so we convert it to xml | |
coverage xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |