Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Setup Python"
description: "Setup the correct version of python"

runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
38 changes: 16 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -20,44 +19,38 @@ jobs:

steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- uses: ./.github/actions/setup-python

- name: Install dependencies
run: |
python scripts/os_specific_requirements.py
python -m pip install --upgrade pip
pip install -r requirements.txt
shell: bash
- name: Prepare Scripts
run: |
chmod +x scripts/*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need this if we were calling ./scripts/lint.py rather than python scripts/lint.pt

One less thing to read in this file

run: pip install -r requirements.txt

- name: Lint
run: |
python scripts/lint.py
shell: bash
run: python scripts/lint.py

- name: Test
run: |
pytest --doctest-modules --cov=src/main/ --cov-report=xml src/test
run: pytest --doctest-modules --cov=src/main/ --cov-report=xml src/test

- name: Package
run: |
python scripts/build_executable.py
run: python scripts/build_executable.py

- uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}
path: ./dist/*

- name: Integration
run: |
pytest src/integration
run: pytest src/integration

- name: Upload code coverage to codecov
if: runner.os == 'Linux'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f coverage.xml

- name: Zip binaries for release
if: github.event_name == 'release'
run: python scripts/zip_release.py

- name: Upload binaries to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
Expand All @@ -66,6 +59,7 @@ jobs:
file_glob: true
file: '*.zip'
tag: ${{ github.ref }}

- uses: actions/setup-ruby@v1
- name: Send Webhook Notification
if: failure()
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/pr-label-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PR Label Check

on:
pull_request:
types: [opened, labeled, unlabeled]

jobs:
validate-labels:
name: Validate release label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python
- name: Check PR has exactly one release label
run: |
python scripts/pr_label_check.py "$GITHUB_EVENT_PATH"
shell: bash
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ Lastly, edit this config file to your liking:
* Check your [core.hooksPath](https://git-scm.com/docs/githooks) - this setting can be `--global` or by repository. Check this first.
* #### The hook is having a runtime error
* Please submit an issue with the terminal output you received [here](https://github.com/unthreaded/git-hooks/issues) with as much detail as possible.

## Development details
For Mac, you must install some dependencies via brew. Simply run [`os_specific_requirements.py`](scripts/os_specific_requirements.py) and you'll be good to go!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple weeks ago I was reading this: https://pyinstaller.org/en/stable/usage.html#using-upx

Turns out PyInstaller no longer references this UPX is currently used only on Windows.


## Contributing
[How to contribute](./CONTRIBUTING.md)
14 changes: 0 additions & 14 deletions scripts/os_specific_requirements.py

This file was deleted.

52 changes: 52 additions & 0 deletions scripts/pr_label_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Ensure a pull request has exactly one version label
"""
import os
import sys
import json

VALID_LABELS = {'Patch', 'Minor', 'Major', "no-release"}

def extract_labels_from_event(event_file: str) -> set[str]:
"""Extract label names from a GitHub event JSON file.

Args:
event_file: Path to the JSON event file produced by GitHub Actions.

Returns:
A set of label names (strings) found on the pull request.
"""
with open(event_file, 'r', encoding='utf-8') as f:
payload = json.load(f)
labels = payload.get('pull_request', {}).get('labels', [])
return {str(lbl.get('name', '')).strip() for lbl in labels}


def are_labels_valid(labels_on_pr: set[str]) -> bool:
"""Check whether the PR has exactly one allowed version label.

Args:
labels_on_pr: Set of label names present on the pull request.

Returns:
True if exactly one label from VALID_LABELS is present; otherwise False.
"""
print(f"Found labels on pull request: {labels_on_pr}")
overlap = VALID_LABELS.intersection(labels_on_pr)
return len(overlap) == 1


if __name__ == "__main__":
print("Checking pull request labels")
event_path = sys.argv[1]
success: bool = False
if event_path and os.path.isfile(event_path):
all_labels = extract_labels_from_event(event_path)
success = are_labels_valid(all_labels)
else:
print("No labels found")

if not success:
print(f"Did not find exactly one of the following labels: {VALID_LABELS}")

sys.exit(0 if success else 1)
Loading