From 54daa94c904169ed6b4aeae920f3227524ff3a8a Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Mon, 28 Jun 2021 12:37:55 +0200 Subject: [PATCH] CI: make macos tests more useful by compiling all target and use ccache --- .github/workflows/macos_build.yml | 48 +++++++++++++++++-- .../install-prereqs-mac.sh | 36 +++++++------- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml index bdf9d5753d..5c5c891fde 100644 --- a/.github/workflows/macos_build.yml +++ b/.github/workflows/macos_build.yml @@ -8,16 +8,56 @@ concurrency: jobs: build: runs-on: 'macos-latest' + strategy: + fail-fast: false # don't cancel if a job from the matrix fails + matrix: + config: [ + sitl, + CubeOrange, + ] steps: - uses: actions/checkout@v2 + with: + submodules: 'recursive' - name: Install Prerequisites shell: bash run: | + if [[ ${{ matrix.config }} == "sitl" ]]; then + export DO_AP_STM_ENV=0 + fi Tools/environment_install/install-prereqs-mac.sh -y source ~/.bash_profile + # Put ccache into github cache for faster build + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + run: | + NOW=$(date -u +"%F-%T") + echo "::set-output name=timestamp::${NOW}" + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{github.workflow}}-ccache-${{matrix.config}}-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: ${{github.workflow}}-ccache-${{matrix.config}} # restore ccache from either previous build on this branch or on master + - name: setup ccache + run: | + mkdir -p ~/.ccache + echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf + echo "compression = true" >> ~/.ccache/ccache.conf + echo "compression_level = 6" >> ~/.ccache/ccache.conf + echo "max_size = 400M" >> ~/.ccache/ccache.conf + ccache -s + ccache -z + - name: test build ${{matrix.config}} + env: + CI_BUILD_TARGET: ${{matrix.config}} + shell: bash + run: | + source ~/.bash_profile + PATH="/github/home/.local/bin:$PATH" echo $PATH - ./waf configure --board CubeOrange - ./waf plane - ./waf configure --board sitl - ./waf plane + ./waf configure --board ${{matrix.config}} + ./waf + ccache -s + ccache -z diff --git a/Tools/environment_install/install-prereqs-mac.sh b/Tools/environment_install/install-prereqs-mac.sh index 6e45ddbd5d..c900479803 100755 --- a/Tools/environment_install/install-prereqs-mac.sh +++ b/Tools/environment_install/install-prereqs-mac.sh @@ -129,18 +129,18 @@ if [[ -z "${DO_AP_STM_ENV}" ]] && maybe_prompt_user "Install ArduPilot STM32 too DO_AP_STM_ENV=1 fi +echo "Checking ccache..." +{ + $(which -s ccache) +} || +{ + brew install ccache + exportline="export PATH=/usr/local/opt/ccache/libexec:\$PATH"; + eval $exportline +} +CCACHE_PATH=$(which ccache) + if [[ $DO_AP_STM_ENV -eq 1 ]]; then - echo "Checking ccache..." - { - $(which -s ccache) - } || - { - brew install ccache - exportline="export PATH=/usr/local/opt/ccache/libexec:\$PATH"; - echo $exportline >> ~/$SHELL_LOGIN - eval $exportline - } - CCACHE_PATH=$(which ccache) install_arm_none_eabi_toolchain fi @@ -162,6 +162,8 @@ echo "Adding ArduPilot Tools to environment" SCRIPT_DIR=$(dirname $(grealpath ${BASH_SOURCE[0]})) ARDUPILOT_ROOT=$(grealpath "$SCRIPT_DIR/../../") + +if [[ $DO_AP_STM_ENV -eq 1 ]]; then exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH"; grep -Fxq "$exportline" ~/$SHELL_LOGIN 2>/dev/null || { if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then @@ -171,15 +173,13 @@ grep -Fxq "$exportline" ~/$SHELL_LOGIN 2>/dev/null || { echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH." fi } +fi -SCRIPT_DIR=$(dirname $(grealpath ${BASH_SOURCE[0]})) -ARDUPILOT_ROOT=$(grealpath "$SCRIPT_DIR/../../") - -exportline="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH"; -grep -Fxq "$exportline" ~/$SHELL_LOGIN 2>/dev/null || { +exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH"; +grep -Fxq "$exportline2" ~/$SHELL_LOGIN 2>/dev/null || { if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then - echo $exportline >> ~/$SHELL_LOGIN - eval $exportline + echo $exportline2 >> ~/$SHELL_LOGIN + eval $exportline2 else echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH." fi