diff --git a/.github/workflows/test_size.yml b/.github/workflows/test_size.yml index 3b0e403a3aefb..3fcd015c1287e 100644 --- a/.github/workflows/test_size.yml +++ b/.github/workflows/test_size.yml @@ -60,270 +60,169 @@ concurrency: jobs: build: runs-on: ubuntu-22.04 - container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 - strategy: - fail-fast: false # don't cancel if a job from the matrix fails - matrix: - toolchain: [ - chibios, - ] - config: [ - Durandal, - MatekF405, - KakuteF7, - MatekH743-bdshot, - MambaH743v4, # for littlefs support - Pixhawk1-1M, - MatekF405-CAN, # see special "build bootloader" code below - DrotekP3Pro, # see special "build bootloader" code below - Hitec-Airspeed, # see special code for Periph below (3 places!) - f103-GPS # see special code for Periph below (3 places!) - ] - include: - - config: disco - toolchain: armhf - exclude: - - config: disco - toolchain: chibios + container: ardupilot/ardupilot-dev-chibios:v0.1.3 + permissions: + contents: read + pull-requests: write + steps: - uses: actions/checkout@v6 with: - ref: ${{ github.event.pull_request.base.ref }} - path: base_branch + fetch-depth: 0 submodules: 'recursive' + # Put ccache into github cache for faster build - name: Prepare ccache timestamp id: ccache_cache_timestamp run: | NOW=$(date -u +"%F-%T") echo "timestamp=${NOW}" >> $GITHUB_OUTPUT + - name: ccache cache files uses: actions/cache@v5 with: path: ~/.ccache - key: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{steps.ccache_cache_timestamp.outputs.timestamp}} - restore-keys: ${{github.workflow}}-ccache-${{ matrix.toolchain }}- # restore ccache from either previous build on this branch or on base branch + key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: ${{github.workflow}}-ccache- + - name: setup ccache run: | - . base_branch/.github/workflows/ccache.env - - name: Build ${{ github.event.pull_request.base.ref }} ${{matrix.config}} ${{ matrix.toolchain }} - env: - CI_BUILD_TARGET: ${{matrix.config}} - shell: bash - run: | - set -ex - # set up some variables based on what sort of build we're doing: - BOOTLOADER=0 - AP_PERIPH=0 - if [ "${{matrix.config}}" = "Hitec-Airspeed" ] || - [ "${{matrix.config}}" = "f103-GPS" ]; then - AP_PERIPH=1 - elif [ "${{matrix.config}}" = "MatekF405-CAN" ] || - [ "${{matrix.config}}" = "DrotekP3Pro" ]; then - BOOTLOADER=1 - fi - if [ $BOOTLOADER -eq 1 ]; then - BIN_SRC="build/${{matrix.config}}/bootloader" - else - BIN_SRC="build/${{matrix.config}}/bin" - fi - - git config --global --add safe.directory ${GITHUB_WORKSPACE} - PATH="/github/home/.local/bin:$PATH" - - # build the base branch - cd base_branch - # configure: - if [ $BOOTLOADER -eq 1 ]; then - ./waf configure --board ${{matrix.config}} --bootloader - else - ./waf configure --board ${{matrix.config}} - fi - # build: - if [ $AP_PERIPH -eq 1 ]; then - ./waf AP_Periph - elif [ $BOOTLOADER -eq 1 ]; then - ./waf bootloader - else - ./waf - fi - mkdir -p $GITHUB_WORKSPACE/base_branch_bin - - cp -r $BIN_SRC/* $GITHUB_WORKSPACE/base_branch_bin/ - - # build a set of binaries without symbols so we can check if - # the binaries have changed. - echo [`date`] Building ${{ github.event.pull_request.base.ref }} with no versions - - NO_VERSIONS_DIR="$GITHUB_WORKSPACE/base_branch_bin_no_versions" - mkdir "$NO_VERSIONS_DIR" - - # export some environment variables designed to get - # repeatable builds from the same source: - export CHIBIOS_GIT_VERSION="12345678" - export GIT_VERSION_EXTENDED="0123456789abcdef" - export GIT_VERSION="abcdef" - export GIT_VERSION_INT="15" - - if [ $AP_PERIPH -eq 1 ]; then - ./waf AP_Periph - elif [ $BOOTLOADER -eq 1 ]; then - ./waf bootloader - else - ./waf - fi - cp -r $BIN_SRC/* "$NO_VERSIONS_DIR" - - echo [`date`] Built ${{ github.event.pull_request.base.ref }} with no versions - - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - path: 'pr' + . .github/workflows/ccache.env - - name: Build PR rebased ${{matrix.config}} ${{ matrix.toolchain }} - env: - CI_BUILD_TARGET: ${{matrix.config}} - shell: bash + - name: Install rsync run: | - set -ex - # set up some variables based on what sort of build we're doing: - BOOTLOADER=0 - AP_PERIPH=0 - if [ "${{matrix.config}}" = "Hitec-Airspeed" ] || - [ "${{matrix.config}}" = "f103-GPS" ]; then - AP_PERIPH=1 - elif [ "${{matrix.config}}" = "MatekF405-CAN" ] || - [ "${{matrix.config}}" = "DrotekP3Pro" ]; then - BOOTLOADER=1 - fi - if [ $BOOTLOADER -eq 1 ]; then - BIN_SRC="build/${{matrix.config}}/bootloader" - else - BIN_SRC="build/${{matrix.config}}/bin" - fi - git config --global --add safe.directory ${GITHUB_WORKSPACE} - PATH="/github/home/.local/bin:$PATH" - cd pr/ - git config user.email "ardupilot-ci@ardupilot.org" - git config user.name "ArduPilot CI" - git remote add target_repo https://github.com/${{github.event.pull_request.base.repo.full_name}} - git fetch --no-tags --prune --progress target_repo ${{ github.event.pull_request.base.ref }} - git rebase target_repo/${{ github.event.pull_request.base.ref }} - git submodule update --init --recursive --depth=1 - # configure - if [ $BOOTLOADER -eq 1 ]; then - ./waf configure --board ${{matrix.config}} --bootloader - else - ./waf configure --board ${{matrix.config}} - fi - # build - if [ $AP_PERIPH -eq 1 ]; then - ./waf AP_Periph - elif [ $BOOTLOADER -eq 1 ]; then - ./waf bootloader - else - ./waf - fi - mkdir $GITHUB_WORKSPACE/pr_bin - cp -r $BIN_SRC/* $GITHUB_WORKSPACE/pr_bin/ - - # build a set of binaries without symbols so we can check if - # the binaries have changed. - echo [`date`] Building PR with no versions - - NO_VERSIONS_DIR="$GITHUB_WORKSPACE/pr_bin_no_versions" - mkdir "$NO_VERSIONS_DIR" - - # export some environment variables designed to get - # repeatable builds from the same source: - export CHIBIOS_GIT_VERSION="12345678" - export GIT_VERSION_EXTENDED="0123456789abcdef" - export GIT_VERSION="abcdef" - export GIT_VERSION_INT="15" + apt-get update + apt-get install -y rsync - if [ $AP_PERIPH -eq 1 ]; then - ./waf AP_Periph - elif [ $BOOTLOADER -eq 1 ]; then - ./waf bootloader - else - ./waf - fi - cp -r $BIN_SRC/* "$NO_VERSIONS_DIR" - - echo [`date`] Built PR with no versions - - # build MatekF405 Plane without quadplane - if [ "${{matrix.config}}" = "MatekF405" ]; then - PLANE_BINARY="build/MatekF405/bin/arduplane.bin" - echo "normal size" - ls -l "$PLANE_BINARY" - EXTRA_HWDEF="/tmp/extra-options.def" - echo "define HAL_QUADPLANE_ENABLED 0" >"$EXTRA_HWDEF" - ./waf configure --board ${{matrix.config}} --extra-hwdef="$EXTRA_HWDEF" - ./waf plane - rm "$EXTRA_HWDEF" - echo "non-quadplane size:" - ls -l "$PLANE_BINARY" - fi - - - name: Full size compare with base branch + - name: Setup git references for size comparison shell: bash run: | - cd pr/ - Tools/scripts/build_tests/pretty_diff_size.py -m $GITHUB_WORKSPACE/base_branch_bin_no_versions -s $GITHUB_WORKSPACE/pr_bin_no_versions + git config --global --add safe.directory ${GITHUB_WORKSPACE} + # Add the base repository as a remote and fetch the base branch + git remote add upstream ${{ github.event.pull_request.base.repo.clone_url }} + git fetch --no-tags --prune --progress upstream ${{ github.event.pull_request.base.ref }} - - name: Feature compare with ${{ github.event.pull_request.base.ref }} + - name: Build and compare sizes using size_compare_branches.py shell: bash run: | - set -ex - cd pr/ - BIN_PREFIX="arm-none-eabi-" - if [ "${{matrix.toolchain}}" = "armhf" ]; then - BIN_PREFIX="arm-linux-gnueabihf-" - fi - BOOTLOADER=0 - AP_PERIPH=0 - if [ "${{matrix.config}}" = "Hitec-Airspeed" ] || - [ "${{matrix.config}}" = "f103-GPS" ]; then - AP_PERIPH=1 - elif [ "${{matrix.config}}" = "MatekF405-CAN" ] || - [ "${{matrix.config}}" = "DrotekP3Pro" ]; then - BOOTLOADER=1 - fi - if [ $AP_PERIPH -eq 1 ]; then - EF_BINARY_NAME="AP_Periph" - elif [ $BOOTLOADER -eq 1 ]; then - EF_BINARY_NAME="AP_Bootloader" - else - EF_BINARY_NAME="arduplane" - fi - EF_BASE_BRANCH_BINARY="$GITHUB_WORKSPACE/base_branch_bin/$EF_BINARY_NAME" - EF_PR_BRANCH_BINARY="$GITHUB_WORKSPACE/pr_bin/$EF_BINARY_NAME" - - Tools/scripts/extract_features.py "$EF_BASE_BRANCH_BINARY" --nm "${BIN_PREFIX}nm" >features-base_branch.txt - Tools/scripts/extract_features.py "$EF_PR_BRANCH_BINARY" --nm "${BIN_PREFIX}nm" >features-pr.txt - diff -u features-base_branch.txt features-pr.txt || true - diff_output=$(diff -u features-base_branch.txt features-pr.txt || true) - echo "### Features Diff Output" >> $GITHUB_STEP_SUMMARY - if [ -n "$diff_output" ]; then - echo '```diff' >> $GITHUB_STEP_SUMMARY - echo "$diff_output" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - else - echo "No differences found." >> $GITHUB_STEP_SUMMARY - fi + PATH="/github/home/.local/bin:$PATH" - - name: Binary compare with ${{ github.event.pull_request.base.ref }} - shell: bash - run: | - diff -r $GITHUB_WORKSPACE/base_branch_bin_no_versions $GITHUB_WORKSPACE/pr_bin_no_versions --exclude=*.abin --exclude=*.apj || true - diff_output=$(diff -r $GITHUB_WORKSPACE/base_branch_bin_no_versions $GITHUB_WORKSPACE/pr_bin_no_versions --exclude=*.abin --exclude=*.apj || true) - echo "### Binary Diff Output" >> $GITHUB_STEP_SUMMARY - if [ -n "$diff_output" ]; then - echo '```diff' >> $GITHUB_STEP_SUMMARY - echo "$diff_output" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - else - echo "No differences found." >> $GITHUB_STEP_SUMMARY - fi + # Run size_compare_branches.py with parallelization + # Use upstream/ref instead of just ref since that's where we fetched it + python3 Tools/scripts/size_compare_branches.py \ + --board Durandal \ + --board MatekF405 \ + --board KakuteF7 \ + --board MatekH743-bdshot \ + --board MambaH743v4 \ + --board Pixhawk1-1M \ + --board MatekF405-CAN \ + --board DrotekP3Pro \ + --board Hitec-Airspeed \ + --board f103-GPS \ + --all-vehicles \ + --features \ + -j 8 \ + --master-branch upstream/${{ github.event.pull_request.base.ref }} \ + | tee /tmp/size_compare_output.txt + + - name: Format and post size comparison results + if: always() && github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const pr_number = context.issue.number; + + // Read the output from size_compare_branches.py + let output = ''; + try { + output = fs.readFileSync('/tmp/size_compare_output.txt', 'utf8'); + } catch (error) { + output = 'Error: Could not read size comparison output'; + } + + // Parse and format the output + const lines = output.split('\n'); + let sizeSection = ''; + let featureSection = ''; + let inFeatures = false; + + for (const line of lines) { + // Detect feature changes section + if (line.includes('Feature changes') || line.includes('features added') || line.includes('features removed')) { + inFeatures = true; + } + + // Format size changes - match CSV header and data rows + // Header: "Board,AP_Periph,..." + // Data rows: "MatekF405,1234,*,-500" etc + if (line.match(/^Board,/) || line.match(/^[A-Za-z0-9_-]+,/)) { + sizeSection += line + '\n'; + } + + // Format feature changes + if (inFeatures && line.trim()) { + // Make feature lists more readable + if (line.includes('added:') || line.includes('removed:')) { + featureSection += '\n**' + line.trim() + '**\n'; + } else if (line.trim().startsWith('-') || line.trim().startsWith('+')) { + // Format added/removed features with better symbols + const formatted = line.replace(/^\s*\+/, ' ✅ ').replace(/^\s*-/, ' ❌ '); + featureSection += formatted + '\n'; + } else { + featureSection += line + '\n'; + } + } + } + + // Build the comment body + let commentBody = `## 📊 Size Comparison Report\n\n`; + commentBody += `Build completed for commit ${context.sha.substring(0, 7)}\n\n`; + + if (sizeSection.trim()) { + commentBody += `### 📦 Size Changes\n\n`; + commentBody += '```\n' + sizeSection.trim() + '\n```\n\n'; + } + + if (featureSection.trim()) { + commentBody += `### 🔧 Feature Changes\n\n`; + commentBody += featureSection.trim() + '\n\n'; + } + + if (!sizeSection.trim() && !featureSection.trim()) { + commentBody += `No size or feature changes detected.\n\n`; + } + + commentBody += `---\n`; + commentBody += `*Updated automatically by the size test workflow*`; + + // Find and update or create comment + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + }); + + const botComment = comments.data.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('Size Comparison Report') + ); + + if (botComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: commentBody + }); + console.log('Updated existing comment'); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + body: commentBody + }); + console.log('Created new comment'); + } diff --git a/libraries/AP_Mount/AP_Mount_config.h b/libraries/AP_Mount/AP_Mount_config.h index 377b3e3040005..6a022d38e0e72 100644 --- a/libraries/AP_Mount/AP_Mount_config.h +++ b/libraries/AP_Mount/AP_Mount_config.h @@ -6,7 +6,7 @@ #include #ifndef HAL_MOUNT_ENABLED -#define HAL_MOUNT_ENABLED 1 +#define HAL_MOUNT_ENABLED 0 #endif #ifndef AP_MOUNT_BACKEND_DEFAULT_ENABLED