Skip to content

Commit

Permalink
Start a new workflow and python script that checks version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amstilp committed Nov 8, 2023
1 parent 48ec00a commit e798b86
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions .github/workflows/check_versions.py
Original file line number Diff line number Diff line change
@@ -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!")

0 comments on commit e798b86

Please sign in to comment.