@@ -2,13 +2,17 @@ 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.event.pull_request.number || github.ref}}
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 : always()
14
+ # if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') }}
15
+ name : Run pre-commit hooks
12
16
runs-on : ubuntu-latest
13
17
steps :
14
18
- name : Checkout latest commit
35
39
~/.cache/pip
36
40
key : pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
37
41
42
+ - name : Wait for other jobs to finish
43
+
44
+ with :
45
+ ref : ${{ github.event.pull_request.head.sha }}
46
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
47
+ wait-interval : 30
48
+ check-regexp : ' ^Arduino [0-9]+ on ubuntu-latest$'
49
+
50
+ - name : Get workflow id
51
+ id : save-workflow-id
52
+ run : |
53
+ echo "Original repo: ${{ github.event.pull_request.head.repo.full_name }}"
54
+ RUNID=$(gh api repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${{ github.event.pull_request.head.sha }}/check-runs | \
55
+ jq -r '.check_runs[] | \
56
+ select(.name == "Arduino 0 on ubuntu-latest") | |
57
+ .html_url | \
58
+ capture("/runs/(?<number>[0-9]+)/job") | \
59
+ .number' | \
60
+ sed 's/"//g' | \
61
+ head -n 1)
62
+ echo "RUNID=$RUNID" >> $GITHUB_ENV
63
+ echo "Workflow id: $RUNID"
64
+
65
+ - name : Download compilation artifacts
66
+ uses : actions/download-artifact@v4
67
+ if : ${{ env.RUNID != '' }}
68
+ with :
69
+ pattern : build-job-*
70
+ merge-multiple : true
71
+ path : ~/.arduino/tests/
72
+ run-id : ${{ env.RUNID }}
73
+ github-token : ${{ secrets.GITHUB_TOKEN }}
74
+
75
+ - name : Merge compile commands
76
+ if : ${{ env.RUNID != '' }}
77
+ run : |
78
+ find ~/.arduino/tests/ -iname "compile_commands.json" | xargs jq -s 'map(.[])' > ~/compile_commands.json
79
+
80
+ - name : Upload compile commands
81
+ if : ${{ env.RUNID != '' }}
82
+ uses : actions/upload-artifact@v4
83
+ with :
84
+ name : compile_commands
85
+ path : ~/compile_commands.json
86
+
38
87
- name : Install python dependencies
39
88
run : python -m pip install pre-commit docutils
40
89
0 commit comments