Skip to content

Commit

Permalink
Merge pull request #6 from GrammAcc/dev
Browse files Browse the repository at this point in the history
Add GitHub Actions CI Workflow
  • Loading branch information
GrammAcc authored Feb 27, 2024
2 parents 65a47af + a83d507 commit 0fc2cf0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
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)

0 comments on commit 0fc2cf0

Please sign in to comment.