Skip to content

Commit ded0d1b

Browse files
committed
try another format github action
1 parent 90148ef commit ded0d1b

File tree

1 file changed

+27
-79
lines changed

1 file changed

+27
-79
lines changed

.github/workflows/Format.yml

Lines changed: 27 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,41 @@
1-
name: "Format Checking"
1+
name: format-check
22

33
on:
44
push:
5-
tags:
6-
- '*'
75
branches:
86
- 'main'
7+
tags: '*'
98
pull_request:
10-
branches:
11-
- 'main'
12-
13-
workflow_call:
14-
inputs:
15-
directory:
16-
description: "The directory on which JuliaFormatter needs to be run"
17-
default: "."
18-
required: false
19-
type: string
20-
julia-version:
21-
description: "Julia version"
22-
default: "1"
23-
required: false
24-
type: string
25-
juliaformatter-version:
26-
description: "Version of JuliaFormatter to use"
27-
default: "1"
28-
required: false
29-
type: string
30-
concurrent-jobs:
31-
description: "Run jobs concurrently"
32-
default: false
33-
required: false
34-
type: boolean
35-
cancel-in-progress:
36-
description: "Cancel jobs in-progress in favor of a new one in the same concurrency group"
37-
default: true
38-
required: false
39-
type: boolean
40-
41-
outputs:
42-
formatted:
43-
description: "If the specified directory is already formatted or not."
44-
value: "${{ jobs.format-check.outputs.formatted }}"
45-
format-diff-patch:
46-
description: "A patch consisting of formatting changes which can be applied to comply with format checking. Available only if `outputs.formatted` is `false`"
47-
value: "${{ jobs.format-check.outputs.formatting-changes }}"
48-
49-
concurrency:
50-
group: "${{ inputs.concurrent-jobs && github.run_id || github.ref }}:${{ github.workflow }}"
51-
cancel-in-progress: ${{ !inputs.concurrent-jobs && inputs.cancel-in-progress }}
529

5310
jobs:
54-
format-check:
55-
name: "Check Formatting"
56-
runs-on: ubuntu-latest
57-
outputs:
58-
formatted: "${{ steps.check-formatting.outputs.formatted }}"
59-
formatting-changes: "${{ steps.check-formatting.outputs.formatting-changes }}"
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
julia-version: [1]
16+
julia-arch: [x86]
17+
os: [ubuntu-latest]
6018
steps:
61-
- uses: actions/checkout@v4
62-
63-
- uses: julia-actions/setup-julia@v1
19+
- uses: julia-actions/setup-julia@latest
6420
with:
65-
version: "${{ inputs.julia-version }}"
21+
version: ${{ matrix.julia-version }}
6622

67-
- name: "Install JuliaFormatter and run formatter on ${{ github.repository }}${{ inputs.directory != '.' && format('/{0}',inputs.directory) || '' }}"
68-
shell: julia --color=yes {0}
23+
- uses: actions/checkout@v4
24+
- name: Install JuliaFormatter and format
25+
# This will use the latest version by default but you can set the version like so:
26+
#
27+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
6928
run: |
70-
using Pkg
71-
Pkg.add(PackageSpec(name="JuliaFormatter", version="${{ inputs.juliaformatter-version }}"))
72-
using JuliaFormatter
73-
format("./${{ inputs.directory }}", verbose=true)
74-
75-
- name: "Check formatting"
76-
id: check-formatting
29+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
30+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
31+
- name: Format check
7732
run: |
78-
MODIFIED_FILES="$(git diff --name-only)"
79-
80-
if [ -z "$MODIFIED_FILES" ]; then
81-
echo "formatted=true" >> $GITHUB_OUTPUT
33+
julia -e '
34+
out = Cmd(`git diff`) |> read |> String
35+
if out == ""
36+
exit(0)
8237
else
83-
echo "Format check failed. Please format the following file(s) with JuliaFormatter v${{ inputs.juliaformatter-version }}."
84-
echo "$MODIFIED_FILES"
85-
86-
{
87-
echo "formatting-changes<<EOF"
88-
echo "$(git diff)"
89-
echo EOF
90-
} >> $GITHUB_OUTPUT
91-
92-
exit 1
93-
fi
38+
@error "Some files have not been formatted !!!"
39+
write(stdout, out)
40+
exit(1)
41+
end'

0 commit comments

Comments
 (0)