Skip to content

Commit c220516

Browse files
committed
better format CI
try another format github action turn on formatter in PR
1 parent 06115ab commit c220516

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

.github/workflows/Format.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1-
name: Formatter
1+
name: format-check
22

3-
on: [pull_request]
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
tags: '*'
8+
pull_request:
49

510
jobs:
611
build:
7-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
julia-version: [1]
16+
julia-arch: [x86]
17+
os: [ubuntu-latest]
818
steps:
19+
- uses: julia-actions/setup-julia@latest
20+
with:
21+
version: ${{ matrix.julia-version }}
22+
923
- uses: actions/checkout@v4
10-
- uses: julia-actions/cache@v2
1124
- name: Install JuliaFormatter and format
25+
# This will use the latest version by default but you can set the version like so:
26+
#
27+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
28+
run: |
29+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
30+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
31+
- name: Format check
1232
run: |
13-
julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
1433
julia -e '
15-
using JuliaFormatter
16-
result = format(".")
17-
if result == false
18-
error("Formatting failed")
19-
end
20-
'
34+
out = Cmd(`git diff`) |> read |> String
35+
if out == ""
36+
exit(0)
37+
else
38+
@error "Some files have not been formatted !!!"
39+
write(stdout, out)
40+
exit(1)
41+
end'

0 commit comments

Comments
 (0)