@@ -2,15 +2,26 @@ name: Pre-commit check
2
2
3
3
on :
4
4
pull_request :
5
- types : [opened, reopened, synchronize, labeled]
5
+ types : [opened, synchronize, reopened, labeled]
6
+
7
+ concurrency :
8
+ group : pre-commit-${{ github.head_ref || github.ref_name }}
9
+ cancel-in-progress : true
6
10
7
11
jobs :
8
12
lint :
9
- if : |
10
- contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
11
- name : Checking if any fixes are needed
13
+ # if: ${{ contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') }}
14
+ name : Run pre-commit hooks
12
15
runs-on : ubuntu-latest
13
16
steps :
17
+ - name : Wait for other jobs to finish
18
+
19
+ with :
20
+ ref : ${{ github.sha }}
21
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
22
+ running-workflow-name : Run pre-commit hooks
23
+ check-regexp : Arduino [0-9]+ on ubuntu-latest
24
+
14
25
- name : Checkout latest commit
15
26
uses : actions/checkout@v4
16
27
with :
35
46
~/.cache/pip
36
47
key : pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
37
48
49
+ - name : Get workflow id
50
+ run : |
51
+ RUNID=$(gh api repos/${{github.event.pull_request.head.repo.full_name}}/commits/${{github.event.pull_request.head.sha}}/check-runs | \
52
+ jq -r '.check_runs[] | \
53
+ select(.name == "Arduino 0 on ubuntu-latest") | \
54
+ .html_url | \
55
+ capture("/runs/(?<number>[0-9]+)/jobs") | \
56
+ .number' | \
57
+ sed 's/"//g' | \
58
+ head -n 1)
59
+ echo "WORKFLOW_ID = $RUNID"
60
+
61
+ - name : Download compilation artifacts
62
+ uses : actions/download-artifact@v4
63
+ if : ${{ env.WORKFLOW_ID != null }}
64
+ with :
65
+ pattern : build-job-*
66
+ merge-multiple : true
67
+ path : ~/.arduino/tests/
68
+ run-id : ${{ env.WORKFLOW_ID }}
69
+ github-token : ${{ secrets.GITHUB_TOKEN }}
70
+
71
+ - name : Merge compile commands
72
+ if : ${{ steps.check-artifact.outputs.exists == 'true' }}
73
+ run : |
74
+ find ~/.arduino/tests/ -iname "compile_commands.json" | xargs jq -s 'map(.[])' > ~/compile_commands.json
75
+
76
+ - name : Upload compile commands
77
+ if : ${{ steps.check-artifact.outputs.exists == 'true' }}
78
+ uses : actions/upload-artifact@v4
79
+ with :
80
+ name : compile_commands
81
+ path : ~/compile_commands.json
82
+
38
83
- name : Install python dependencies
39
84
run : python -m pip install pre-commit docutils
40
85
0 commit comments