diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 000000000..b7f16eb18 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1,12 @@ +annotate_untyped_fields_with_any = false +short_to_long_function_def = false +whitespace_ops_in_indices = true +remove_extra_newlines = true +whitespace_in_kwargs = true +always_use_return = false +conditional_to_if = false +align_struct_field = true +align_conditional = true +align_assignment = true +align_pair_arrow = true +import_to_using = false diff --git a/.github/workflows/Format-check.yml b/.github/workflows/Format-check.yml new file mode 100644 index 000000000..f2fb54d77 --- /dev/null +++ b/.github/workflows/Format-check.yml @@ -0,0 +1,39 @@ +name: format + +on: + push: + branches: + - 'master' + - 'release-' + tags: '*' + pull_request: + +jobs: + check: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: ['1'] + julia-arch: [x64] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + + - uses: actions/checkout@v2 + - name: Install JuliaFormatter and format + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + julia -e 'using JuliaFormatter; format(["src", "test"], 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'