forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (85 loc) · 2.89 KB
/
Copy pathpre-commit.yml
File metadata and controls
97 lines (85 loc) · 2.89 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
97
name: pre-commit
on:
push:
branches:
- master
- 'Stable*'
paths-ignore:
- 'docs/**'
- 'translations/**'
pull_request:
paths-ignore:
- 'docs/**'
- 'translations/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 1
persist-credentials: false
- name: Get build config
id: config
uses: ./.github/actions/build-config
- name: Setup Python
uses: ./.github/actions/setup-python
with:
groups: precommit
python-version: '3.12'
- name: Install Qt (for qmllint)
uses: ./.github/actions/qt-install
with:
version: ${{ steps.config.outputs.qt_version }}
host: linux
arch: linux_gcc_64
modules: ''
archives: qtbase qtdeclarative icu
- name: Run pre-commit
id: pre-commit
continue-on-error: true
env:
PRE_COMMIT_OUTPUT: pre-commit-output.txt
run: python3 ./tools/pre_commit.py --ci
- name: Prepare pre-commit results artifact
if: github.event_name == 'pull_request' && always()
env:
EXIT_CODE: ${{ steps.pre-commit.outputs.exit_code }}
PASSED: ${{ steps.pre-commit.outputs.passed }}
FAILED: ${{ steps.pre-commit.outputs.failed }}
SKIPPED: ${{ steps.pre-commit.outputs.skipped }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
python3 "${GITHUB_WORKSPACE}/.github/scripts/precommit_results.py" \
--output-dir pre-commit-results \
--exit-code "${EXIT_CODE:-1}" \
--passed "${PASSED:-0}" \
--failed "${FAILED:-0}" \
--skipped "${SKIPPED:-0}" \
--run-url "${RUN_URL}" \
--output-file pre-commit-output.txt
- name: Upload pre-commit results artifact
if: github.event_name == 'pull_request' && always()
uses: actions/upload-artifact@v7
with:
name: pre-commit-results
path: pre-commit-results
retention-days: 7
# Hook failures are surfaced via the PR comment; only fail the job when
# the runner script itself didn't complete (no exit_code output written).
- name: Fail job on pre-commit script crash
if: always() && steps.pre-commit.outcome == 'failure' && steps.pre-commit.outputs.exit_code == ''
run: |
echo "::error::pre-commit runner crashed before writing results"
exit 1