Skip to content

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mmikhasenko
Copy link

@mmikhasenko mmikhasenko commented Jun 23, 2025

Formatting cleanup using JuliaFormatter.format(".") to ensure consistent code style across the package. This reduces noisy diffs in future changes and improves readability. No functional changes.

Closes #1401

Modifications

  • add .formating with scripts
  • modified README.md. Added formatting rules
  • added .git-blame-ignore-revs to
  • applied formatting

Tests

  • are passing

JuliaFormatter.format(".")
@mmikhasenko mmikhasenko marked this pull request as draft June 23, 2025 14:42
@devmotion
Copy link
Member

I'd actually prefer Runic, it seems to work fine in StatsFuns and PDMats and I've been bitten by JuliaFormatter 2 problems a few times. GLM uses JuliaFormatter though, so there is no agreed on standard in JuliaStats yet.

@mmikhasenko
Copy link
Author

I'd actually prefer Runic, it seems to work fine in StatsFuns and PDMats and I've been bitten by JuliaFormatter 2 problems a few times. GLM uses JuliaFormatter though, so there is no agreed on standard in JuliaStats yet.

completely fine with me, I do not have preference

@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 83.28518% with 405 lines in your changes missing coverage. Please review.

Project coverage is 86.21%. Comparing base (abb151c) to head (3bede98).

Files with missing lines Patch % Lines
src/univariate/continuous/kolmogorov.jl 36.36% 28 Missing ⚠️
src/samplers/obsoleted.jl 0.00% 20 Missing ⚠️
src/multivariate/mvnormal.jl 74.28% 18 Missing ⚠️
src/univariate/continuous/chernoff.jl 35.71% 18 Missing ⚠️
src/multivariate/dirichlet.jl 69.81% 16 Missing ⚠️
src/mixtures/mixturemodel.jl 76.19% 15 Missing ⚠️
src/univariate/continuous/triweight.jl 48.14% 14 Missing ⚠️
src/multivariate/mvtdist.jl 66.66% 12 Missing ⚠️
src/univariate/continuous/epanechnikov.jl 45.45% 12 Missing ⚠️
src/univariate/continuous/skewnormal.jl 62.50% 12 Missing ⚠️
... and 81 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1987      +/-   ##
==========================================
- Coverage   86.28%   86.21%   -0.08%     
==========================================
  Files         146      146              
  Lines        8787     8798      +11     
==========================================
+ Hits         7582     7585       +3     
- Misses       1205     1213       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mmikhasenko mmikhasenko changed the title formatter with JuliaFormatter formatter with Runic Jun 23, 2025
@mmikhasenko mmikhasenko marked this pull request as ready for review June 23, 2025 16:35
@mmikhasenko
Copy link
Author

The work is complete. Tests are passing.
Could you please review?

@mmikhasenko
Copy link
Author

ping @st-- , the author of original issue #1401, for an opinion.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -5,7 +5,7 @@ on:
push:
branches:
- master
tags: '*'
tags: "*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this?

Suggested change
tags: "*"
tags: '*'

Comment on lines +19 to +33
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")'
Copy link
Member

Choose a reason for hiding this comment

The 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
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")'
runic:
name: Runic formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v2
- uses: fredrikekre/runic-action@v1
with:
version: '1'

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.

Comment on lines +41 to +42
- "min"
- "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change these lines:

Suggested change
- "min"
- "1"
- 'min'
- '1'

@@ -57,7 +72,7 @@ jobs:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
version: "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version: "1"
version: '1'

Comment on lines +59 to +72
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>`.

Copy link
Member

Choose a reason for hiding this comment

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

@devmotion
Copy link
Member

Maybe let's merge #1905 before changing the formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JuliaFormatter to workflow
3 participants