Skip to content

Commit da32c2b

Browse files
authored
Switch Format.yml to CUDA.jl style (#568)
1 parent 1516dce commit da32c2b

File tree

2 files changed

+105
-55
lines changed

2 files changed

+105
-55
lines changed

.github/workflows/Format.yml

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: 'Format'
2+
3+
on:
4+
pull_request_target:
5+
paths: ['**/*.jl']
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
pull-requests: write
12+
13+
jobs:
14+
runic:
15+
runs-on: ubuntu-latest
16+
if: github.event.pull_request.draft == false
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{github.event.pull_request.head.ref}}
22+
repository: ${{github.event.pull_request.head.repo.full_name}}
23+
fetch-depth: 0
24+
25+
- name: Add upstream remote
26+
run: |
27+
git remote add upstream https://github.com/${{ github.repository }}
28+
git fetch upstream
29+
30+
- name: Setup Julia
31+
uses: julia-actions/setup-julia@v2
32+
with:
33+
version: '1'
34+
arch: 'x64'
35+
- uses: julia-actions/cache@v2
36+
37+
- name: Install Runic
38+
run: |
39+
julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
40+
curl -o git-runic https://raw.githubusercontent.com/fredrikekre/Runic.jl/master/bin/git-runic
41+
chmod +x git-runic
42+
sudo mv git-runic /usr/local/bin
43+
44+
- name: Run Runic
45+
id: runic
46+
run: |
47+
set +e
48+
MERGE_BASE=$(git merge-base upstream/${{ github.base_ref }} HEAD) || exit 1
49+
DIFF=$(git runic --diff $MERGE_BASE)
50+
EXIT_CODE=$?
51+
52+
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
53+
echo "diff<<EOF" >> $GITHUB_OUTPUT
54+
echo "$DIFF" >> $GITHUB_OUTPUT
55+
echo "EOF" >> $GITHUB_OUTPUT
56+
57+
# if Runic failed, bail out
58+
[ $EXIT_CODE -eq 2 ] && exit 1 || exit 0
59+
60+
- name: Find comment
61+
uses: peter-evans/find-comment@v3
62+
id: find-comment
63+
with:
64+
issue-number: ${{ github.event.pull_request.number }}
65+
comment-author: 'github-actions[bot]'
66+
body-includes: '<!-- runic-format-summary -->'
67+
68+
- name: Comment formatting suggestions
69+
if: steps.runic.outputs.exit_code == 1
70+
uses: peter-evans/create-or-update-comment@v4
71+
with:
72+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
73+
issue-number: ${{ github.event.pull_request.number }}
74+
body: |
75+
<!-- runic-format-summary -->
76+
77+
Your PR requires formatting changes to meet the project's style guidelines.
78+
Please consider running [Runic](https://github.com/fredrikekre/Runic.jl) (`git runic ${{ github.base_ref }}`) to apply these changes.
79+
80+
<details>
81+
<summary>Click here to view the suggested changes.</summary>
82+
83+
```diff
84+
${{ steps.runic.outputs.diff }}
85+
```
86+
87+
</details>
88+
edit-mode: replace
89+
90+
- name: Update stale comment
91+
if: steps.runic.outputs.exit_code == 0 && steps.find-comment.outputs.comment-id
92+
uses: peter-evans/create-or-update-comment@v4
93+
with:
94+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
95+
issue-number: ${{ github.event.pull_request.number }}
96+
body: |
97+
<!-- runic-format-summary -->
98+
99+
Your PR no longer requires formatting changes. Thank you for your contribution!
100+
edit-mode: replace
101+
102+
# XXX: if Github ever supports allow-failure (actions/runner#2347)
103+
#- name: Propagate exit code
104+
# run: |
105+
# exit ${{ steps.runic.outputs.exit_code }}

.github/workflows/Formatting.yml

-55
This file was deleted.

0 commit comments

Comments
 (0)