-
Notifications
You must be signed in to change notification settings - Fork 13
41 lines (41 loc) · 1.25 KB
/
Copy pathFormatter.yml
File metadata and controls
41 lines (41 loc) · 1.25 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
name: Formatter
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
julia-format:
name: Formatter
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
- uses: actions/checkout@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install JuliaFormatter and format
run: |
julia --color=yes -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia --color=yes -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Commit formatted code
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git diff --quiet && exit 0
git add -A
git commit -m "chore: autoformat"
git push
- name: Format check
if: github.event_name != 'workflow_dispatch'
run: |
julia --color=yes -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'