diff --git a/.github/workflows/tables.yml b/.github/workflows/tables.yml new file mode 100644 index 0000000..c7d0c29 --- /dev/null +++ b/.github/workflows/tables.yml @@ -0,0 +1,46 @@ +# .github/workflows/tables.yml +name: test-and-tables + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + - run: pip install -r requirements.txt + - run: python -m pytest -q tests + + tables: + needs: test + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + - run: pip install -r requirements.txt + - run: python scripts/generate_tables.py + - name: Commit regenerated tables if changed + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add tables + if git diff --cached --quiet; then + echo "Tables unchanged." + else + git commit -m "Regenerate tables [skip ci]" + git push + fi diff --git a/requirements.txt b/requirements.txt index f01ac91..71e61c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy>=2.0 -scipy>=1.11 -pandas>=2.0 +numpy==2.4.4 +scipy==1.17.1 +pandas==3.0.2 pytest>=7 diff --git a/scripts/generate_tables.py b/scripts/generate_tables.py index 00ec419..1199cab 100644 --- a/scripts/generate_tables.py +++ b/scripts/generate_tables.py @@ -38,7 +38,7 @@ def to_md(df: pd.DataFrame, pct_cols=None, decimals=2) -> str: def save(name, df, pct_cols=None, note=""): - df.to_csv(os.path.join(OUT, name + ".csv")) + df.round(6).to_csv(os.path.join(OUT, name + ".csv")) # rounded to avoid float-noise diffs with open(os.path.join(OUT, name + ".md"), "w") as f: f.write(f"# {name}\n\n{note}\n\n" + to_md(df, pct_cols) + "\n") print("wrote", name)