Skip to content

Commit 673a3a0

Browse files
Claudeclaude
andcommitted
CI - NEW FEATURE - Add a pre-commit formatting workflow, disabled for now
Adds a Format and Hygiene workflow that runs the repository's own pre-commit suite (JuliaFormatter plus the file-hygiene hooks) so contributors who have not run `pre-commit install` are still caught. It is wired to workflow_dispatch only: the repository has pre-existing formatting drift that must be cleaned up first, which is out of scope here. Running it manually from the Actions tab shows the current damage; uncommenting the pull_request trigger enables it as a gate. The julia-formatter hook is `language: system`, so it shells out to whatever JuliaFormatter is in the default depot environment rather than the one implied by the pinned hook revision. The workflow therefore installs JuliaFormatter v1.0.62 explicitly, matching the rev in .pre-commit-config.yaml, so CI and local runs agree. Also disables coverage instrumentation in the test job. julia-runtest enables it by default, but nothing consumes the .cov files: they are gitignored and never uploaded. Instrumenting compute-heavy numerical code for output that is discarded is pure cost. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019tFBCa5iBXyb7xp8LxqBJx
1 parent 0c8e4e4 commit 673a3a0

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/format.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Format and Hygiene
2+
3+
# Runs the repository's pre-commit suite (JuliaFormatter + file hygiene) so that
4+
# contributors who have not run `pre-commit install` locally are still caught.
5+
#
6+
# DISABLED as a pull request gate for now: the repository has pre-existing
7+
# formatting drift that has to be cleaned up first. Until then, run this
8+
# manually from the Actions tab ("Run workflow") to see the current damage.
9+
#
10+
# To enable it as a gate, uncomment the `pull_request` trigger below. If the
11+
# test suite's `Tests` job is a required status check, add `pre-commit` too.
12+
on:
13+
workflow_dispatch:
14+
# pull_request:
15+
# branches:
16+
# - main
17+
# - develop
18+
19+
permissions:
20+
contents: read
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
pre-commit:
28+
name: pre-commit
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 20
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v6
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
# Matches default_language_version in .pre-commit-config.yaml
39+
python-version: '3.10'
40+
41+
- name: Set up Julia
42+
uses: julia-actions/setup-julia@v2
43+
with:
44+
version: '1.11'
45+
46+
# The julia-formatter hook is `language: system`: it shells out to
47+
# `julia -e 'import JuliaFormatter: format; format(ARGS)'` and therefore
48+
# uses whatever JuliaFormatter lives in the default depot environment.
49+
# Pin it to the same version .pre-commit-config.yaml pins the hook repo
50+
# to, otherwise CI and local pre-commit runs disagree on formatting.
51+
- name: Install JuliaFormatter
52+
run: julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.62"))'
53+
54+
- name: Cache pre-commit environments
55+
uses: actions/cache@v4
56+
with:
57+
path: ~/.cache/pre-commit
58+
key: pre-commit-${{ runner.os }}-py3.10-${{ hashFiles('.pre-commit-config.yaml') }}
59+
restore-keys: |
60+
pre-commit-${{ runner.os }}-py3.10-
61+
62+
- name: Run pre-commit
63+
run: |
64+
python -m pip install --upgrade pre-commit
65+
pre-commit run --all-files --show-diff-on-failure --color=always

.github/workflows/test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@ jobs:
107107
- name: Build Julia packages
108108
uses: julia-actions/julia-buildpkg@v1
109109

110+
# Coverage instrumentation is off: nothing consumes the .cov files (they are
111+
# gitignored and never uploaded), and instrumenting slows compute-heavy
112+
# numerical code noticeably. Set coverage: true and add a Codecov upload
113+
# step together if coverage reporting is ever wanted.
110114
- name: Run tests
111115
uses: julia-actions/julia-runtest@v1
116+
with:
117+
coverage: false
112118

113119
# Stable check that is present on every pull request, whether or not the suite
114120
# ran. Point branch protection at this job so skipped runs do not block merges.

0 commit comments

Comments
 (0)