Skip to content

CI

CI #175

Workflow file for this run

name: CI
on:
push:
branches: [ trunk ]
pull_request:
branches: [ trunk, main, '**' ]
schedule:
- cron: '17 3 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-22.04
outputs:
code: ${{ steps.filter.outputs.code }}
mapping: ${{ steps.filter.outputs.mapping }}
tests: ${{ steps.filter.outputs.tests }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
code:
- 'alpha_ws/**'
- 'alpha_configs/**'
- 'scripts/**'
- 'deploy/**'
- '.github/workflows/ci.yml'
- '!**/*.md'
mapping:
- 'alpha_ws/src/alpha_mapping/**'
- 'alpha_ws/src/**/alpha_mapping*'
tests:
- 'alpha_ws/src/**/test/**'
docs:
name: Docs Validation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install pre-commit
run: pipx install pre-commit
- name: Run pre-commit (agents index + validate)
env:
AGENTS_INDEX_NO_DATE: "1"
run: |
pre-commit run --all-files || (echo 'Expected to update docs/AGENTS_INDEX.md; please commit.' && git --no-pager diff && exit 1)
build:
name: ROS 2 Build (Humble)
runs-on: ubuntu-22.04
needs: changes
if: needs.changes.outputs.code == 'true'
env:
ALPHA_WS: alpha_ws
PKG_TARGET: ""
steps:
- uses: actions/checkout@v4
- name: Enforce test markers (unit/integration)
run: |
python3 - <<'PY'
import glob, sys
bad=[]
for f in glob.glob('alpha_ws/src/**/test/test_*.py', recursive=True):
s=open(f,'r',encoding='utf-8').read()
if '@pytest.mark.unit' not in s and '@pytest.mark.integration' not in s:
bad.append(f)
if bad:
print("Tests missing @pytest.mark.unit or @pytest.mark.integration:")
print(*("- "+b for b in bad), sep="\n")
sys.exit(1)
PY
- name: Setup ROS 2 apt sources
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: humble
- name: Configure apt
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
echo 'APT::Get::Assume-Yes "true";' | sudo tee /etc/apt/apt.conf.d/90-assume-yes
sudo apt-get update
- name: Cache rosdep metadata
uses: actions/cache@v4
with:
path: |
~/.ros/rosdep/sources.cache
~/.ros/rosdep/sources.list.d
key: rosdep-${{ runner.os }}-${{ hashFiles('**/package.xml') }}
restore-keys: |
rosdep-${{ runner.os }}-
- name: Install base build tools
run: |
sudo apt-get update
sudo apt-get install -y \
ros-humble-ros-base \
ros-humble-pluginlib \
ros-humble-rclpy \
ros-humble-rclcpp \
ros-humble-std-msgs \
ros-humble-sensor-msgs \
python3-colcon-common-extensions \
python3-colcon-ros \
ros-dev-tools \
build-essential \
cmake \
python3-setuptools \
python3-pip \
python3-wheel \
python3-rosdep \
libyaml-cpp-dev \
libcurl4-openssl-dev \
python3-pytest \
ros-humble-std-srvs \
ros-humble-diagnostic-msgs
python3 -m pip install --user --upgrade pip
python3 -m pip install --user pyyaml jsonschema pytest
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt','**/*.cmake','**/package.xml') }}
restore-keys: |
ccache-${{ runner.os }}-
- name: Configure ccache
run: |
mkdir -p ~/.ccache
echo 'max_size = 2G' > ~/.ccache/ccache.conf
- name: Resolve ROS package deps (rosdep)
shell: bash
run: |
set -euxo pipefail
# Initialize rosdep databases if needed
sudo rosdep init || true
# Retry rosdep update in case of transient network hiccups
for i in 1 2 3; do
if rosdep update; then
break
fi
echo "rosdep update failed (attempt $i). Retrying..."
sleep 5
done
# Attempt to install dependencies from package.xml files
set +e
rosdep install --rosdistro humble --from-paths "$ALPHA_WS" -i -y
rc=$?
set -e
if [ $rc -ne 0 ]; then
echo "::warning::rosdep install failed with code $rc. Falling back to apt for common ROS deps."
sudo apt-get update
sudo apt-get install -y \
ros-humble-rosidl-default-generators \
ros-humble-rosidl-default-runtime \
ros-humble-std-msgs \
ros-humble-diagnostic-msgs \
ros-humble-rclpy \
python3-yaml || true
fi
- name: Show discovered packages
shell: bash
run: |
cd "$ALPHA_WS" || exit 0
colcon list || true
- name: Build (core packages; skip alpha_mapping)
shell: bash
run: |
set -euo pipefail
# Work around ROS 2 setup scripts referencing unset vars under -u
set +u
source /opt/ros/humble/setup.bash
set -u
cd "$ALPHA_WS"
colcon build --merge-install \
--packages-skip alpha_mapping \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Validate configs (jsonschema)
shell: bash
run: |
# Run config schema validation from repo root
python3 scripts/validate_configs.py
# Skip colcon test for now; rely on targeted pytest step below
- name: Unit tests (gating)
shell: bash
run: |
set -euo pipefail
# Source ROS 2 and the built workspace so generated Python interfaces are importable
set +u
source /opt/ros/humble/setup.bash
[ -f alpha_ws/install/setup.bash ] && source alpha_ws/install/setup.bash
set -u
# Run package unit tests directly with pytest
python3 -m pytest -m unit -q
mapping-build:
name: ROS 2 Build (Humble) — mapping (non-gating)
needs: changes
if: ${{ needs.changes.outputs.mapping == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
continue-on-error: true
env:
ALPHA_WS: alpha_ws
steps:
- uses: actions/checkout@v4
- name: Setup ROS 2 apt sources
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: humble
- name: Configure apt
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
echo 'APT::Get::Assume-Yes "true";' | sudo tee /etc/apt/apt.conf.d/90-assume-yes
sudo apt-get update
- name: Cache rosdep metadata
uses: actions/cache@v4
with:
path: |
~/.ros/rosdep/sources.cache
~/.ros/rosdep/sources.list.d
key: rosdep-${{ runner.os }}-${{ hashFiles('**/package.xml') }}
restore-keys: |
rosdep-${{ runner.os }}-
- name: Install base build tools (mapping)
run: |
sudo apt-get update
sudo apt-get install -y \
ros-humble-ros-base \
ros-humble-pluginlib \
ros-humble-rclcpp \
ros-humble-sensor-msgs \
ros-humble-std-msgs \
python3-colcon-common-extensions \
python3-colcon-ros \
ros-dev-tools \
build-essential \
cmake \
python3-setuptools \
python3-pip \
python3-wheel \
python3-rosdep \
libyaml-cpp-dev \
libcurl4-openssl-dev \
python3-pytest \
ros-humble-std-srvs \
ros-humble-diagnostic-msgs
python3 -m pip install --user --upgrade pip
python3 -m pip install --user pyyaml jsonschema pytest
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt','**/*.cmake','**/package.xml') }}
restore-keys: |
ccache-${{ runner.os }}-
- name: Configure ccache
run: |
mkdir -p ~/.ccache
echo 'max_size = 2G' > ~/.ccache/ccache.conf
- name: Resolve mapping deps (rosdep)
run: |
sudo rosdep init || true
rosdep update || true
rosdep install --rosdistro humble --from-paths "$ALPHA_WS/src/alpha_mapping" -i -y || true
- name: Build alpha_mapping only (Release)
run: |
set +u
source /opt/ros/humble/setup.bash
set -u
cd "$ALPHA_WS"
colcon build --merge-install \
--packages-select alpha_mapping \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 2>&1 | tee ../mapping-build.log
- name: Upload mapping build log
if: always()
uses: actions/upload-artifact@v4
with:
name: mapping-build-log
path: mapping-build.log
integration-tests:
name: Integration tests (non-gating)
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
continue-on-error: true
env:
ALPHA_WS: alpha_ws
steps:
- uses: actions/checkout@v4
- name: Setup ROS 2 apt sources
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: humble
- name: Configure apt
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
echo 'APT::Get::Assume-Yes "true";' | sudo tee /etc/apt/apt.conf.d/90-assume-yes
sudo apt-get update
- name: Cache rosdep metadata
uses: actions/cache@v4
with:
path: |
~/.ros/rosdep/sources.cache
~/.ros/rosdep/sources.list.d
key: rosdep-${{ runner.os }}-${{ hashFiles('**/package.xml') }}
restore-keys: |
rosdep-${{ runner.os }}-
- name: Install base build tools (integration)
run: |
sudo apt-get update
sudo apt-get install -y \
ros-humble-ros-base \
ros-humble-pluginlib \
ros-humble-rclpy \
ros-humble-rclcpp \
ros-humble-std-msgs \
ros-humble-sensor-msgs \
python3-colcon-common-extensions \
python3-colcon-ros \
ros-dev-tools \
build-essential \
cmake \
python3-setuptools \
python3-pip \
python3-wheel \
python3-rosdep \
libyaml-cpp-dev \
libcurl4-openssl-dev \
python3-pytest \
ros-humble-std-srvs \
ros-humble-diagnostic-msgs
python3 -m pip install --user --upgrade pip
python3 -m pip install --user pyyaml jsonschema pytest
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt','**/*.cmake','**/package.xml') }}
restore-keys: |
ccache-${{ runner.os }}-
- name: Configure ccache
run: |
mkdir -p ~/.ccache
echo 'max_size = 2G' > ~/.ccache/ccache.conf
- name: Resolve deps (workspace)
run: |
sudo rosdep init || true
rosdep update || true
rosdep install --rosdistro humble --from-paths "$ALPHA_WS/src" -i -y || true
- name: Build (Release, merge-install)
run: |
set +u
source /opt/ros/humble/setup.bash
set -u
cd "$ALPHA_WS"
colcon build --merge-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Run integration tests (pytest -m integration)
run: |
set +u
source /opt/ros/humble/setup.bash
source alpha_ws/install/setup.bash
set -u
python3 -m pytest -m integration -q || true