Skip to content

Commit 3b8ab52

Browse files
committed
use format-check from MixedModels.jl
1 parent e8f0ac1 commit 3b8ab52

File tree

4 files changed

+59
-25
lines changed

4 files changed

+59
-25
lines changed

.github/workflows/CI.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,37 @@ env:
1717

1818

1919
jobs:
20+
format-check:
21+
# note: keep in sync with `format/run.jl`
22+
name: Style check (Julia ${{ matrix.julia-version }} - ${{ github.event_name }})
23+
# Run on push's or non-draft PRs
24+
if: (github.event_name == 'push') || (github.event.pull_request.draft == false)
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
julia-version: [1.6]
29+
steps:
30+
- uses: julia-actions/setup-julia@latest
31+
with:
32+
version: ${{ matrix.julia-version }}
33+
- uses: actions/checkout@v4
34+
- name: Instantiate `format` environment and format
35+
run: |
36+
julia --project=format -e 'using Pkg; Pkg.instantiate()'
37+
julia --project=format 'format/run.jl'
38+
- uses: reviewdog/action-suggester@v1
39+
if: github.event_name == 'pull_request'
40+
with:
41+
tool_name: JuliaFormatter
42+
fail_on_error: true
43+
2044
test:
21-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
45+
name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
2246
runs-on: ${{ matrix.os }}
2347
strategy:
2448
fail-fast: false
2549
matrix:
26-
version:
50+
julia-version:
2751
- '1.6'
2852
- '1' # latest stable 1.x release
2953
- 'nightly'
@@ -32,10 +56,10 @@ jobs:
3256
arch:
3357
- x64
3458
steps:
35-
- uses: actions/checkout@v2
36-
- uses: julia-actions/setup-julia@v1
59+
- uses: actions/checkout@v4
60+
- uses: julia-actions/setup-julia@latest
3761
with:
38-
version: ${{ matrix.version }}
62+
version: ${{ matrix.julia-version }}
3963
arch: ${{ matrix.arch }}
4064
- uses: actions/cache@v1
4165
env:
@@ -57,8 +81,8 @@ jobs:
5781
name: Documentation
5882
runs-on: ubuntu-latest
5983
steps:
60-
- uses: actions/checkout@v2
61-
- uses: julia-actions/setup-julia@v1
84+
- uses: actions/checkout@v4
85+
- uses: julia-actions/setup-julia@latest
6286
with:
6387
version: '1'
6488
- name: Install dependencies

.github/workflows/format-check.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

format/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"

format/run.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using JuliaFormatter
2+
3+
function main()
4+
perfect = true
5+
# note: keep in sync with `.JuliaFormatter.toml`
6+
# and with `.github/workflows/CI.yml` format-check
7+
for d in ["src/", "test/", "docs/"]
8+
@info "...linting $d ..."
9+
dir_perfect = format(
10+
d;
11+
style=BlueStyle(),
12+
join_lines_based_on_source=true,
13+
remove_extra_newlines = false,
14+
)
15+
perfect = perfect && dir_perfect
16+
end
17+
if perfect
18+
@info "Linting complete - no files altered"
19+
else
20+
@info "Linting complete - files altered"
21+
run(`git status`)
22+
end
23+
return nothing
24+
end
25+
26+
main()

0 commit comments

Comments
 (0)