Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions CI Workflow #6

Merged
merged 1 commit into from
Feb 27, 2024
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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Modulr CI

on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main", "dev"]

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.12
- name: Install Hatch
run: pipx install hatch
- name: Run Hatch CI
run: hatch run test
shell: bash
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@ python = "3.12"
dependencies = ["black"]

[tool.hatch.envs.default.scripts]
test = """for dir in testsuite/*/; do
python modulr.py $dir 1>/dev/null
python testsuite/checkresults.py $dir
done"""
test = "bash test-suite.sh"
format = "black ."
7 changes: 7 additions & 0 deletions test-suite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

for dir in testsuite/*/; do
python modulr.py $dir 1>/dev/null
python testsuite/checkresults.py $dir
done

7 changes: 7 additions & 0 deletions testsuite/checkresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
output_root = testrun_root / "site"
expect_root = testrun_root / "expected"

has_failures: bool = False

for root, dirs, files in output_root.walk(on_error=print):
filepaths = [root / file for file in files]
for fp in filepaths:
Expand All @@ -27,10 +29,15 @@
try:
assert output_file.read() == expect_file.read()
except AssertionError:
has_failures = True
print(
f"Test {str(testrun_root).removeprefix('testsuite/')} - {fp}: Fail"
)
else:
print(
f"Test {str(testrun_root).removeprefix('testsuite/')} - {fp}: Pass"
)
if has_failures:
sys.exit(1)
else:
sys.exit(0)