Skip to content

Introduce JuliaFormatter with style=blue #220

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

Merged
merged 17 commits into from
Jan 11, 2021
Merged

Introduce JuliaFormatter with style=blue #220

merged 17 commits into from
Jan 11, 2021

Conversation

st--
Copy link
Member

@st-- st-- commented Jan 9, 2021

Introduces a format check (using JuliaFormatter / https://github.com/julia-actions/julia-format) with style = "blue". Resolves #219.

@willtebbutt
Copy link
Member

I like this a lot 👍

@@ -113,10 +119,10 @@ include("zygote_adjoints.jl")
include("test_utils.jl")

function __init__()
@require Kronecker="2c470bb0-bcc8-11e8-3dad-c9649493f05e" begin
@require Kronecker = "2c470bb0-bcc8-11e8-3dad-c9649493f05e" begin
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit inconsistent to add whitespace here, compared with the conventions for keyword arguments - is this according to BlueStyle or a JuliaFormatter thing?

Choose a reason for hiding this comment

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

I agree. I suspect this is a JuliaFormatter (or CSTParser) issue

@devmotion
Copy link
Member

Did the merge commit revert any changes from JuliaFormatter? I guess it would be good to add the Github action for checking the format in this PR as well to be sure it passes.

@@ -47,3 +47,10 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov.info
format:
Copy link
Member Author

Choose a reason for hiding this comment

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

Separate from the others as format-testing should be independent of the host/version matrix and it seems more sensible to only run it once (and then it's easier to distinguish format failure from the "regular" tests)

@st-- st-- marked this pull request as ready for review January 9, 2021 18:49
@st-- st-- requested a review from devmotion January 9, 2021 22:23
Comment on lines 65 to 68
# The version of JuliaFormatter used is just to show how to specify the version. The latest
# version would be preferrable.
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.12.2"))'
Copy link
Member

Choose a reason for hiding this comment

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

I don't like that the version number has to be updated manually if there is a new version of JuliaFortmatter. We could just install the latest version but this means we would end up with breaking changes without realizing. Ideally, we would add a Project.toml file in some directory and be notified about breaking releases by CompatHelper.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, that'd be nice. I'm not sure how you'd go about sorting it out with the Project.toml (feel free to make those changes on this branch or a separate PR). I do think it's overall better to pin the version of the formatter, as otherwise it can be hard to figure out how exactly to get the local formatter be in sync with the cloud format-checker..

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how you'd go about sorting it out with the Project.toml

Similar to the package, tests, and documentation, we can specify the SemVer-compatible versions in a separate project environment. CompatHelper will automatically create a PR on Github if a new breaking release is available (we are not notified about non-breaking releases).

it can be hard to figure out how exactly to get the local formatter be in sync with the cloud format-checker.

I think specifying the version that we use in a project environment is the best we can do. We can't control which version of JuliaFormatter developers use in their editors or install globally but if they load our project environment it will always be compatible.

st-- and others added 2 commits January 9, 2021 23:15
@st-- st-- requested a review from devmotion January 9, 2021 23:19
@devmotion
Copy link
Member

I simplified the Github action and pushed some changes, but since I got involved now someone else has to approve the PR.

@willtebbutt willtebbutt requested a review from theogf January 10, 2021 01:07
@theogf
Copy link
Member

theogf commented Jan 11, 2021

@devmotion I think you still need to indicate that your change requests have been satisfied.

@theogf theogf merged commit d00fb95 into master Jan 11, 2021
@theogf theogf deleted the st/formatter branch January 11, 2021 10:47
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.

CI: introduce automatic code formatting (e.g. JuliaFormatter)?
5 participants