CI: Move lint and docs to separate action for readability

Currently, linting is done in one specific job of the big test Matrix, and
it's very easy to overlook.  But we want linting to be the first thing to fix.

Also reorganize and rename jobs for readability.

Finally, use python 3.11 for lint/docs because python 3.12 seems to break dev install.
This commit is contained in:
Baptiste Jonglez 2024-03-25 20:03:12 +01:00 committed by zorun
parent 4af4c10b1f
commit 73f014e90e
4 changed files with 55 additions and 10 deletions

View file

@ -1,4 +1,4 @@
name: CI to Docker Hub
name: Docker build
on:
push:
@ -18,7 +18,7 @@ jobs:
- name: Test image # Checks we are able to run the container.
run: docker compose -f docker-compose.test.yml run sut
build:
build_upload:
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request'

42
.github/workflows/lint-docs.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Lint & Docs
on:
push:
branches: [ 'master', 'stable-*' ]
pull_request:
branches: [ 'master', 'stable-*' ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Run Lint
run: tox -e lint
test_doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Check we can generate documentation
run: tox -e docs

View file

@ -1,4 +1,4 @@
name: Test & Docs
name: Unit tests
on:
push:
@ -7,7 +7,7 @@ on:
branches: [ 'master', 'stable-*' ]
jobs:
build:
test:
runs-on: ubuntu-latest
@ -101,6 +101,3 @@ jobs:
if: matrix.database == 'mariadb'
env:
TESTING_SQLALCHEMY_DATABASE_URI: 'mysql+pymysql://root:ihatemoney@localhost:3306/ihatemoney_ci'
- name: Run Lint & Docs
run: tox -e lint_docs
if: matrix.python-version == '3.12'

12
tox.ini
View file

@ -1,6 +1,6 @@
[tox]
isolated_build = true
envlist = py312,py311,py310,py39,py38,py37,lint_docs
envlist = py312,py311,py310,py39,py38,py37,lint,docs
skip_missing_interpreters = True
[testenv]
@ -16,15 +16,21 @@ deps =
# To be sure we are importing ihatemoney pkg from pip-installed version
changedir = /tmp
[testenv:lint_docs]
[testenv:lint]
commands =
black --check --target-version=py37 .
isort --check --profile black .
flake8 ihatemoney
vermin --no-tips --violations -t=3.7- .
deps =
-e.[dev]
changedir = {toxinidir}
[testenv:docs]
commands =
sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html
deps =
-e.[dev,doc]
-e.[doc]
changedir = {toxinidir}
[flake8]