Skip to content

Commit 5017343

Browse files
add nox task for checking if the changelog got updated (#346)
1 parent 7e8b747 commit 5017343

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

.github/workflows/checks.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ jobs:
3737
run: |
3838
poetry run python -m nox -s docs:build
3939
40+
Changelog:
41+
name: Changelog Update Check
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: SCM Checkout
46+
uses: actions/checkout@v4
47+
48+
- name: Fetch the main branch
49+
run: git fetch origin main
50+
51+
- name: Setup Python & Poetry Environment
52+
uses: ./.github/actions/python-environment
53+
with:
54+
python-version: "3.9"
55+
56+
- name: Run changelog update check
57+
run: poetry run nox -s changelog:updated
58+
4059
build-matrix:
4160
name: Generate Build Matrix
4261
uses: ./.github/workflows/matrix-python.yml

doc/changes/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
## ✨ Added
44

55
* [#73](https://github.com/exasol/python-toolbox/issues/73): Added nox target for auditing work spaces in regard to known vulnerabilities
6+
* [#65](https://github.com/exasol/python-toolbox/issues/65): Added a Nox task for checking if the changelog got updated.

exasol/toolbox/nox/_documentation.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import annotations
22

33
import shutil
4+
import subprocess
5+
import sys
46
import webbrowser
7+
from pathlib import Path
58

69
import nox
710
from nox import Session
@@ -36,6 +39,25 @@ def _build_multiversion_docs(session: nox.Session, config: Config) -> None:
3639
)
3740

3841

42+
def _git_diff_changes_main() -> int:
43+
"""
44+
Check if doc/changes is changed and return the exit code of command git diff.
45+
The exit code is 0 if there are no changes.
46+
"""
47+
p = subprocess.run(
48+
[
49+
"git",
50+
"diff",
51+
"--quiet",
52+
"origin/main",
53+
"--",
54+
PROJECT_CONFIG.root / "doc/changes",
55+
],
56+
capture_output=True,
57+
)
58+
return p.returncode
59+
60+
3961
@nox.session(name="docs:multiversion", python=False)
4062
def build_multiversion(session: Session) -> None:
4163
"""Builds the multiversion project documentation"""
@@ -64,3 +86,14 @@ def clean_docs(_session: Session) -> None:
6486
docs_folder = PROJECT_CONFIG.root / DOCS_OUTPUT_DIR
6587
if docs_folder.exists():
6688
shutil.rmtree(docs_folder)
89+
90+
91+
@nox.session(name="changelog:updated", python=False)
92+
def updated(_session: Session) -> None:
93+
"""Checks if the change log has been updated"""
94+
if _git_diff_changes_main() == 0:
95+
print(
96+
"Changelog is not updated.\n"
97+
"Please describe your changes in the changelog!"
98+
)
99+
sys.exit(1)

exasol/toolbox/nox/tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def check(session: Session) -> None:
5858
build_docs,
5959
clean_docs,
6060
open_docs,
61+
updated,
6162
)
6263
from exasol.toolbox.nox._release import prepare_release
6364
from exasol.toolbox.nox._shared import (

exasol/toolbox/templates/github/workflows/checks.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ jobs:
4747
name: Generate Build Matrix
4848
uses: ./.github/workflows/matrix-python.yml
4949

50+
Changelog:
51+
name: Changelog Update Check
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: SCM Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Setup Python & Poetry Environment
59+
uses: ./.github/actions/python-environment
60+
with:
61+
python-version: "3.9"
62+
63+
- name: Run changelog update check
64+
run: poetry run nox -s changelog:updated
65+
5066
Lint:
5167
name: Linting (Python-${{ matrix.python-version }})
5268
needs: [ Version-Check, build-matrix ]

0 commit comments

Comments
 (0)