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
125 changes: 64 additions & 61 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,69 @@ jobs:
fail-fast: false
matrix:
# We want the oldest possible version of MacOS for backwards compatibility
os: [ubuntu-latest, macos-13, windows-latest]
os: [ ubuntu-latest, macos-13, windows-latest ]

steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- 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/*
- name: Lint
run: |
python scripts/lint.py
shell: bash
- name: Test
run: |
pytest --doctest-modules --cov=src/main/ --cov-report=xml src/test
- name: Package
run: |
python scripts/package.py
- uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}
path: ./dist/*
- name: 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: Upload binaries to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: '*.zip'
tag: ${{ github.ref }}
- uses: actions/setup-ruby@v1
- name: Send Webhook Notification
if: failure()
env:
JOB_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
WEBHOOK_REPO: ${{ secrets.WEBHOOK_REPO }}
# On PRs from forks the secrets aren't included
# Thus the || error handling you see below
run: |
echo Status: "$JOB_STATUS"
git clone "$WEBHOOK_REPO" webhook || (echo Missing repo && exit 1)
bash webhook/send.sh "$JOB_STATUS" "$WEBHOOK_URL" || (echo Missing hook URL && exit 1)
shell: bash
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- 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/*
- name: Lint
run: |
python scripts/lint.py
shell: bash
- name: Test
run: |
pytest --doctest-modules --cov=src/main/ --cov-report=xml src/test
- name: Package
run: |
python scripts/build_executable.py
- uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}
path: ./dist/*
- name: 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
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: '*.zip'
tag: ${{ github.ref }}
- uses: actions/setup-ruby@v1
- name: Send Webhook Notification
if: failure()
env:
JOB_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
WEBHOOK_REPO: ${{ secrets.WEBHOOK_REPO }}
# On PRs from forks the secrets aren't included
# Thus the || error handling you see below
run: |
echo Status: "$JOB_STATUS"
git clone "$WEBHOOK_REPO" webhook || (echo Missing repo && exit 1)
bash webhook/send.sh "$JOB_STATUS" "$WEBHOOK_URL" || (echo Missing hook URL && exit 1)
shell: bash
3 changes: 2 additions & 1 deletion .run/Build executable.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build executable" type="PythonConfigurationType" factoryName="Python">
<module name="git-hooks" />
<option name="ENV_FILES" value="" />
Copy link
Member

Choose a reason for hiding this comment

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

This might be cause I'm checking from mobile, but is this being used anywhere?

<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
Expand All @@ -12,7 +13,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/scripts/package.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/scripts/build_executable.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
Expand Down
9 changes: 2 additions & 7 deletions scripts/package.py → scripts/build_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@
Generate OS specific executable
"""
import os
import platform
import sys
from shutil import copy2 as copy, rmtree

import PyInstaller.__main__

from helpers import OS_ALIAS, EXE_FILE_FOLDER

if __name__ == "__main__":
# Clean up from previous build
rmtree('dist', ignore_errors=True)
rmtree('build', ignore_errors=True)

OS_ALIAS: str = platform.system().lower()

if OS_ALIAS == "darwin":
OS_ALIAS = "mac"

EXE_NAME: str = "commit-msg"
EXE_FILE_FOLDER = 'dist'

# Hidden import mends PyInstaller moduleNotFound errors
PyInstaller.__main__.run([
Expand Down
9 changes: 9 additions & 0 deletions scripts/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Shared code betweens scripts
"""
import platform

__os_alias_temp: str = platform.system().lower()

OS_ALIAS: str = "mac" if __os_alias_temp == "darwin" else __os_alias_temp
EXE_FILE_FOLDER = 'dist'
13 changes: 13 additions & 0 deletions scripts/zip_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Zip executable for release
"""
from shutil import make_archive

from helpers import OS_ALIAS, EXE_FILE_FOLDER

if __name__ == "__main__":
# Output a zip file with the configuration file + executable
# in the current working directory
zip_file_name = OS_ALIAS.capitalize()
make_archive(zip_file_name, 'zip', EXE_FILE_FOLDER)
print(f"Wrote zip file: {zip_file_name}")
Loading