Skip to content

Commit

Permalink
Follow up changes to Runic formatting
Browse files Browse the repository at this point in the history
 - Add commit to blame ignore list
 - Mention Runic formatting in the CHANGELOG.md
 - Run Runic check on CI
 - Add runic-pre-commit to pre-commit configuration
 - Add information about Runic and pre-commit to CONTRIBUTING.md
  • Loading branch information
fredrikekre committed Oct 31, 2024
1 parent c50ce06 commit d6e43f4
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# `pre-commit run --all-files` (https://github.com/Ferrite-FEM/Ferrite.jl/pull/928)
68e1ab15bea4618f76b9ed1d850e2ce33375e266
# Apply Runic.jl formatting (https://github.com/Ferrite-FEM/Ferrite.jl/pull/1096)
c50ce06f2261398ecfe6da4578e50baff88cf563
16 changes: 16 additions & 0 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
env:
# Skip runic-pre-commit since we use runic-action below instead
SKIP: runic

runic:
name: "Runic"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.11'
- uses: julia-actions/cache@v2
- uses: fredrikekre/runic-action@v1
with:
version: "35d6dd44ca8704f329319c83a2209875db2ede06"

explicit-imports:
runs-on: ubuntu-latest
Expand Down
22 changes: 13 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: 'https://github.com/fredrikekre/runic-pre-commit'
rev: v1.0.0
hooks:
- id: runic
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
```
([#1083])

### Other
- Ferrite now uses [Runic.jl](https://github.com/fredrikekre/Runic.jl) for code formatting.
([#1096])

## [v1.0.0] - 2024-09-30

Ferrite version 1.0 is a relatively large release, with a lot of new features, improvements,
Expand Down Expand Up @@ -1027,3 +1031,4 @@ poking into Ferrite internals:
[#1058]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1058
[#1059]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1059
[#1083]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1083
[#1096]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1096
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@ issues][open-issues].
Remember to always include (when applicable): i) unit tests which exercises the new code,
ii) documentation, iii) a note in the [CHANGELOG.md](CHANGELOG.md) file.

### Code formatting

Ferrite uses [Runic.jl][runic] for code formatting. You can install Runic with the following
command:

```shell
julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
```

and you can then run the formatter from the root of the repository with:

```shell
julia --project=@runic -e 'using Runic; exit(Runic.main(ARGS))' -- --inplace .
```

Refer to the Runic.jl [README][runic-readme] for more details (such as editor integration).


### pre-commit hooks

Ferrite uses [pre-commit] to run various checks (including Runic formatting). After
installing pre-commit (refer to the [pre-commit installation
instructions][pre-commit-install]) run the following from the root of the repository to
configure pre-commit to run before each commit:

```shell
pre-commit install
```


[documenter]: https://juliadocs.github.io/Documenter.jl/
[first-contributions]: https://github.com/firstcontributions/first-contributions
Expand All @@ -80,6 +109,10 @@ ii) documentation, iii) a note in the [CHANGELOG.md](CHANGELOG.md) file.
[new-discussion]: https://github.com/Ferrite-FEM/Ferrite.jl/discussions/new
[new-issue]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/new
[open-issues]: https://github.com/Ferrite-FEM/Ferrite.jl/issues
[pre-commit-install]: https://pre-commit.com/#install
[pre-commit]: https://pre-commit.com/
[runic-readme]: https://github.com/fredrikekre/Runic.jl/blob/master/README.md
[runic]: https://github.com/fredrikekre/Runic.jl
[so-mre]: https://stackoverflow.com/help/minimal-reproducible-example
[tim-doc]: https://youtu.be/ZpH1ry8qqfw
[tim-git]: https://youtu.be/cquJ9kPkwR8
4 changes: 2 additions & 2 deletions docs/src/literate-tutorials/computational_homogenization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ function homogenize_test(u::Matrix, dh, cv, E_incl, E_mat) #
Ē′ = SymmetricTensor{4, 2}() do i, j, k, l #src
ij = i == j == 1 ? 1 : i == j == 2 ? 2 : 3 #src
kl = k == l == 1 ? 1 : k == l == 2 ? 2 : 3 #src
εij = function_symmetric_gradient(cv, qp, view(ue, :, ij)) + #src
εij = function_symmetric_gradient(cv, qp, view(ue, :, ij)) + #src
symmetric((basevec(Vec{2}, i) basevec(Vec{2}, j))) #src
εkl = function_symmetric_gradient(cv, qp, view(ue, :, kl)) + #src
εkl = function_symmetric_gradient(cv, qp, view(ue, :, kl)) + #src
symmetric((basevec(Vec{2}, k) basevec(Vec{2}, l))) #src
return (εij E εkl) *#src
end #src
Expand Down

0 comments on commit d6e43f4

Please sign in to comment.