From 73f014e90e5c1cd6fd5d5a6abcc71e00a4b1a969 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 25 Mar 2024 20:03:12 +0100 Subject: [PATCH] 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. --- .github/workflows/dockerhub.yml | 4 +- .github/workflows/lint-docs.yml | 42 +++++++++++++++++++ .../{test-docs.yml => unit-tests.yml} | 7 +--- tox.ini | 12 ++++-- 4 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/lint-docs.yml rename .github/workflows/{test-docs.yml => unit-tests.yml} (96%) diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index c8943b9d..6c8a47b2 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -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' diff --git a/.github/workflows/lint-docs.yml b/.github/workflows/lint-docs.yml new file mode 100644 index 00000000..12ec03fe --- /dev/null +++ b/.github/workflows/lint-docs.yml @@ -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 diff --git a/.github/workflows/test-docs.yml b/.github/workflows/unit-tests.yml similarity index 96% rename from .github/workflows/test-docs.yml rename to .github/workflows/unit-tests.yml index 372ca8ae..067bc923 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/unit-tests.yml @@ -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' diff --git a/tox.ini b/tox.ini index fe2c9ad9..8a0421fa 100644 --- a/tox.ini +++ b/tox.ini @@ -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]