diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 88fa837f..fe2596e4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -21,3 +21,12 @@ + +### ☑️ Checks + + + +- [ ] My PR contains actual code changes, and I have updated the version number in `pyproject.toml`. diff --git a/.github/scripts/check_version.sh b/.github/scripts/check_version.sh new file mode 100755 index 00000000..54c90238 --- /dev/null +++ b/.github/scripts/check_version.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if git diff --name-only origin/main | grep ".*\.py$" > /dev/null 2>&1; then + # Found modified stuff, make sure version is bumped! + MAIN_TAG=$(git describe origin/main --tags --abbrev=0) + CURRENT_VERSION=$(poetry version --short 2>/dev/null) + + GIT_ROOT=$(git rev-parse --show-toplevel) + # Script exits with return code 1 if the check fails. + python ${GIT_ROOT}/.github/scripts/compare_versions.py ${MAIN_TAG} ${CURRENT_VERSION} +fi \ No newline at end of file diff --git a/.github/scripts/compare_versions.py b/.github/scripts/compare_versions.py new file mode 100644 index 00000000..d1fdbfa7 --- /dev/null +++ b/.github/scripts/compare_versions.py @@ -0,0 +1,13 @@ +# This script checks if current version is larger than latest main version. + +import sys + +from packaging import version + +main_tag = sys.argv[1] +current_version = sys.argv[2] + +# We want this program to exit 1 when the check fails. +# Since `True` == `1`, we want this comparison to evaluate to `0` if we +# want the check to pass. +sys.exit(version.parse(main_tag) >= version.parse(current_version)) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbcf0762..55284cca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,9 @@ jobs: thresholdNew: 0.85 thresholdModified: 0.0 + - name: Check bumped version + run: bash .github/scripts/check_version.sh + docker: name: Docker build runs-on: ubuntu-latest