From ded0d1b92042449216a11fb4293bee8d29f1749e Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Sun, 6 Oct 2024 12:43:27 +0200 Subject: [PATCH] try another format github action --- .github/workflows/Format.yml | 106 +++++++++-------------------------- 1 file changed, 27 insertions(+), 79 deletions(-) diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml index d43cfa4..f08e0fc 100644 --- a/.github/workflows/Format.yml +++ b/.github/workflows/Format.yml @@ -1,93 +1,41 @@ -name: "Format Checking" +name: format-check on: push: - tags: - - '*' branches: - 'main' + tags: '*' pull_request: - branches: - - 'main' - - workflow_call: - inputs: - directory: - description: "The directory on which JuliaFormatter needs to be run" - default: "." - required: false - type: string - julia-version: - description: "Julia version" - default: "1" - required: false - type: string - juliaformatter-version: - description: "Version of JuliaFormatter to use" - default: "1" - required: false - type: string - concurrent-jobs: - description: "Run jobs concurrently" - default: false - required: false - type: boolean - cancel-in-progress: - description: "Cancel jobs in-progress in favor of a new one in the same concurrency group" - default: true - required: false - type: boolean - - outputs: - formatted: - description: "If the specified directory is already formatted or not." - value: "${{ jobs.format-check.outputs.formatted }}" - format-diff-patch: - description: "A patch consisting of formatting changes which can be applied to comply with format checking. Available only if `outputs.formatted` is `false`" - value: "${{ jobs.format-check.outputs.formatting-changes }}" - -concurrency: - group: "${{ inputs.concurrent-jobs && github.run_id || github.ref }}:${{ github.workflow }}" - cancel-in-progress: ${{ !inputs.concurrent-jobs && inputs.cancel-in-progress }} jobs: - format-check: - name: "Check Formatting" - runs-on: ubuntu-latest - outputs: - formatted: "${{ steps.check-formatting.outputs.formatted }}" - formatting-changes: "${{ steps.check-formatting.outputs.formatting-changes }}" + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] steps: - - uses: actions/checkout@v4 - - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@latest with: - version: "${{ inputs.julia-version }}" + version: ${{ matrix.julia-version }} - - name: "Install JuliaFormatter and run formatter on ${{ github.repository }}${{ inputs.directory != '.' && format('/{0}',inputs.directory) || '' }}" - shell: julia --color=yes {0} + - uses: actions/checkout@v4 + - 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: | - using Pkg - Pkg.add(PackageSpec(name="JuliaFormatter", version="${{ inputs.juliaformatter-version }}")) - using JuliaFormatter - format("./${{ inputs.directory }}", verbose=true) - - - name: "Check formatting" - id: check-formatting + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Format check run: | - MODIFIED_FILES="$(git diff --name-only)" - - if [ -z "$MODIFIED_FILES" ]; then - echo "formatted=true" >> $GITHUB_OUTPUT + julia -e ' + out = Cmd(`git diff`) |> read |> String + if out == "" + exit(0) else - echo "Format check failed. Please format the following file(s) with JuliaFormatter v${{ inputs.juliaformatter-version }}." - echo "$MODIFIED_FILES" - - { - echo "formatting-changes<> $GITHUB_OUTPUT - - exit 1 - fi \ No newline at end of file + @error "Some files have not been formatted !!!" + write(stdout, out) + exit(1) + end' \ No newline at end of file