Repository navigation
67 lines (58 loc) · 2.23 KB
/
Copy pathformat.yaml
File metadata and controls
67 lines (58 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Format and Hygiene
# Runs the repository's pre-commit suite (JuliaFormatter + file hygiene) so that
# contributors who have not run `pre-commit install` locally are still caught.
#
# The `pre-commit` job fails whenever the hooks rewrite a tracked file, so it
# reports whether the repository is clean under the formatter. The repository
# was swept with `pre-commit run --all-files` when this check was enabled, so
# `pre-commit` can be a required status check. Pushes to develop are checked too,
# since two pull requests that are each clean can merge into unformatted code.
on:
workflow_dispatch:
push:
branches:
- develop
pull_request:
branches:
- main
- develop
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
# Matches default_language_version in .pre-commit-config.yaml
python-version: '3.10'
- name: Set up Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.11'
# The julia-formatter hook is `language: system`: it shells out to
# `julia -e 'import JuliaFormatter: format; format(ARGS)'` and therefore
# uses whatever JuliaFormatter lives in the default depot environment.
# Pin it to the same version .pre-commit-config.yaml pins the hook repo
# to, otherwise CI and local pre-commit runs disagree on formatting.
- name: Install JuliaFormatter
run: julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.62"))'
- name: Cache pre-commit environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-py3.10-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-py3.10-
- name: Run pre-commit
run: |
python -m pip install --upgrade pre-commit
pre-commit run --all-files --show-diff-on-failure --color=always