Skip to content

diagnostic_remote_logging: escape InfluxDB line-protocol special characters in diagnostic text #1661

diagnostic_remote_logging: escape InfluxDB line-protocol special characters in diagnostic text

diagnostic_remote_logging: escape InfluxDB line-protocol special characters in diagnostic text #1661

Workflow file for this run

name: Test diagnostics
on:
pull_request:
push:
branches:
- ros2
schedule:
# Run every week at 20:00 on Sunday
- cron: "0 20 * * 0"
jobs:
ros_distro_from_branch_name:
name: What is the distro?
runs-on: ubuntu-latest
outputs:
distro: ${{ steps.set-distro.outputs.distro }}
steps:
- name: Set ROS distro from branch name
id: set-distro
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "This is a PR. Getting branch name from base ref."
branch_name="${{ github.event.pull_request.base.ref }}"
else
echo "This is a push. Getting branch name from head ref."
branch_name="${GITHUB_REF}"
fi
echo "> Branch name is: ${branch_name}"
if [[ "${branch_name}" == *"ros2-humble"* ]]; then
distro="humble"
elif [[ "${branch_name}" == *"ros2-jazzy"* ]]; then
distro="jazzy"
elif [[ "${branch_name}" == *"ros2-kilted"* ]]; then
distro="kilted"
elif [[ "${branch_name}" == *"ros2-lyrical"* ]]; then
distro="lyrical"
elif [[ "${branch_name}" == *"ros2"* ]]; then
distro="rolling"
else
echo "! Unknown branch for determining ROS distro: ${GITHUB_REF##*/}"
exit 1
fi
echo "> Determined ROS distro to be: ${distro}!"
echo "distro=$distro" >> $GITHUB_OUTPUT
build_and_test:
name: Build ${{ matrix.distro }} on ubuntu
needs: ros_distro_from_branch_name
strategy:
fail-fast: false
matrix:
include:
- distro: ${{ needs.ros_distro_from_branch_name.outputs.distro }}
os: ${{ needs.ros_distro_from_branch_name.outputs.distro == 'humble' && '22.04' || (needs.ros_distro_from_branch_name.outputs.distro == 'kilted' || needs.ros_distro_from_branch_name.outputs.distro == 'jazzy') && '24.04' || '26.04' }}
runs-on: ubuntu-latest
container: ubuntu:${{ matrix.os }}
steps:
- uses: ros-tooling/setup-ros@0.7.19
if: ${{ matrix.distro != 'rolling' }}
with:
required-ros-distributions: ${{ matrix.distro }}
- uses: ros-tooling/setup-ros@0.7.19
if: ${{ matrix.distro == 'rolling' }}
- name: Install ccache
run: sudo apt-get update && sudo apt-get install --no-install-recommends --yes ccache
- uses: actions/cache@v6
with:
path: .ccache
key: ccache-${{ runner.os }}-${{ matrix.distro }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
ccache-${{ runner.os }}-${{ matrix.distro }}-
- uses: ros-tooling/action-ros-ci@0.4.8
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 2G
with:
target-ros2-distro: ${{ matrix.distro }}
vcs-repo-file-url: ${{ matrix.distro == 'rolling' && 'https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos' || '' }}
colcon-defaults: |
{
"build": {
"cmake-args": [
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
]
}
}
package-name: |
diagnostic_aggregator
diagnostic_common_diagnostics
diagnostic_remote_logging
diagnostic_updater
self_test
build_win:
name: Build ${{ matrix.distro }} on windows
needs: ros_distro_from_branch_name
runs-on: windows-2022
# container: ${{ inputs.container }}
env:
ros_underlay_path: C:\dev
upstream_workspace: C:\upstream_ws
# this will be src/{repo-owner}/{repo-name}
repo_path: src/${{ github.repository }}
# Path to a repos file with additional windows dependencies
windows_dependencies: ""
# Space-separated list of packages to skip from
skip_dependencies: "sdformat_urdf"
# Space-separated list of packages to skip from build
skip_packages: ""
# Space-separated list of packages to be built with Ninja generator (default is MSVC otherwise)
ninja_packages: ""
# Additional arguments to pass to CMake for upstream workspace, e.g. -DBUILD_TESTING=OFF
upstream_cmake_args: "-DBUILD_TESTING=OFF"
# Additional arguments to pass to CMake for target workspace, e.g. -DBUILD_TESTING=OFF
target_cmake_args: ""
strategy:
fail-fast: false
matrix:
include:
- distro: ${{ needs.ros_distro_from_branch_name.outputs.distro }}
steps:
- name: Restore pixi.lock
uses: actions/cache/restore@v6
id: cache
with:
path: pixi.lock
key: pixi|${{ matrix.distro }}
- name: Checkout source
uses: actions/checkout@v7
with:
path: ${{ env.repo_path }}
- name: Install pixi
uses: prefix-dev/setup-pixi@v0.11.3
with:
cache: false
locked: false
run-install: false
- name: Generate Pixi manifest from package.xml
run: |
Push-Location ${{ env.repo_path }}
pixi exec --spec pixi-ros==0.7.0 pixi-ros init --distro ${{ matrix.distro }} --platform linux-64 --platform win-64
Pop-Location
$generatedManifest = Join-Path "${{ env.repo_path }}" "pixi.toml"
[string[]]$content = Get-Content $generatedManifest
$activationIndex = $content.IndexOf("[activation]")
if ($activationIndex -ge 0) {
$content = $content[0..($activationIndex - 1)]
$content | Set-Content $generatedManifest
}
pixi add --manifest-path $generatedManifest --no-install rosinstall_generator
pixi add --manifest-path $generatedManifest --no-install --pypi vcstool
pixi add --manifest-path $generatedManifest --no-install "setuptools<82"
Copy-Item $generatedManifest "pixi.toml"
Copy-Item (Join-Path "${{ env.repo_path }}" "pixi.lock") "pixi.lock"
- name: Install Pixi dependencies
run: pixi install
- name: Cache pixi.lock
uses: actions/cache/save@v6
# independent of the success of the following steps, but only on default branch
# cache independent of the cache hit of the restore step, because pixi.toml could have changed
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
with:
path: pixi.lock
key: pixi|${{ matrix.distro }}
- name: Upload pixi lock file
uses: actions/upload-artifact@v7
with:
name: pixi.lock
path: pixi.lock
- name: Install ROS
# Download and extract ROS 2 package
# https://docs.ros.org/en/rolling/Installation/Windows-Install-Binary.html
shell: cmd
run: |
call pixi shell-hook -s cmd > pixi_env.bat
call pixi_env.bat
if errorlevel 1 exit /b 1
if not exist "${{ env.ros_underlay_path }}" mkdir "${{ env.ros_underlay_path }}"
cd /d "${{ env.ros_underlay_path }}"
powershell -NoProfile -Command "$ErrorActionPreference = 'Stop'; Invoke-WebRequest -Uri 'https://github.com/ros2/ros2/releases/download/release-rolling-nightlies/ros2-rolling-nightly-windows-amd64.zip' -OutFile 'ros2-package-windows-AMD64.zip'; Expand-Archive -Path 'ros2-package-windows-AMD64.zip' -DestinationPath 'ros2_${{ matrix.distro }}'; Remove-Item 'ros2-package-windows-AMD64.zip'"
if errorlevel 1 exit /b 1
cd /d "ros2_${{ matrix.distro }}\ros2-windows"
python preinstall_setup_windows.py
if errorlevel 1 exit /b 1
- name: Get package list
id: package_list_action
uses: ros-controls/ros2_control_ci/.github/actions/set-package-list-pixi@master
with:
path: ${{ env.repo_path }}
manifest-path: pixi.toml
- name: Clone dependencies
shell: cmd
run: |
setlocal EnableDelayedExpansion
call pixi shell-hook -s cmd > pixi_env.bat
call pixi_env.bat
if errorlevel 1 exit /b 1
call ${{ env.ros_underlay_path }}\ros2_${{ matrix.distro }}\ros2-windows\setup.bat
if errorlevel 1 exit /b 1
rem Workaround .. --from-path: 'src/ros/diagnostics' is not an existing directory
if not exist "${{ env.upstream_workspace }}\${{ env.repo_path }}" mkdir "${{ env.upstream_workspace }}\${{ env.repo_path }}"
rem Check for repos files and pass them to vcstool
set "repo_file=${{ env.repo_path }}\${{ steps.package_list_action.outputs.repo_name }}.${{ matrix.distro }}.repos"
if exist "!repo_file!" (
echo Local repos file found
vcs import --input "!repo_file!" "${{ env.upstream_workspace }}\src"
if errorlevel 1 exit /b 1
)
if not "${{ env.windows_dependencies }}"=="" if exist "${{ env.repo_path }}\${{ env.windows_dependencies }}" (
echo Windows repos file found
vcs import --input "${{ env.repo_path }}\${{ env.windows_dependencies }}" "${{ env.upstream_workspace }}\src"
if errorlevel 1 exit /b 1
)
rem Use rosinstall_generator to get dependencies not already installed
set "underlay_ws_pkgs="
for /f "delims=" %%p in ('ros2 pkg list') do set "underlay_ws_pkgs=!underlay_ws_pkgs! %%p"
echo underlay_ws_pkgs = !underlay_ws_pkgs!
rosinstall_generator --rosdistro ${{ matrix.distro }} --deps --deps-only --format repos --exclude !underlay_ws_pkgs! ${{ env.skip_dependencies }} --from-path ${{ env.upstream_workspace }} ${{ env.repo_path }} > deps.repos
if errorlevel 1 exit /b 1
rem rosinstall_generator skips excludes from a different repository
vcs import --skip-existing --input deps.repos "${{ env.upstream_workspace }}\src"
if errorlevel 1 exit /b 1
- name: Upload repos file
uses: actions/upload-artifact@v7
with:
name: windows.repos
path: deps.repos
- name: Build upstream workspace
# use Ninja generator optionally for selected packages.
# This is needed for RSL, but doesn't work for msg packages
# https://github.com/search?q=repo%3APickNikRobotics%2FRSL%20ninja&type=code
# https://github.com/colcon/colcon-ros/issues/84#issuecomment-1862881299
shell: cmd
run: |
call pixi shell-hook -s cmd > pixi_env.bat
call pixi_env.bat >nul 2>&1
call ${{ env.ros_underlay_path }}\ros2_${{ matrix.distro }}\ros2-windows\setup.bat
pushd ${{ env.upstream_workspace }}
@echo on
set skip_arg=
if not "${{ env.skip_packages }}"=="" (
set skip_arg=${{ env.skip_packages }}
)
if not "${{ env.ninja_packages }}"=="" (
colcon build --packages-up-to ${{ env.ninja_packages }} --cmake-args -G Ninja --event-handler console_cohesion+ --merge-install
set skip_arg=%skip_arg% ${{ env.ninja_packages }}
)
colcon build --packages-skip %skip_arg% --event-handler console_cohesion+ --cmake-args ${{ env.upstream_cmake_args }} --merge-install
- name: Build target workspace
shell: cmd
run: |
call pixi shell-hook -s cmd > pixi_env.bat
call pixi_env.bat >nul 2>&1
call ${{ env.ros_underlay_path }}\ros2_${{ matrix.distro }}\ros2-windows\setup.bat
call ${{ env.upstream_workspace }}\install\setup.bat
@echo on
set skip_arg=
if not "${{ env.skip_packages }}"=="" (
set skip_arg=--packages-skip ${{ env.skip_packages }}
)
colcon build %skip_arg% --event-handler console_cohesion+ --cmake-args ${{ env.target_cmake_args }} --merge-install