diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000000000..d9b106905426e --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +always_for_in = true diff --git a/.github/workflows/JuliaFormatter.yml b/.github/workflows/JuliaFormatter.yml new file mode 100644 index 0000000000000..ed0d73989dfa3 --- /dev/null +++ b/.github/workflows/JuliaFormatter.yml @@ -0,0 +1,36 @@ +name: Code style + +on: + pull_request: + +jobs: + JuliaFormatter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + - name: Install dependencies + run: | + using Pkg + Pkg.add("JuliaFormatter") + shell: julia --color=yes {0} + - name: Format Julia files + run: | + using JuliaFormatter + + base = ENV["GITHUB_BASE_REF"] # "main" + run(`git fetch origin $base`) + + cmd = `git diff -z --name-only origin/$base` + files = split(read(cmd, String), '\0') + filter!(endswith(".jl"), files) + + println("Formatting:") + foreach(println, files) + + format(files) + shell: julia --color=yes --compile=min -O0 {0} + - name: suggester / JuliaFormatter + uses: reviewdog/action-suggester@v1 + with: + tool_name: JuliaFormatter