From 1bd52c1d8246ac222e1452ab33ec326db2af98f4 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Tue, 17 Dec 2024 09:17:56 +1100 Subject: [PATCH] ci: Carbonix_build workflow with new peripheral build and aircraft config collection steps --- .github/workflows/carbonix_build.yml | 158 ++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index 10914261f9..1c4ed3ef98 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -181,8 +181,162 @@ jobs: echo "::set-output name=s3_path::$PATH_TO_S3" shell: bash + build-periph: + runs-on: ubuntu-22.04 + needs: setup-s3-path + container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 + strategy: + fail-fast: false + matrix: + config: [ + CarbonixF405, + CarbonixF405-no-crystal + ] + + toolchain: [ chibios ] + gcc: [10] + exclude: + - gcc: 10 + toolchain: chibios-clang + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - 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@v3 + with: + path: ~/.ccache + key: ${{github.workflow}}-ccache-${{matrix.config}}-${{ matrix.toolchain }}-${{ matrix.gcc }}-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: ${{github.workflow}}-ccache-${{matrix.config}}-${{ matrix.toolchain }}-${{ matrix.gcc }} + + - name: setup ccache + run: | + . .github/workflows/ccache.env + + - name: Install bash tools + run: | + sudo apt-get update + sudo apt-get -y install xxd + + - name: build ${{matrix.config}} + shell: bash + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + if [[ ${{ matrix.toolchain }} == "chibios-clang" ]]; then + export CC=clang + export CXX=clang++ + fi + PATH="/usr/lib/ccache:/opt/gcc-arm-none-eabi-${{matrix.gcc}}/bin:$PATH" + PATH="/github/home/.local/bin:$PATH" + Tools/Carbonix_scripts/carbonix_waf_build.sh ${{ matrix.config }} + ccache -s + ccache -z + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-periph-${{ matrix.config }} + path: output/ + + collect-aircraft-config-files: + runs-on: ubuntu-22.04 + needs: build-periph + outputs: + aircraft-config-files: ${{ steps.collect.outputs.aircraft-config-files }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Collect XML files + id: collect + run: | + xml_files=$(find libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration -name "*.xml" -print0 | xargs -0 echo | tr -d '\n' | jq -R -s -c 'split(" ")') + echo "aircraft-config-files=$xml_files" >> $GITHUB_OUTPUT + + process-ac: + runs-on: ubuntu-22.04 + needs: [collect-aircraft-config-files, setup-s3-path] + container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 + strategy: + fail-fast: false + matrix: + xml_file: ${{ fromJson(needs.collect-aircraft-config-files.outputs.aircraft-config-files) }} + toolchain: [ chibios ] + gcc: [10] + exclude: + - gcc: 10 + toolchain: chibios-clang + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install bash tools + run: | + sudo apt-get update + sudo apt-get -y install xxd + + - name: Download all build artifacts + uses: actions/download-artifact@v3 + with: + path: periph-build/ + + - name: List files + run: | + ls -la periph-build/*/ + + - name: Configure Git Safe Directory + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - name: Get Commit ID + id: get_commit_id + run: | + COMMIT_ID=$(git rev-parse --short HEAD) + echo "commit_id=$COMMIT_ID" >> $GITHUB_ENV + shell: sh -e {0} + + - name: Run aircraft_config.py + run: | + python Tools/Carbonix_scripts/aircraft_config.py ${{ matrix.xml_file }} ${{ env.commit_id }} + ls -la final-output/*/ || echo "No files found" + + - name: Install AWS CLI + run: | + apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get install -y curl unzip + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip -q awscliv2.zip + ./aws/install --update + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Upload to S3 + run: | + PATH_TO_S3=${{ needs.setup-s3-path.outputs.s3_path }} + echo "Uploading Artifacts to: $PATH_TO_S3" + aws s3 cp final-output/ $PATH_TO_S3 --recursive + build-sitl: runs-on: 'windows-latest' + needs: setup-s3-path steps: - uses: actions/checkout@v4 with: @@ -217,12 +371,14 @@ jobs: echo "export CCACHE_MAXSIZE=400M" >> ~/ccache.conf && source ~/ccache.conf && ccache -s + - name: ccache cache files - uses: actions/cache@v4 + uses: actions/cache@v3 with: path: D:/a/ardupilot/ardupilot/ccache key: ${{ steps.ccache_cache_timestamp.outputs.cache-key }}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} restore-keys: ${{ steps.ccache_cache_timestamp.outputs.cache-key }}-ccache- # restore ccache from either previous build on this branch or on base branch + - name: Prepare Python environment env: PATH: /usr/bin:$(cygpath ${SYSTEMROOT})/system32