-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 1.95 KB
/
Copy pathci.yml
File metadata and controls
78 lines (65 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo Binaries
id: deps-cache
uses: actions/cache@v4
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-lint-${{ hashFiles('.github/workflows/ci.yml') }}
- name: Install Selene
if: steps.deps-cache.outputs.cache-hit != 'true'
run: cargo install selene
- name: Lint
run: make lint
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Cache Cargo Binaries
id: deps-cache
uses: actions/cache@v4
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-format-${{ hashFiles('.github/workflows/ci.yml') }}
- name: Install Stylua
if: steps.deps-cache.outputs.cache-hit != 'true'
run: cargo install stylua
- name: Check format
id: check-format
continue-on-error: true
run: |
make check-format || {
echo "::error::Code formatting check failed. The workflow will automatically format the code and commit the changes in a new commit."
exit 1
}
- name: Format
if: steps.check-format.outcome == 'failure'
run: make format
- name: Commit changes
if: steps.check-format.outcome == 'failure'
run: |
git config --global user.name 'Github Actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am 'Format code'
git push