# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)

name: ROS-CI

# This determines when this workflow is run
on: [push, pull_request] # on all pushes and PRs

jobs:
  CI:
    strategy:
      matrix:
        env:
          - {ROS_DISTRO: melodic, PRERELEASE: false}
          - {ROS_DISTRO: noetic}
          - {ROS_DISTRO: foxy}
          - {ROS_DISTRO: rolling}
          - {ROS_DISTRO: humble}
    env:
      CCACHE_DIR: /github/home/.ccache # Enable ccache
      PRERELEASE: true
      BUILDER: colcon
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive
      # This step will fetch/store the directory used by ccache before/after the ci run
      - uses: actions/cache@v3
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}
      - name: Echo CCACHE_DIR
        shell: bash -l {0}
        env: ${{ matrix.env }}
        run: |
          echo CCACHE_DIR=${CCACHE_DIR}
      - name: Echo CCACHE_DIR
        shell: bash -l {0}
        run: |
          echo CCACHE_DIR=${CCACHE_DIR}
      # Run industrial_ci
      - uses: 'ros-industrial/industrial_ci@6a8f546cbd31fbd5c9f77e3409265c8b39abc3d6'
        env: ${{ matrix.env }}
