Repository navigation
96 lines (80 loc) · 2.62 KB
/
Copy pathcode-style-check.yml
File metadata and controls
96 lines (80 loc) · 2.62 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Code Style Check
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
checks: write
jobs:
python-style-check:
name: Python Code Style Check
runs-on: ubuntu-latest
outputs:
needs_fix: ${{ steps.python-check.outcome == 'failure' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: pip install ruff==0.14.6
- name: Run Python style check
id: python-check
continue-on-error: true
run: make quality
- name: Set check status
if: steps.python-check.outcome == 'failure'
run: echo "Python style check failed, will trigger auto-fix workflow"
cpp-style-check:
name: C++ Code Style Check
runs-on: ubuntu-latest
outputs:
needs_fix: ${{ steps.cpp-check.outcome == 'failure' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install clang-format via pip
run: pip install clang-format==21.1.8
- name: Run C++ style check
id: cpp-check
continue-on-error: true
run: make cquality
- name: Set check status
if: steps.cpp-check.outcome == 'failure'
run: echo "C++ style check failed, will trigger auto-fix workflow"
trigger-auto-fix:
name: Trigger Auto-Fix if Needed
needs: [python-style-check, cpp-style-check]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && (needs.python-style-check.outputs.needs_fix == 'true' || needs.cpp-style-check.outputs.needs_fix == 'true')
steps:
- name: Trigger auto-fix workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Trigger the auto-fix workflow
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'auto-fix-code-style.yml',
ref: context.payload.pull_request.head.ref,
inputs: {
pr_number: context.payload.pull_request.number.toString(),
pr_branch: context.payload.pull_request.head.ref,
needs_python_fix: '${{ needs.python-style-check.outputs.needs_fix }}',
needs_cpp_fix: '${{ needs.cpp-style-check.outputs.needs_fix }}'
}
});