Skip to content

Commit a07d127

Browse files
Add pre-commit code checks (#145)
* Add pre-commit code checks * Remove self-qualification * Cleanup some used function from packages * Update codechecks * Apply formatter * Add JuliaFormatter to CI * Fix EOF * Fix trailing WS * Format test and Use correct function from ExplicitImports * Fix some faulty formatting actions * Update deps
1 parent 009811a commit a07d127

File tree

124 files changed

+7803
-3840
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+7803
-3840
lines changed

.JuliaFormatter.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
style = "sciml"
2+
align_assignment = true
3+
margin = 100
4+
remove_extra_newlines = false
5+
whitespace_in_kwargs = true
6+
whitespace_typedefs = true
7+
ignore = ["bak/*", "benchmarks/*", "data/*", "docs/*"]

.github/workflows/TagBot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- uses: JuliaRegistries/TagBot@v1
1313
with:
1414
token: ${{ secrets.GITHUB_TOKEN }}
15-
ssh: ${{ secrets.DOCUMENTER_KEY }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/codechecks.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Code checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
8+
jobs:
9+
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
15+
16+
format:
17+
runs-on: ubuntu-latest
18+
name: "JuliaFormatter.jl"
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: '1.12'
23+
24+
- uses: actions/checkout@v6
25+
- name: Install JuliaFormatter and format
26+
# This will use the latest version by default but you can set the version like so:
27+
#
28+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29+
run: |
30+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter")); Pkg.Apps.add(PackageSpec(name="JuliaFormatter"))'
31+
$HOME/.julia/bin/jlfmt --inplace -v .
32+
- name: Format check
33+
run: |
34+
julia -e '
35+
out = Cmd(`git diff`) |> read |> String
36+
if out == ""
37+
exit(0)
38+
else
39+
@error "Some files have not been formatted !!!"
40+
write(stdout, out)
41+
exit(1)
42+
end'

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-toml
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: mixed-line-ending
11+
- id: trailing-whitespace

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
1111
Ferrite = "c061ca5d-56c9-439f-9c0e-210fe06d3992"
1212
FerriteGmsh = "4f95f4f8-b27c-4ae5-9a39-ea55e634e36b"
1313
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
14-
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1514
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1615
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1716
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -29,6 +28,7 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2928
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3029
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
3130
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
31+
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
3232
Tensors = "48a634ad-e948-5137-8d70-aa71f2a747f4"
3333
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
3434
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
@@ -62,6 +62,7 @@ OrdinaryDiffEqOperatorSplitting = "0.2.3"
6262
OrdinaryDiffEqTsit5 = "1"
6363
Preferences = "1"
6464
SciMLBase = "2"
65+
SymbolicIndexingInterface = "0.3.46"
6566
UnPack = "1"
6667
julia = "1.10"
6768

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A modular shared-memory high-performance framework for multiscale cardiac multip
1212
> This package is under heavy development. Expect regular breaking changes
1313
> for now. If you are interested in joining development, then either comment
1414
> an issue you are interested or directly reach out to me via julialang.zulipchat.com, mail or
15-
> julialang.slack.com. Alternatively open a [GitHub discussion](https://github.com/JuliaHealth/Thunderbolt.jl/discussions) if you have something
15+
> julialang.slack.com. Alternatively open a [GitHub discussion](https://github.com/JuliaHealth/Thunderbolt.jl/discussions) if you have something
1616
> specific in mind.
1717
1818
## Questions
@@ -46,7 +46,7 @@ You are now all set to start using Thunderbolt!
4646
## Accessing the Documentation Offline
4747

4848
To build the docs you first need to install Julia, see <https://julialang.org/> for details.
49-
Then you need to install the packages. To accomplish this you first start a julia shell in the
49+
Then you need to install the packages. To accomplish this you first start a julia shell in the
5050
docs fonder and open the Pkg REPL; i.e. press `]` at the `julia>` promp to
5151
enter `pkg>` mode. Then you [activate and instantiate](https://pkgdocs.julialang.org/v1/environments/#Using-someone-else's-project) via
5252
```

bak/examples-gpu/spiral-wave.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ spiral_wave_initializer!(u₀, odeform)
9191
u₀gpu = CuVector(u₀)
9292
problem = OS.OperatorSplittingProblem(odeform, u₀gpu, tspan)
9393

94-
#
94+
#
9595
function BJPprec(A,p)
9696
P = BlockJacobiPreconditioner(A, 1000, CUDABackend())
9797
KrylovPreconditioners.update!(P, A)

bak/examples/isolated-lumped-circuit.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pt0sat = 100.0
6060
qt0sat = 0.0
6161
## Systemic Arteriole #### Checked
6262
Rsar = 0.5
63-
## Systemic Capillary #### Checked
63+
## Systemic Capillary #### Checked
6464
Rscp = 0.52
6565
## Systemic Vein #### Checked
6666
Csvn = 20.5
@@ -97,7 +97,7 @@ Kf_sav = 0.0004
9797
Ke_sav = 9000.0
9898
M_sav = 0.0004
9999
A_sav = 0.00047
100-
# right heart #
100+
# right heart #
101101
Kst_ra = 2.5
102102
Kst_rv = 20.0
103103
Kf_pav = 0.0004
@@ -109,7 +109,7 @@ A_pav = 0.00047
109109
Kp_av = 5500.0 # * 57.29578 # Shi Paper has values in radians!
110110
Kf_av = 50.0
111111
Kf_mv = 50.0
112-
Kp_mv = 5500.0 # * 57.29578
112+
Kp_mv = 5500.0 # * 57.29578
113113
Kf_tv = 50.0
114114
Kp_tv = 5500.0 # * 57.29578
115115
Kf_pv = 50.0
@@ -131,7 +131,7 @@ Kv_pv = 3.5
131131
θmin_pv = 5.0 * pi / 180
132132
θmin_tv = 5.0 * pi / 180
133133

134-
## pressure force and frictional force is the same for all 4 valves
134+
## pressure force and frictional force is the same for all 4 valves
135135

136136
# Initial conditions #### Checked against cellML model
137137

bak/examples/leads.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ ms = OrthotropicMicrostructureModel(
1313
)
1414

1515
κ = SpectralTensorCoefficient(
16-
ms,
16+
ms,
1717
ConstantCoefficient(SVector(0.3, 0.12, 0.12) + SVector(0.3, 0.03, 0.03)))
1818
κᵢ = SpectralTensorCoefficient(
19-
ms,
19+
ms,
2020
ConstantCoefficient(SVector(0.3, 0.12, 0.12)))
2121

2222

benchmarks/benchmarks-cuda-linear-form.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using BenchmarkTools, Thunderbolt, StaticArrays,Ferrite , CUDA
22

33
# The Following is needed to enforce grid to use Float32.
4-
left = Vec((-1.f0, -1.f0,-1.f0))
5-
right = Vec((1.f0, 1.f0, 1.f0))
4+
left = Vec((-1.f0, -1.f0,-1.f0))
5+
right = Vec((1.f0, 1.f0, 1.f0))
66

77
grid = generate_grid(Hexahedron , (500,100,100),left,right)
88

0 commit comments

Comments
 (0)