Skip to content

Commit

Permalink
Follow up changes to Runic formatting (#1099)
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 authored Oct 31, 2024
1 parent c50ce06 commit b56e2c9
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 19 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: "d9a27b9d6279a103fedc7202258207a7b7afe18c"

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
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@ 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(url = "https://github.com/fredrikekre/Runic.jl")'
```

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
```

Note that this currently requires Runic.jl to be installed in the shared `@runic`
environment according to the instructions above.


[documenter]: https://juliadocs.github.io/Documenter.jl/
[first-contributions]: https://github.com/firstcontributions/first-contributions
Expand All @@ -80,6 +112,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
24 changes: 14 additions & 10 deletions docs/src/literate-tutorials/ns_vs_diffeq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ dim = 2;
# We specify first the rectangle, the cylinder, the surface spanned by the cylinder
# and the boolean difference of rectangle and cylinder.
if !IS_CI #hide
rect_tag = gmsh.model.occ.add_rectangle(0, 0, 0, 1.1, 0.41)
circle_tag = gmsh.model.occ.add_circle(0.2, 0.2, 0, 0.05)
circle_curve_tag = gmsh.model.occ.add_curve_loop([circle_tag])
circle_surf_tag = gmsh.model.occ.add_plane_surface([circle_curve_tag])
gmsh.model.occ.cut([(dim, rect_tag)], [(dim, circle_surf_tag)])
# runic: off #src
rect_tag = gmsh.model.occ.add_rectangle(0, 0, 0, 1.1, 0.41)
circle_tag = gmsh.model.occ.add_circle(0.2, 0.2, 0, 0.05)
circle_curve_tag = gmsh.model.occ.add_curve_loop([circle_tag])
circle_surf_tag = gmsh.model.occ.add_plane_surface([circle_curve_tag])
gmsh.model.occ.cut([(dim, rect_tag)], [(dim, circle_surf_tag)])
# runic: on #src
else #hide
rect_tag = gmsh.model.occ.add_rectangle(0, 0, 0, 0.55, 0.41) #hide
end #hide
Expand All @@ -153,11 +155,13 @@ nothing
gmsh.model.occ.synchronize()
# In the next lines, we add the physical groups needed to define boundary conditions.
if !IS_CI #hide
bottomtag = gmsh.model.model.add_physical_group(dim - 1, [6], -1, "bottom")
lefttag = gmsh.model.model.add_physical_group(dim - 1, [7], -1, "left")
righttag = gmsh.model.model.add_physical_group(dim - 1, [8], -1, "right")
toptag = gmsh.model.model.add_physical_group(dim - 1, [9], -1, "top")
holetag = gmsh.model.model.add_physical_group(dim - 1, [5], -1, "hole")
# runic: off #src
bottomtag = gmsh.model.model.add_physical_group(dim - 1, [6], -1, "bottom")
lefttag = gmsh.model.model.add_physical_group(dim - 1, [7], -1, "left")
righttag = gmsh.model.model.add_physical_group(dim - 1, [8], -1, "right")
toptag = gmsh.model.model.add_physical_group(dim - 1, [9], -1, "top")
holetag = gmsh.model.model.add_physical_group(dim - 1, [5], -1, "hole")
# runic: on #src
else #hide
gmsh.model.model.add_physical_group(dim - 1, [4], 7, "left") #hide
gmsh.model.model.add_physical_group(dim - 1, [3], 8, "top") #hide
Expand Down

0 comments on commit b56e2c9

Please sign in to comment.