From a959964b1f6b0707ef3acef11f9ffd31d0facfce Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:11:49 +0200 Subject: [PATCH 1/6] run isort on all files --- create_report_dirs.py | 2 +- src/changelog2version/extract_version.py | 5 +++-- src/changelog2version/render_version_file.py | 3 ++- src/changelog2version/update_version.py | 7 ++++--- tests/test_extract_version.py | 12 ++++++------ tests/test_update_version.py | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/create_report_dirs.py b/create_report_dirs.py index a93ad2e..8f46546 100644 --- a/create_report_dirs.py +++ b/create_report_dirs.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 """Create test report directories.""" -from pathlib import Path import os import shutil +from pathlib import Path if os.path.exists('reports'): shutil.rmtree('reports', ignore_errors=True) diff --git a/src/changelog2version/extract_version.py b/src/changelog2version/extract_version.py index a38f4b5..7ec0229 100644 --- a/src/changelog2version/extract_version.py +++ b/src/changelog2version/extract_version.py @@ -7,12 +7,13 @@ """ import logging -from pathlib import Path import re -from semver import VersionInfo +from pathlib import Path from sys import stdout from typing import List, Optional +from semver import VersionInfo + class ExtractVersionError(Exception): """Base class for exceptions in this module.""" diff --git a/src/changelog2version/render_version_file.py b/src/changelog2version/render_version_file.py index cd6e31a..f910ee0 100644 --- a/src/changelog2version/render_version_file.py +++ b/src/changelog2version/render_version_file.py @@ -3,11 +3,12 @@ """Render version file based on template""" -from jinja2 import Environment, FileSystemLoader import logging from pathlib import Path from typing import Optional, Union +from jinja2 import Environment, FileSystemLoader + from .extract_version import ExtractVersion diff --git a/src/changelog2version/update_version.py b/src/changelog2version/update_version.py index bc51e69..c19d700 100644 --- a/src/changelog2version/update_version.py +++ b/src/changelog2version/update_version.py @@ -21,14 +21,15 @@ import argparse import fileinput -from hashlib import sha1 import json import logging -from pathlib import Path import re -import semver +from hashlib import sha1 +from pathlib import Path from sys import stdout +import semver + from .extract_version import ExtractVersion from .render_version_file import RenderVersionFile from .version import __version__ diff --git a/tests/test_extract_version.py b/tests/test_extract_version.py index 8e83ef5..6886f41 100644 --- a/tests/test_extract_version.py +++ b/tests/test_extract_version.py @@ -3,16 +3,16 @@ """Unittest for testing the extract_version file""" import logging -from nose2.tools import params +import unittest from pathlib import Path -from semver import VersionInfo from sys import stdout from typing import List -import unittest -from unittest.mock import patch, mock_open +from unittest.mock import mock_open, patch -from changelog2version.extract_version import ExtractVersion, \ - ExtractVersionError +from changelog2version.extract_version import (ExtractVersion, + ExtractVersionError) +from nose2.tools import params +from semver import VersionInfo class TestExtractVersion(unittest.TestCase): diff --git a/tests/test_update_version.py b/tests/test_update_version.py index a67505f..eee9450 100644 --- a/tests/test_update_version.py +++ b/tests/test_update_version.py @@ -3,9 +3,9 @@ """Unittest for testing the update_version file""" import logging +import unittest from pathlib import Path from sys import stdout -import unittest class TestUpdateVersion(unittest.TestCase): From 51c5b54ecd9db2185a07b66187aba6e604c7bdc1 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:24:02 +0200 Subject: [PATCH 2/6] drop Python 3.8 support from test workflow and package classifier --- .github/workflows/test.yml | 2 +- README.md | 2 +- setup.py | 2 -- tox.ini | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14faf46..e9cf971 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: # runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11'] # os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Checkout diff --git a/README.md b/README.md index fbc0293..9d0dd26 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Downloads](https://pepy.tech/badge/changelog2version)](https://pepy.tech/project/changelog2version) ![Release](https://img.shields.io/github/v/release/brainelectronics/changelog2version?include_prereleases&color=success) -![Python](https://img.shields.io/badge/python3-Ok-green.svg) +![Python](https://img.shields.io/badge/Python-3.9%20|%203.10%20|%203.11-green.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![codecov](https://codecov.io/github/brainelectronics/changelog2version/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/changelog2version) diff --git a/setup.py b/setup.py index fdc1f40..be9f589 100644 --- a/setup.py +++ b/setup.py @@ -96,8 +96,6 @@ # that you indicate you support Python 3. These classifiers are *not* # checked by 'pip install'. See instead 'python_requires' below. "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/tox.ini b/tox.ini index c4ef219..75f928b 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ # and also to help confirm pull requests to this project. [tox] -envlist = py{37,38,39,310} +envlist = py{39,310,311} # Define the minimal tox version required to run; # if the host tox is less than this the tool with create an environment and From 5faa8656b60f612674627d372e4fdf5345adfb38 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:25:49 +0200 Subject: [PATCH 3/6] ignore changelog.json file from git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4ceed74..1bc416f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ examples/*.c examples/*.h examples/*.py examples/version_info +changelog.json # custom, package specific ignores .DS_Store From bc407a65293cd9023b53621d8ed0c2bf44d1e711 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:34:25 +0200 Subject: [PATCH 4/6] bump action checkout to v4 and setup-python to v5 --- .github/workflows/release.yml | 4 ++-- .github/workflows/test-release.yaml | 4 ++-- .github/workflows/test.yml | 4 ++-- .github/workflows/unittest.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a771291..572a724 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: '3.9' - name: Install build and deploy dependencies diff --git a/.github/workflows/test-release.yaml b/.github/workflows/test-release.yaml index 5da510e..baabc3f 100644 --- a/.github/workflows/test-release.yaml +++ b/.github/workflows/test-release.yaml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: '3.9' - name: Install deploy dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9cf971..1679334 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,9 +24,9 @@ jobs: # os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} # python-version: '3.9' diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index 0a302c6..9246367 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -13,8 +13,8 @@ jobs: test-and-coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.9' - name: Execute tests From 5f46ad2303fe2ee7c2e3bd6bcd39233dd1ec4c97 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:46:46 +0200 Subject: [PATCH 5/6] use snippets2changelog --- .github/workflows/release.yml | 6 ++++++ .github/workflows/test-release.yaml | 6 ++++++ .github/workflows/test.yml | 6 ++++++ .snippets/26.md | 12 ++++++++++++ requirements-deploy.txt | 1 + 5 files changed, 31 insertions(+) create mode 100644 .snippets/26.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 572a724..07f9df7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,12 @@ jobs: python -m pip install -U setuptools wheel build if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi pip install . + - name: Update changelog with snippets + run: | + changelog-generator \ + changelog changelog.md \ + --snippets=.snippets \ + --in-place - name: Parse changelog id: parse_changelog run: | diff --git a/.github/workflows/test-release.yaml b/.github/workflows/test-release.yaml index baabc3f..12709c9 100644 --- a/.github/workflows/test-release.yaml +++ b/.github/workflows/test-release.yaml @@ -24,6 +24,12 @@ jobs: python -m pip install -U setuptools wheel build if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi pip install . + - name: Update changelog with snippets + run: | + changelog-generator \ + changelog changelog.md \ + --snippets=.snippets \ + --in-place - name: Parse changelog id: parse_changelog run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1679334..adc8694 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,12 @@ jobs: python -m pip install -U setuptools wheel build if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi pip install . + - name: Update changelog with snippets + run: | + changelog-generator \ + changelog changelog.md \ + --snippets=.snippets \ + --in-place - name: Build package run: | changelog2version \ diff --git a/.snippets/26.md b/.snippets/26.md new file mode 100644 index 0000000..4963ffe --- /dev/null +++ b/.snippets/26.md @@ -0,0 +1,12 @@ +## Use snippets2changelog + + +- run isort on all files +- drop Python 3.8 support everywhere and update README badge +- add generated `changelog.json` file to `.gitignore` +- use latest `actions/checkout@v4` and `actions/setup-python@v5` +- use `snippets2changelog` package, closes #26 diff --git a/requirements-deploy.txt b/requirements-deploy.txt index f4cdfdb..643e30d 100644 --- a/requirements-deploy.txt +++ b/requirements-deploy.txt @@ -2,3 +2,4 @@ # Avoid fixed versions # # to upload package to PyPi or other package hosts twine>=5.1.1,<6 +snippets2changelog>=1.2.1,<2 From 92b1221610959d400293dbe529586145c40f6de2 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 4 Oct 2024 10:51:18 +0200 Subject: [PATCH 6/6] rtfm and adjust the checkout depth when using the snippets2changelog package --- .github/workflows/release.yml | 3 +++ .github/workflows/test-release.yaml | 3 +++ .github/workflows/test.yml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07f9df7..f5304bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # all history is needed to crawl it properly + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/test-release.yaml b/.github/workflows/test-release.yaml index 12709c9..4fd226d 100644 --- a/.github/workflows/test-release.yaml +++ b/.github/workflows/test-release.yaml @@ -15,6 +15,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # all history is needed to crawl it properly + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index adc8694..46d0b17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # all history is needed to crawl it properly + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: