name: colcon workspace

on: [push, pull_request]

jobs:
  # build on Ubuntu docker images
  build_linux:
    name: "${{ matrix.docker_image }} (${{ matrix.ros_distribution }})"

    runs-on: ubuntu-latest

    strategy:
      matrix:
        include:
          - docker_image: ubuntu:20.04
            ros_distribution: noetic
            ros_version: 1

          - docker_image: ubuntu:22.04
            ros_distribution: humble
            ros_version: 2

          - docker_image: ubuntu:24.04
            ros_distribution: jazzy
            ros_version: 2

          - docker_image: almalinux:8
            ros_distribution: humble
            ros_version: 2

          - docker_image: almalinux:9
            ros_distribution: jazzy
            ros_version: 2

    container:
      image: ${{ matrix.docker_image }}

    steps:
      - uses: actions/checkout@v5

      - name: Setup ROS environment
        uses: ros-tooling/setup-ros@v0.7

      - name: ROS 1 CI Action
        if: ${{ matrix.ros_version == 1 }}
        uses: ros-tooling/action-ros-ci@v0.4
        with:
          package-name: apriltag
          target-ros1-distro: ${{ matrix.ros_distribution }}

      - name: ROS 2 CI Action
        if: ${{ matrix.ros_version == 2 }}
        uses: ros-tooling/action-ros-ci@v0.4
        with:
          package-name: apriltag
          target-ros2-distro: ${{ matrix.ros_distribution }}


  # build on macOS native
  build_macos:
    name: "macOS (${{ matrix.ros_distribution }})"

    runs-on: macos-latest

    strategy:
      matrix:
        ros_distribution: [humble, jazzy]

    steps:
      - uses: actions/checkout@v5

      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"

      - name: Setup ROS environment
        uses: ros-tooling/setup-ros@v0.7

      - name: ROS 2 CI Action
        uses: ros-tooling/action-ros-ci@v0.4
        with:
          package-name: apriltag
          target-ros2-distro: ${{ matrix.ros_distribution }}
