From d7199bf69500d791e01eb239b3330832bdc3ab15 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Sun, 22 Jan 2023 10:45:07 -0300 Subject: [PATCH 1/7] Speed up CI using compiler cache --- .github/workflows/ci_pipeline.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 7c0ff8f5a..14f2e3fa9 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -25,16 +25,22 @@ jobs: - name: Install python packages run: pip install colcon-lcov-result==0.5.0 pre-commit==2.20.0 + - name: Cache + uses: hendrikmuhs/ccache-action@v1.2.8 + with: + key: ${{ github.job }} + verbose: 2 + - name: Build and test uses: ros-tooling/action-ros-ci@0.2.7 with: package-name: beluga beluga_amcl - target-ros2-distro: ${{ env.ROS_DISTRO }} + target-ros2-distro: ${{ env.ROS_DISTRO }} import-token: ${{ secrets.GITHUB_TOKEN }} colcon-defaults: | { "build": { - "mixin": ["coverage-gcc", "coverage-pytest"] + "mixin": ["ccache", "coverage-gcc", "coverage-pytest"] }, "test": { "mixin": ["coverage-pytest"] From a4a4c5af29c223e72fe1aedfc63c0310a0916dc6 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 10:04:21 -0300 Subject: [PATCH 2/7] Fix cache misses --- .github/workflows/ci_pipeline.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 14f2e3fa9..6960fd7e4 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -26,10 +26,19 @@ jobs: run: pip install colcon-lcov-result==0.5.0 pre-commit==2.20.0 - name: Cache - uses: hendrikmuhs/ccache-action@v1.2.8 + uses: Chocobo1/setup-ccache-action@v1 with: - key: ${{ github.job }} - verbose: 2 + api_token: ${{ secrets.GITHUB_TOKEN }} + update_packager_index: false + remove_stale_cache: false + # Disable hashing of the current working directory to avoid cache misses + # when building in two different directories. + # This might be an issue if we use the same cache storage for + # debug and release builds. + # See https://ccache.dev/manual/latest.html#config_hash_dir. + ccache_options: | + hash_dir=false + sloppiness= - name: Build and test uses: ros-tooling/action-ros-ci@0.2.7 @@ -51,6 +60,7 @@ jobs: - name: Lint shell: bash run: | + ccache --print-stats git config --global --add safe.directory $PWD source /opt/ros/${{ env.ROS_DISTRO }}/setup.sh pre-commit run --all-files --verbose --show-diff-on-failure From 9956d552c5ca3c1c8b108587348341ce081f527a Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 12:31:22 -0300 Subject: [PATCH 3/7] Try sloppiness settings --- .github/workflows/ci_pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 6960fd7e4..7f16c6348 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -38,7 +38,7 @@ jobs: # See https://ccache.dev/manual/latest.html#config_hash_dir. ccache_options: | hash_dir=false - sloppiness= + sloppiness=system_headers,time_macros,pch_defines,include_file_ctime,include_file_mtime - name: Build and test uses: ros-tooling/action-ros-ci@0.2.7 From 505e108c015db3c11c006bdb294fb81161237402 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 15:38:50 -0300 Subject: [PATCH 4/7] Upload artifact --- .github/workflows/ci_pipeline.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 7f16c6348..cfd4a4a72 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -57,6 +57,12 @@ jobs: } colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/c75e4b34a3959524564afb584e2aa33c7eec323c/index.yaml + - name: Upload cache as artifact + uses: actions/upload-artifact@v3 + with: + name: ccache + path: /github/home/.cache/ccache + - name: Lint shell: bash run: | From bc77da70af7e391842d8b2b6e48effc086ec7724 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 16:22:13 -0300 Subject: [PATCH 5/7] Use debug mode --- .github/workflows/ci_pipeline.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index cfd4a4a72..c76993d9a 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-22.04 env: ROS_DISTRO: humble + CCACHE_DEBUG: true container: image: ros:humble-ros-base-jammy steps: @@ -37,6 +38,7 @@ jobs: # debug and release builds. # See https://ccache.dev/manual/latest.html#config_hash_dir. ccache_options: | + debug=true hash_dir=false sloppiness=system_headers,time_macros,pch_defines,include_file_ctime,include_file_mtime From 50207e8d66e9d487b01b295f85126eb50f28d337 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 17:34:28 -0300 Subject: [PATCH 6/7] Hack to set configuration values --- .github/workflows/ci_pipeline.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index c76993d9a..1e1c1e519 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -51,7 +51,11 @@ jobs: colcon-defaults: | { "build": { - "mixin": ["ccache", "coverage-gcc", "coverage-pytest"] + "mixin": ["coverage-gcc", "coverage-pytest"], + "cmake-args": [ + "-DCMAKE_C_COMPILER_LAUNCHER=ccache;-o;hash_dir=false;-o;debug=true;&&;ccache;-p;&&;ccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache;-o;hash_dir=false;-o;debug=true;&&;ccache;-p;&&;ccache" + ] }, "test": { "mixin": ["coverage-pytest"] @@ -68,6 +72,8 @@ jobs: - name: Lint shell: bash run: | + cat ros_ws/build/compile_commands.json + ls -la ros_ws/src ccache --print-stats git config --global --add safe.directory $PWD source /opt/ros/${{ env.ROS_DISTRO }}/setup.sh From a02fdefecfd07b9a6197ecf62800fac7ce1d273a Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Mon, 23 Jan 2023 20:25:06 -0300 Subject: [PATCH 7/7] Try environment variable trick --- .github/scripts/ccache_with_fix.sh | 10 ++++++++++ .github/workflows/ci_pipeline.yml | 16 ++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) create mode 100755 .github/scripts/ccache_with_fix.sh diff --git a/.github/scripts/ccache_with_fix.sh b/.github/scripts/ccache_with_fix.sh new file mode 100755 index 000000000..7235cc4d7 --- /dev/null +++ b/.github/scripts/ccache_with_fix.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +BASEDIR=$(ls -d /__w/beluga/beluga/ros_ws/src/??????????? | head -n 1) + +echo "Using CCACHE_BASEDIR=$BASEDIR" + +exec \ + env VERBOSE=1 \ + env CCACHE_BASEDIR=$BASEDIR \ + ccache $@ diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 1e1c1e519..b468c478b 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -32,15 +32,6 @@ jobs: api_token: ${{ secrets.GITHUB_TOKEN }} update_packager_index: false remove_stale_cache: false - # Disable hashing of the current working directory to avoid cache misses - # when building in two different directories. - # This might be an issue if we use the same cache storage for - # debug and release builds. - # See https://ccache.dev/manual/latest.html#config_hash_dir. - ccache_options: | - debug=true - hash_dir=false - sloppiness=system_headers,time_macros,pch_defines,include_file_ctime,include_file_mtime - name: Build and test uses: ros-tooling/action-ros-ci@0.2.7 @@ -53,8 +44,8 @@ jobs: "build": { "mixin": ["coverage-gcc", "coverage-pytest"], "cmake-args": [ - "-DCMAKE_C_COMPILER_LAUNCHER=ccache;-o;hash_dir=false;-o;debug=true;&&;ccache;-p;&&;ccache", - "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache;-o;hash_dir=false;-o;debug=true;&&;ccache;-p;&&;ccache" + "-DCMAKE_C_COMPILER_LAUNCHER=/__w/beluga/beluga/.github/scripts/ccache_with_fix.sh", + "-DCMAKE_CXX_COMPILER_LAUNCHER=/__w/beluga/beluga/.github/scripts/ccache_with_fix.sh" ] }, "test": { @@ -72,9 +63,6 @@ jobs: - name: Lint shell: bash run: | - cat ros_ws/build/compile_commands.json - ls -la ros_ws/src - ccache --print-stats git config --global --add safe.directory $PWD source /opt/ros/${{ env.ROS_DISTRO }}/setup.sh pre-commit run --all-files --verbose --show-diff-on-failure