Skip to content

Commit b95c737

Browse files
authored
Add Runic using GHA (#2268)
[Runic](https://github.com/fredrikekre/Runic.jl) is a newish Julia formatter, that JuliaGPU has been adopting. A particularly nice feature is it's ability to format only ranges, and thus we can use a GHA to format Enzyme over-time. Using [pre-commit](https://pre-commit.com/) one can also easily install a git pre commit hook.
1 parent 871577f commit b95c737

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.github/workflows/Format.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
11+
# needed for julia-actions/cache to delete old caches
12+
actions: write
13+
14+
# needed for googleapis/code-suggester
15+
pull-requests: write
16+
17+
jobs:
18+
runic:
19+
runs-on: ubuntu-latest
20+
if: github.event.pull_request.draft == false
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{github.event.pull_request.head.ref}}
25+
repository: ${{github.event.pull_request.head.repo.full_name}}
26+
fetch-depth: 0
27+
28+
- name: Setup Julia
29+
uses: julia-actions/setup-julia@v2
30+
with:
31+
version: '1'
32+
arch: 'x64'
33+
- uses: julia-actions/cache@v2
34+
35+
- name: Install Runic
36+
run: |
37+
julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
38+
curl -o git-runic https://raw.githubusercontent.com/fredrikekre/Runic.jl/master/bin/git-runic
39+
chmod +x git-runic
40+
sudo mv git-runic /usr/local/bin
41+
42+
- name: Run Runic
43+
run: |
44+
set +e
45+
git runic origin/master
46+
[ $? -eq 2 ] && exit 1 || exit 0
47+
48+
- name: Suggest changes
49+
uses: googleapis/code-suggester@v2
50+
env:
51+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
with:
53+
command: review
54+
pull_number: ${{ github.event.pull_request.number }}
55+
git_dir: '.'

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/fredrikekre/runic-pre-commit
3+
rev: v1.0.0
4+
hooks:
5+
- id: runic

0 commit comments

Comments
 (0)