From e798b86f1a39fcceb1b966ecbd606d239fde2b69 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 7 Nov 2023 16:52:31 -0800 Subject: [PATCH] Start a new workflow and python script that checks version This workflow is intended to verify that the version in the branch being merged is higher than the main branch. This is definitely not working and I'm not sure I even want to implement this this way. --- .github/workflows/check_version.yml | 36 +++++++++++++++++++++++++++++ .github/workflows/check_versions.py | 33 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/check_version.yml create mode 100644 .github/workflows/check_versions.py diff --git a/.github/workflows/check_version.yml b/.github/workflows/check_version.yml new file mode 100644 index 00000000..910b7f84 --- /dev/null +++ b/.github/workflows/check_version.yml @@ -0,0 +1,36 @@ +name: hatch-tests + +on: + pull_request: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + + push: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout current version + uses: actions/checkout@v4 + path: "current" + + - name: Checkout main version + uses: actions/checkout@v4 + ref: "main" + path: "main" + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Compare versions diff --git a/.github/workflows/check_versions.py b/.github/workflows/check_versions.py new file mode 100644 index 00000000..9f5669bb --- /dev/null +++ b/.github/workflows/check_versions.py @@ -0,0 +1,33 @@ +import argparse +import importlib +import sys + +from packaging import version + +parser = argparse.ArgumentParser( + prog="compare_versions", + description="Check that the version of the updated path is higher than the version of the main path.", +) +parser.add_argument("--main") +parser.add_argument("--updated") +argv = parser.parse_args() + +# Read in main version +sys.path.insert(0, argv.main) +import anvil_consortium_manager # noqa: E402 + +main_version = version.parse(anvil_consortium_manager.__version__) +print("Main version: " + str(main_version)) + +# Read in current version + +sys.path.insert(0, argv.updated) +importlib.reload(anvil_consortium_manager) + +current_version = version.parse(anvil_consortium_manager.__version__) +print("Updated version: " + str(current_version)) + +if current_version <= main_version: + raise Exception("Updated version is less than or equal to the main version.") + +print("Ok!")