From d6e4d840512836569e98ef000ff130a7442ff22b Mon Sep 17 00:00:00 2001 From: vil02 Date: Mon, 30 Oct 2023 19:46:03 +0100 Subject: [PATCH] chore: add `check_format.yml` --- .github/workflows/check_format.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/check_format.yml diff --git a/.github/workflows/check_format.yml b/.github/workflows/check_format.yml new file mode 100644 index 00000000..33413cef --- /dev/null +++ b/.github/workflows/check_format.yml @@ -0,0 +1,39 @@ +--- +name: check_format + +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + +jobs: + check_format: + name: Check format + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@v1 + with: + version: 1.8 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install JuliaFormatter + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + + - name: Format code + run: | + git clean -f -x -d + julia -e 'using JuliaFormatter; format(".", verbose=true)' + + - name: Fail if needs reformatting + run: | + if [[ $(git status --porcelain) ]]; then + echo "please reformat these files:" + git status --porcelain=v1 + exit 1 + fi