Skip to content

Commit

Permalink
Rework reusable workflows to work with every repository
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Feb 9, 2024
1 parent 2432afc commit 76e284f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/reusable-debian-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ jobs:
runs-on: ubuntu-latest
env:
ROS_DISTRO: ${{ inputs.ros_distro }}
path: src/control_toolbox
container: ghcr.io/ros-controls/ros:${{ inputs.ros_distro }}-debian
steps:
- name: Get repository name
# Extract the repository name from the GITHUB_REPOSITORY environment variable
# ${{ github.event.repository.name }} seems to be not working with act
run: echo "path=src/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Checkout default ref when build is not scheduled
if: ${{ github.event_name != 'schedule' }}
uses: actions/checkout@v4
Expand All @@ -46,20 +49,25 @@ jobs:
with:
ref: ${{ inputs.ref_for_scheduled_build }}
path: ${{ env.path }}
- name: Build workspace
- name: Import upstream workspace
shell: bash
run: |
source /opt/ros2_ws/install/setup.bash
if [[ -n "${{ inputs.upstream_workspace }}" ]]; then
vcs import src < ${{ env.path }}/${{ inputs.upstream_workspace }}
fi
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
colcon build --packages-up-to $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
- name: Get list of packages
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
run: |
echo "package_list=$(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only)" >> $GITHUB_ENV
- name: Build workspace
shell: bash
run: |
source /opt/ros2_ws/install/setup.bash
colcon build --packages-up-to ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
- name: Test workspace
shell: bash
continue-on-error: true
run: |
source /opt/ros2_ws/install/setup.bash
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
colcon test --packages-select $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
colcon test --packages-select ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
colcon test-result --verbose
18 changes: 12 additions & 6 deletions .github/workflows/reusable-rhel-binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ jobs:
rhel_binary:
name: ${{ inputs.ros_distro }} RHEL binary build
runs-on: ubuntu-latest
env:
path: src/control_toolbox
container: ghcr.io/ros-controls/ros:${{ inputs.ros_distro }}-rhel
steps:
- name: Get repository name
# Extract the repository name from the GITHUB_REPOSITORY environment variable
# ${{ github.event.repository.name }} seems to be not working with act
run: echo "path=src/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Checkout default ref when build is not scheduled
if: ${{ github.event_name != 'schedule' }}
uses: actions/checkout@v4
Expand All @@ -45,6 +47,7 @@ jobs:
ref: ${{ inputs.ref_for_scheduled_build }}
path: ${{ env.path }}
- name: Install dependencies
shell: bash
run: |
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
source /opt/ros2_ws/install/local_setup.bash
Expand All @@ -53,19 +56,22 @@ jobs:
fi
rosdep update
rosdep install -iyr --from-path src || true
- name: Get list of packages
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
run: |
echo "package_list=$(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only)" >> $GITHUB_ENV
- name: Build workspace
shell: bash
# source also underlay workspace with generate_parameter_library on rhel9
run: |
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
source /opt/ros2_ws/install/local_setup.bash
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
colcon build --packages-up-to $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
colcon build --packages-up-to ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
- name: Test workspace
shell: bash
continue-on-error: true
run: |
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
source /opt/ros2_ws/install/local_setup.bash
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
colcon test --packages-select $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
colcon test --packages-select ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
colcon test-result --verbose

0 comments on commit 76e284f

Please sign in to comment.