Skip to content

Commit c4738af

Browse files
authored
Merge branch 'main' into feat/rtl-type-prioritize-home
2 parents 78b285a + 8c4b703 commit c4738af

80 files changed

Lines changed: 2560 additions & 471 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Gazebo Classic SITL
2+
description: Build PX4 firmware and Gazebo Classic plugins with ccache stats
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build - PX4 Firmware (SITL)
8+
shell: bash
9+
run: make px4_sitl_default
10+
11+
- name: Cache - Stats after PX4 Firmware
12+
shell: bash
13+
run: ccache -s
14+
15+
- name: Build - Gazebo Classic Plugins
16+
shell: bash
17+
run: make px4_sitl_default sitl_gazebo-classic
18+
19+
- name: Cache - Stats after Gazebo Plugins
20+
shell: bash
21+
run: ccache -s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Save ccache
2+
description: Print ccache stats and save to cache
3+
4+
inputs:
5+
cache-primary-key:
6+
description: Primary cache key from setup-ccache output
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Cache - Stats
13+
if: always()
14+
shell: bash
15+
run: ccache -s
16+
17+
- name: Cache - Save ccache
18+
if: always()
19+
uses: actions/cache/save@v4
20+
with:
21+
path: ~/.ccache
22+
key: ${{ inputs.cache-primary-key }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Setup ccache
2+
description: Restore ccache from cache and configure ccache.conf
3+
4+
inputs:
5+
cache-key-prefix:
6+
description: Cache key prefix (e.g. ccache-sitl)
7+
required: true
8+
max-size:
9+
description: Max ccache size (e.g. 300M)
10+
required: false
11+
default: '300M'
12+
base-dir:
13+
description: ccache base_dir value
14+
required: false
15+
default: '${GITHUB_WORKSPACE}'
16+
install-ccache:
17+
description: Install ccache via apt before configuring
18+
required: false
19+
default: 'false'
20+
21+
outputs:
22+
cache-primary-key:
23+
description: Primary cache key (pass to save-ccache)
24+
value: ${{ steps.restore.outputs.cache-primary-key }}
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- name: Cache - Install ccache
30+
if: inputs.install-ccache == 'true'
31+
shell: bash
32+
run: apt-get update && apt-get install -y ccache
33+
34+
- name: Cache - Restore ccache
35+
id: restore
36+
uses: actions/cache/restore@v4
37+
with:
38+
path: ~/.ccache
39+
key: ${{ inputs.cache-key-prefix }}-${{ github.ref_name }}-${{ github.sha }}
40+
restore-keys: |
41+
${{ inputs.cache-key-prefix }}-${{ github.ref_name }}-
42+
${{ inputs.cache-key-prefix }}-${{ github.base_ref || 'main' }}-
43+
${{ inputs.cache-key-prefix }}-
44+
45+
- name: Cache - Configure ccache
46+
shell: bash
47+
run: |
48+
mkdir -p ~/.ccache
49+
echo "base_dir = ${{ inputs.base-dir }}" > ~/.ccache/ccache.conf
50+
echo "compression = true" >> ~/.ccache/ccache.conf
51+
echo "compression_level = 6" >> ~/.ccache/ccache.conf
52+
echo "max_size = ${{ inputs.max-size }}" >> ~/.ccache/ccache.conf
53+
echo "hash_dir = false" >> ~/.ccache/ccache.conf
54+
echo "compiler_check = content" >> ~/.ccache/ccache.conf
55+
ccache -s
56+
ccache -z

.github/workflows/build_deb_package.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ jobs:
9898
fetch-depth: 0
9999
fetch-tags: true
100100

101+
- name: Use AWS regional apt mirror
102+
if: startsWith(runner.name, 'runs-on--')
103+
run: ./Tools/ci/use_aws_apt_mirror.sh
104+
101105
- name: Cache apt packages
102106
uses: actions/cache@v4
103107
with:
@@ -126,10 +130,10 @@ jobs:
126130
fail-fast: false
127131
matrix:
128132
include:
129-
- { image: sih, target: sih, arch: amd64, runner: x64, platform: "linux/amd64", dockerfile: Dockerfile.sih }
130-
- { image: sih, target: sih, arch: arm64, runner: arm64, platform: "linux/arm64", dockerfile: Dockerfile.sih }
131-
- { image: gazebo, target: default, arch: amd64, runner: x64, platform: "linux/amd64", dockerfile: Dockerfile.gazebo }
132-
- { image: gazebo, target: default, arch: arm64, runner: arm64, platform: "linux/arm64", dockerfile: Dockerfile.gazebo }
133+
- { image: sih, repo: px4-sitl, target: sih, arch: amd64, runner: x64, platform: "linux/amd64", dockerfile: Dockerfile.sih }
134+
- { image: sih, repo: px4-sitl, target: sih, arch: arm64, runner: arm64, platform: "linux/arm64", dockerfile: Dockerfile.sih }
135+
- { image: gazebo, repo: px4-sitl-gazebo, target: default, arch: amd64, runner: x64, platform: "linux/amd64", dockerfile: Dockerfile.gazebo }
136+
- { image: gazebo, repo: px4-sitl-gazebo, target: default, arch: arm64, runner: arm64, platform: "linux/arm64", dockerfile: Dockerfile.gazebo }
133137
steps:
134138
- uses: runs-on/action@v2
135139
- uses: actions/checkout@v4
@@ -164,10 +168,10 @@ jobs:
164168
context: docker-context
165169
file: Tools/packaging/${{ matrix.dockerfile }}
166170
tags: |
167-
px4io/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
168-
px4io/px4-sitl-${{ matrix.image }}:latest-${{ matrix.arch }}
169-
ghcr.io/px4/px4-sitl-${{ matrix.image }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
170-
ghcr.io/px4/px4-sitl-${{ matrix.image }}:latest-${{ matrix.arch }}
171+
px4io/${{ matrix.repo }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
172+
px4io/${{ matrix.repo }}:latest-${{ matrix.arch }}
173+
ghcr.io/px4/${{ matrix.repo }}:${{ needs.setup.outputs.px4_version }}-${{ matrix.arch }}
174+
ghcr.io/px4/${{ matrix.repo }}:latest-${{ matrix.arch }}
171175
platforms: ${{ matrix.platform }}
172176
load: false
173177
push: ${{ needs.setup.outputs.should_push == 'true' }}
@@ -185,7 +189,9 @@ jobs:
185189
runs-on: [runs-on,"runner=1cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",extras=s3-cache,spot=false]
186190
strategy:
187191
matrix:
188-
image: [sih, gazebo]
192+
include:
193+
- { image: sih, repo: px4-sitl }
194+
- { image: gazebo, repo: px4-sitl-gazebo }
189195
steps:
190196
- uses: runs-on/action@v2
191197

@@ -199,7 +205,7 @@ jobs:
199205
VERSION="${{ needs.setup.outputs.px4_version }}"
200206
201207
for REGISTRY in px4io ghcr.io/px4; do
202-
IMAGE="${REGISTRY}/px4-sitl-${{ matrix.image }}"
208+
IMAGE="${REGISTRY}/${{ matrix.repo }}"
203209
204210
for TAG in ${VERSION} latest; do
205211
docker manifest create ${IMAGE}:${TAG} \

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222

2323
container:
24-
image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556
24+
image: ghcr.io/px4/px4-dev:v1.17.0-rc2
2525

2626
strategy:
2727
fail-fast: false
@@ -50,7 +50,7 @@ jobs:
5050
PX4_SBOM_DISABLE: 1
5151
run: |
5252
cd "$GITHUB_WORKSPACE"
53-
git config --global --add safe.directory "$GITHUB_WORKSPACE"
53+
git config --system --add safe.directory '*'
5454
make ${{ matrix.check }}
5555
5656
- name: Uploading Coverage to Codecov.io

.github/workflows/clang-tidy.yml

Lines changed: 102 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
name: Clang-Tidy
2121
runs-on: [runs-on, runner=16cpu-linux-x64, "run-id=${{ github.run_id }}", "extras=s3-cache"]
2222
container:
23-
image: px4io/px4-dev:v1.17.0-beta1
23+
image: ghcr.io/px4/px4-dev:v1.17.0-rc2
24+
outputs:
25+
has_findings: ${{ steps.clang_tidy.outputs.has_findings }}
2426
steps:
2527
- uses: runs-on/action@v2
2628
- uses: actions/checkout@v4
@@ -31,39 +33,110 @@ jobs:
3133
- name: Configure Git Safe Directory
3234
run: git config --system --add safe.directory '*'
3335

34-
- name: Restore Compiler Cache
35-
id: cc_restore
36-
uses: actions/cache/restore@v4
36+
- uses: ./.github/actions/setup-ccache
37+
id: ccache
3738
with:
38-
path: ~/.ccache
39-
key: ccache-clang-tidy-${{ github.head_ref || github.ref_name }}
40-
restore-keys: |
41-
ccache-clang-tidy-${{ github.head_ref || github.ref_name }}-
42-
ccache-clang-tidy-main-
43-
ccache-clang-tidy-
39+
cache-key-prefix: ccache-clang-tidy
40+
max-size: 120M
4441

45-
- name: Configure Compiler Cache
46-
run: |
47-
mkdir -p ~/.ccache
48-
echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf
49-
echo "compression = true" >> ~/.ccache/ccache.conf
50-
echo "compression_level = 6" >> ~/.ccache/ccache.conf
51-
echo "max_size = 120M" >> ~/.ccache/ccache.conf
52-
echo "hash_dir = false" >> ~/.ccache/ccache.conf
53-
echo "compiler_check = content" >> ~/.ccache/ccache.conf
54-
ccache -s
55-
ccache -z
42+
- name: Build - px4_sitl_default (Clang)
43+
run: make -j16 px4_sitl_default-clang
5644

5745
- name: Run Clang-Tidy Analysis
58-
run: make -j16 clang-tidy
46+
id: clang_tidy
47+
run: |
48+
if [ "${{ github.event_name }}" != "pull_request" ]; then
49+
make -j$(nproc) clang-tidy
50+
echo "has_findings=false" >> $GITHUB_OUTPUT
51+
else
52+
output=$(python3 Tools/ci/run-clang-tidy-pr.py origin/${{ github.base_ref }} 2>&1)
53+
exit_code=$?
54+
echo "$output"
55+
# Helper prints this message on both early-exit paths
56+
# (no changed C++ files, or no matching TUs in the compile DB)
57+
if echo "$output" | grep -q "skipping clang-tidy"; then
58+
echo "has_findings=false" >> $GITHUB_OUTPUT
59+
else
60+
echo "has_findings=true" >> $GITHUB_OUTPUT
61+
fi
62+
exit $exit_code
63+
fi
5964
60-
- name: Compiler Cache Stats
61-
if: always()
62-
run: ccache -s
65+
- name: Upload compile_commands.json
66+
if: always() && github.event_name == 'pull_request'
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: compile-commands
70+
path: build/px4_sitl_default-clang/compile_commands.json
71+
retention-days: 1
6372

64-
- name: Save Compiler Cache
73+
- uses: ./.github/actions/save-ccache
6574
if: always()
66-
uses: actions/cache/save@v4
6775
with:
68-
path: ~/.ccache
69-
key: ${{ steps.cc_restore.outputs.cache-primary-key }}
76+
cache-primary-key: ${{ steps.ccache.outputs.cache-primary-key }}
77+
78+
post_clang_tidy_comments:
79+
name: Clang-Tidy PR Annotations
80+
needs: [clang_tidy]
81+
runs-on: ubuntu-latest
82+
permissions:
83+
pull-requests: write
84+
contents: read
85+
if: >-
86+
always()
87+
&& github.event.pull_request
88+
&& github.event.pull_request.head.repo.full_name == github.repository
89+
&& (needs.clang_tidy.result == 'success' || needs.clang_tidy.result == 'failure')
90+
&& needs.clang_tidy.outputs.has_findings == 'true'
91+
steps:
92+
- uses: actions/checkout@v4
93+
with:
94+
fetch-depth: 0
95+
96+
- name: Install clang-tools (for clang-tidy-diff)
97+
run: sudo apt-get install -y clang-tools
98+
99+
- name: Download compile_commands.json
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: compile-commands
103+
path: build/px4_sitl_default-clang
104+
105+
- name: Run clang-tidy-diff and export fixes
106+
run: |
107+
# WHY WE REWRITE compile_commands.json PATHS
108+
#
109+
# The clang_tidy job runs on a RunsOn/AWS runner where the workspace
110+
# root is "/__w/PX4-Autopilot/PX4-Autopilot". All absolute paths baked
111+
# into compile_commands.json (the "file" and "directory" fields, and
112+
# every -I include path in "command") use that prefix.
113+
#
114+
# This annotation job runs on a GitHub-hosted runner where the
115+
# workspace root is "/home/runner/work/PX4-Autopilot/PX4-Autopilot".
116+
# When clang-tidy-diff invokes clang-tidy, it reads the "directory"
117+
# field from compile_commands.json and calls chdir() on it. Since
118+
# the AWS-style path does not exist here, clang-tidy crashes with:
119+
# LLVM ERROR: Cannot chdir into "/__w/.../build/px4_sitl_default-clang"
120+
# and silently produces an empty fixes.yml, so no annotations are posted.
121+
#
122+
# Fix: rewrite all occurrences of the AWS workspace prefix to the
123+
# current runner workspace ($GITHUB_WORKSPACE) before invoking
124+
# clang-tidy-diff. Safe because compile_commands.json is a local
125+
# scratch file pulled from the artifact; no source file is modified.
126+
sed -i "s|/__w/PX4-Autopilot/PX4-Autopilot|${GITHUB_WORKSPACE}|g" \
127+
build/px4_sitl_default-clang/compile_commands.json
128+
129+
mkdir -p clang-tidy-result
130+
git diff -U0 origin/${{ github.base_ref }}...HEAD \
131+
| clang-tidy-diff-18.py -p1 \
132+
-path build/px4_sitl_default-clang \
133+
-export-fixes clang-tidy-result/fixes.yml \
134+
-j0 || true
135+
136+
- name: Annotate PR with clang-tidy findings
137+
uses: platisd/clang-tidy-pr-comments@v1
138+
with:
139+
github_token: ${{ secrets.GITHUB_TOKEN }}
140+
clang_tidy_fixes: clang-tidy-result/fixes.yml
141+
request_changes: true
142+
suggestions_per_comment: 10

.github/workflows/compile_ubuntu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949
5050
- uses: actions/checkout@v4
5151

52+
- name: Use AWS regional apt mirror
53+
if: startsWith(runner.name, 'runs-on--')
54+
run: ./Tools/ci/use_aws_apt_mirror.sh
55+
5256
- name: Install Deps, Build, and Make Quick Check
5357
run: |
5458
# we need to install dependencies and build on the same step

0 commit comments

Comments
 (0)