Skip to content

Commit

Permalink
ci: pyproject tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Sep 21, 2024
1 parent 20300c7 commit 8a03414
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 6 deletions.
46 changes: 46 additions & 0 deletions .github/scripts/compare_pyproject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import argparse
import sys
import tomllib


def main():
parser = argparse.ArgumentParser(
description="Compare versions in [project] section of main and dev TOML files."
)
parser.add_argument("--dev-toml", help="Path to the dev branch TOML file")
parser.add_argument("--main-toml", help="Path to the main branch TOML file")

args = parser.parse_args()

try:
with open(args.dev_toml, "rb") as file:
dev_toml = tomllib.load(file)
except FileNotFoundError:
sys.exit(f"File not found: {args.dev_toml}")
except Exception as e:
sys.exit(f"Error reading file {args.dev_toml}: {e}")

try:
with open(args.main_toml, "rb") as file:
main_toml = tomllib.load(file)
except FileNotFoundError:
sys.exit(f"File not found: {args.main_toml}")
except Exception as e:
sys.exit(f"Error reading file {args.main_toml}: {e}")

# Extracting versions
dev_version = dev_toml.get("project").get("version")
main_version = main_toml.get("project").get("version")

print(f"{dev_version=}")
print(f"{main_version=}")

if dev_version == main_version:
sys.exit(
"Versions between dev and main branch match."
"\nThe version needs to be bumped to make sure it will be installed."
)


if __name__ == "__main__":
main()
29 changes: 23 additions & 6 deletions .github/workflows/test_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@ jobs:
style-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Checkout Dev
uses: actions/checkout@v4
- name: Checkout Main
run: git clone --depth 1 https://github.com/nypesap/mkdocs-nype.git main-branch
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3
cache: pip
- run: pip install isort black
- run: isort mkdocs_nype/ --check
- run: black mkdocs_nype/ --check
- name: Install style-check deps
run: pip install isort black
- name: Run style-check tests
run: |
isort mkdocs_nype/ --check
black mkdocs_nype/ --check
- name: Check package version when contents change
if: "hashFiles('mkdocs_nype') != hashFiles('main-branch/mkdocs_nype')"
run: |
wget -O main_pyproject.toml https://raw.githubusercontent.com/nypesap/mkdocs-nype/refs/heads/main/pyproject.toml
python .github/scripts/compare_pyproject.py --dev-toml pyproject.toml --main-toml main_pyproject.toml
check-repos:
needs: style-check
runs-on: ubuntu-latest
Expand All @@ -30,4 +42,9 @@ jobs:
- https://github.com/fioriroletesting/fioriroletesting.github.io.git
steps:
- uses: actions/checkout@v4
- run: echo "${{ matrix.repo }}"
- run: echo "${{ matrix.repo }}"
after-repos:
needs: check-repos
runs-on: ubuntu-latest
steps:
- run: echo "Success"

0 comments on commit 8a03414

Please sign in to comment.