diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5493cc461a..54439a0080 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -37,6 +37,25 @@ jobs: run: | poetry run python -m nox -s docs:build + Changelog: + name: Changelog Update Check + runs-on: ubuntu-latest + + steps: + - name: SCM Checkout + uses: actions/checkout@v4 + + - name: Fetch the main branch + run: git fetch origin main + + - name: Setup Python & Poetry Environment + uses: ./.github/actions/python-environment + with: + python-version: "3.9" + + - name: Run changelog update check + run: poetry run nox -s changelog:updated + build-matrix: name: Generate Build Matrix uses: ./.github/workflows/matrix-python.yml diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index 51a89b2f6f..1429ba5083 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -3,3 +3,4 @@ ## ✨ Added * [#73](https://github.com/exasol/python-toolbox/issues/73): Added nox target for auditing work spaces in regard to known vulnerabilities +* [#65](https://github.com/exasol/python-toolbox/issues/65): Added a Nox task for checking if the changelog got updated. \ No newline at end of file diff --git a/exasol/toolbox/nox/_documentation.py b/exasol/toolbox/nox/_documentation.py index 8564f21da0..257e89cf15 100644 --- a/exasol/toolbox/nox/_documentation.py +++ b/exasol/toolbox/nox/_documentation.py @@ -1,7 +1,10 @@ from __future__ import annotations import shutil +import subprocess +import sys import webbrowser +from pathlib import Path import nox from nox import Session @@ -36,6 +39,25 @@ def _build_multiversion_docs(session: nox.Session, config: Config) -> None: ) +def _git_diff_changes_main() -> int: + """ + Check if doc/changes is changed and return the exit code of command git diff. + The exit code is 0 if there are no changes. + """ + p = subprocess.run( + [ + "git", + "diff", + "--quiet", + "origin/main", + "--", + PROJECT_CONFIG.root / "doc/changes", + ], + capture_output=True, + ) + return p.returncode + + @nox.session(name="docs:multiversion", python=False) def build_multiversion(session: Session) -> None: """Builds the multiversion project documentation""" @@ -64,3 +86,14 @@ def clean_docs(_session: Session) -> None: docs_folder = PROJECT_CONFIG.root / DOCS_OUTPUT_DIR if docs_folder.exists(): shutil.rmtree(docs_folder) + + +@nox.session(name="changelog:updated", python=False) +def updated(_session: Session) -> None: + """Checks if the change log has been updated""" + if _git_diff_changes_main() == 0: + print( + "Changelog is not updated.\n" + "Please describe your changes in the changelog!" + ) + sys.exit(1) diff --git a/exasol/toolbox/nox/tasks.py b/exasol/toolbox/nox/tasks.py index a1890b283b..ce8f901b72 100644 --- a/exasol/toolbox/nox/tasks.py +++ b/exasol/toolbox/nox/tasks.py @@ -58,6 +58,7 @@ def check(session: Session) -> None: build_docs, clean_docs, open_docs, + updated, ) from exasol.toolbox.nox._release import prepare_release from exasol.toolbox.nox._shared import ( diff --git a/exasol/toolbox/templates/github/workflows/checks.yml b/exasol/toolbox/templates/github/workflows/checks.yml index d5f6ae5ce8..a5528ead2b 100644 --- a/exasol/toolbox/templates/github/workflows/checks.yml +++ b/exasol/toolbox/templates/github/workflows/checks.yml @@ -47,6 +47,22 @@ jobs: name: Generate Build Matrix uses: ./.github/workflows/matrix-python.yml + Changelog: + name: Changelog Update Check + runs-on: ubuntu-latest + + steps: + - name: SCM Checkout + uses: actions/checkout@v4 + + - name: Setup Python & Poetry Environment + uses: ./.github/actions/python-environment + with: + python-version: "3.9" + + - name: Run changelog update check + run: poetry run nox -s changelog:updated + Lint: name: Linting (Python-${{ matrix.python-version }}) needs: [ Version-Check, build-matrix ]