-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use BlueStyle and JuliaFormatter (#246)
We have been using JuliaFormatter quite successfully for some while in the JuliaGaussianProcesses organization, and I think it would be good to adopt some style guide also in DynamicPPL and other TuringLang packages. This helps to keep the code base consistent and, in my opinion, increases readability and reduces mental overhead. I just chose [BlueStyle](https://github.com/invenia/BlueStyle) here since it is used in JuliaGaussianProcesses. I would be fine with YAS as well, I think a main criterion should just be that is supported by [JuliaFormatter](https://github.com/domluna/JuliaFormatter.jl) since this makes it much easier to format code correctly. Speaking about convenience, I also added a configuration for JuliaFormatter such that one can just run `format(path_to_repo)` to re-format the codebase correctly (actually, that's what I did when putting together the PR). Moreover, I added a Github action that will automatically check and report if PRs are formatted correctly. It will even post suggestions with format fixes (if required) which is even more convenient.
- Loading branch information
Showing
38 changed files
with
828 additions
and
788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
style="blue" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Format | ||
|
||
on: | ||
push: | ||
branches: | ||
# This is where pull requests from "bors r+" are built. | ||
- staging | ||
# This is where pull requests from "bors try" are built. | ||
- trying | ||
# Build the master branch. | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: 1 | ||
- name: Format code | ||
run: | | ||
using Pkg | ||
Pkg.add(; name="JuliaFormatter", uuid="98e50ef6-434e-11e9-1051-2b60c6c9e899") | ||
using JuliaFormatter | ||
format("."; verbose=true) | ||
shell: julia --color=yes {0} | ||
- uses: reviewdog/action-suggester@v1 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
tool_name: JuliaFormatter | ||
fail_on_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.