Skip to content

Commit

Permalink
Formatted with config file and adding format check
Browse files Browse the repository at this point in the history
* Added format file .JuliaFormatter
* Added GitHub Action for format checking
* Formatted the code with the file above and some hand tweaks on
comments
  • Loading branch information
anchal-physics committed Sep 21, 2023
1 parent fe8c6c1 commit 7f73bc7
Show file tree
Hide file tree
Showing 4 changed files with 552 additions and 284 deletions.
27 changes: 27 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
align_assignment = true
align_conditional = true
align_matrix = true
align_pair_arrow = true
align_struct_field = true
always_for_in = true
always_use_return = true
annotate_untyped_fields_with_any = false
conditional_to_if = true
for_in_replacement = ""
format_docstrings = true
import_to_using = true
indent = 4
indent_submodule = true
join_lines_based_on_source = true
long_to_short_function_def = true
margin = 88
normalize_line_endings = "unix"
pipe_to_function_call = true
remove_extra_newlines = true
separate_kwargs_with_semicolon = true
surround_whereop_typeparameters = true
trailing_comma = true
whitespace_in_kwargs = false
whitespace_ops_in_indices = false
whitespace_typedefs = true
yas_style_nesting = true
36 changes: 36 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Format Check

on:
push:
branches: ["master", "dev", "format"]
pull_request:
branches: ["master", "dev"]
jobs:
check:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.9.3]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
Loading

0 comments on commit 7f73bc7

Please sign in to comment.