diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml index 95b6013..f08e0fc 100644 --- a/.github/workflows/Format.yml +++ b/.github/workflows/Format.yml @@ -1,20 +1,41 @@ -name: Formatter +name: format-check -on: [pull_request] +on: + push: + branches: + - 'main' + tags: '*' + pull_request: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] steps: + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + - uses: actions/checkout@v4 - - uses: julia-actions/cache@v2 - name: Install JuliaFormatter and format + # This will use the latest version by default but you can set the version like so: + # + # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Format check run: | - julia -e 'import Pkg; Pkg.add("JuliaFormatter")' julia -e ' - using JuliaFormatter - result = format(".") - if result == false - error("Formatting failed") - end - ' + out = Cmd(`git diff`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have not been formatted !!!" + write(stdout, out) + exit(1) + end' \ No newline at end of file