Skip to content

Commit 7544a8c

Browse files
committed
Format CI
1 parent 8496cbe commit 7544a8c

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

.github/workflows/format_check.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Format check
2+
on:
3+
push:
4+
branches: [master]
5+
tags: [v*]
6+
pull_request:
7+
8+
jobs:
9+
format:
10+
name: "Format Check"
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: julia-actions/setup-julia@v1
15+
with:
16+
version: 1
17+
- name: Install JuliaFormatter and format
18+
run: |
19+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
20+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
21+
- name: Check format
22+
run: |
23+
julia -e '
24+
out = Cmd(`git diff --name-only`) |> read |> String
25+
if out == ""
26+
exit(0)
27+
else
28+
@error "The following files have not been formatted:"
29+
write(stdout, out)
30+
out_diff = Cmd(`git diff`) |> read |> String
31+
@error "Diff:"
32+
write(stdout, out_diff)
33+
exit(1)
34+
@error ""
35+
end'

.github/workflows/format_pr.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: format-pr
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *'
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install JuliaFormatter and format
11+
run: |
12+
julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
13+
julia -e 'using JuliaFormatter; format(".")'
14+
# https://github.com/marketplace/actions/create-pull-request
15+
# https://github.com/peter-evans/create-pull-request#reference-example
16+
- name: Create Pull Request
17+
id: cpr
18+
uses: peter-evans/create-pull-request@v3
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
commit-message: Format .jl files
22+
title: 'Automatic JuliaFormatter.jl run'
23+
branch: auto-juliaformatter-pr
24+
delete-branch: true
25+
labels: formatting, automated pr, no changelog
26+
- name: Check outputs
27+
run: |
28+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
29+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Format suggestions
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
# Skip intermediate builds: always.
8+
# Cancel intermediate builds: only if it is a pull request build.
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
11+
12+
jobs:
13+
format:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: julia-actions/setup-julia@latest
18+
with:
19+
version: 1
20+
- run: |
21+
julia -e 'using Pkg; Pkg.add("JuliaFormatter")'
22+
julia -e 'using JuliaFormatter; format("."; verbose=true)'
23+
- uses: reviewdog/action-suggester@v1
24+
with:
25+
tool_name: JuliaFormatter
26+
fail_on_error: true
27+
filter_mode: added

0 commit comments

Comments
 (0)