-
Notifications
You must be signed in to change notification settings - Fork 429
formatter with Runic #1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
formatter with Runic #1987
Changes from all commits
572590d
22ef918
af6c728
67ed560
e0864bb
6fe7afa
2cb35ca
6ef4382
3bede98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[deps] | ||
Runic = "62bfec6d-59d7-401d-8490-b29ee721c001" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Runic | ||
|
||
project_path = Base.Filesystem.joinpath(Base.Filesystem.dirname(Base.source_path()), "..") | ||
|
||
println("Formatting code with Runic...") | ||
|
||
# Format all files in the project | ||
not_formatted = Runic.main(["--inplace", project_path]) | ||
if not_formatted == 0 | ||
@info "Formatting completed successfully." | ||
else | ||
@warn "Formatting failed!" | ||
end | ||
exit(not_formatted) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Runic | ||
|
||
project_path = Base.Filesystem.joinpath(Base.Filesystem.dirname(Base.source_path()), "..") | ||
|
||
println("Checking code formatting with Runic...") | ||
|
||
# Check if files are properly formatted | ||
not_formatted = Runic.main(["--check", "--diff", project_path]) | ||
|
||
if not_formatted == 0 | ||
println("✅ All files are properly formatted!") | ||
exit(0) | ||
else | ||
println("❌ Formatting check failed!") | ||
println("Some files are not properly formatted.") | ||
println("To fix formatting, run: julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(\".formatting/format_all.jl\")'") | ||
exit(1) | ||
end |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work - this is referring to the commit in your fork but we have to ignore the commit that might finally land in the master branch. We have to add this file only once the formatting commit is in the master branch and its hash is known. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Runic formatting commit | ||
e0864bbfea8e3a766f4d49ec956dc8ea52f19e9e |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,7 +5,7 @@ on: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
branches: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- master | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tags: '*' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tags: "*" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to change this?
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
merge_group: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -16,15 +16,30 @@ concurrency: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: Format Check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: julia-actions/setup-julia@v2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: "1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
show-versioninfo: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: julia-actions/cache@v2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
julia --project=.formatting -e ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Pkg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pkg.instantiate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
include(".formatting/format_check.jl")' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+19
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should keep it simple and just follow the recommended and documented workflow in the Runic docs:
Suggested change
Possibly it could be made a separate workflow as in e.g. PDMats (https://github.com/JuliaStats/PDMats.jl/blob/master/.github/workflows/Format.yml) but that doesn't matter too much IMO. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
test: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runs-on: ${{ matrix.os }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
strategy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fail-fast: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
matrix: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- 'min' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- '1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "min" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to change these lines:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- pre | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -57,7 +72,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: julia-actions/setup-julia@v2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: '1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: "1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
show-versioninfo: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
julia --project=docs -e ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ Distributions.jl | |||||||||||||||||||||||||||
[](https://zenodo.org/record/2647458) | ||||||||||||||||||||||||||||
[](https://coveralls.io/r/JuliaStats/Distributions.jl?branch=master) | ||||||||||||||||||||||||||||
[](https://github.com/JuliaTesting/Aqua.jl) | ||||||||||||||||||||||||||||
[](https://github.com/fredrikekre/Runic.jl) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
[](https://JuliaStats.github.io/Distributions.jl/latest/) | ||||||||||||||||||||||||||||
[](https://JuliaStats.github.io/Distributions.jl/stable/) | ||||||||||||||||||||||||||||
|
@@ -40,7 +41,7 @@ not been reported yet on the issues of the repository. | |||||||||||||||||||||||||||
If not, you can file a new issue, add your version of the package | ||||||||||||||||||||||||||||
which you can get with this command in the Julia REPL: | ||||||||||||||||||||||||||||
```julia | ||||||||||||||||||||||||||||
julia> ]status Distributions | ||||||||||||||||||||||||||||
julia> ] status Distributions | ||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Be exhaustive in your report, summarize the bug, and provide: | ||||||||||||||||||||||||||||
|
@@ -55,6 +56,20 @@ clone it and make modifications on a new branch, | |||||||||||||||||||||||||||
Once your changes are made, push them on your fork and create the | ||||||||||||||||||||||||||||
Pull Request on the main repository. | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
To format the code, run the following command: | ||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||
julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(".formatting/format_all.jl")' | ||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
**Note:** Code formatting is automatically checked in CI using Runic. | ||||||||||||||||||||||||||||
The formatting command can be run locally with | ||||||||||||||||||||||||||||
```julia | ||||||||||||||||||||||||||||
julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(".formatting/format_check.jl")' | ||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||
The `.git-blame-ignore-revs` file contains commit hashes for mass formatting changes. | ||||||||||||||||||||||||||||
This allows `git blame` to show the actual authors of code changes rather than the formatting commit. | ||||||||||||||||||||||||||||
When viewing blame information, use `git blame --ignore-revs-file .git-blame-ignore-revs <filename>`. | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Comment on lines
+59
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to document it more prominently (not sure about it, users don't have to care and everyone who submits a PR will notice and learn it anyway), we should just refer to the Runic docs.
Suggested change
|
||||||||||||||||||||||||||||
### Requirements | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Distributions is a central package which many rely on, | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file and all other files in this folder. It has to be maintained and there is no reason for users to do anything else than following the Runic documentation.