Skip to content

Commit 76e284f

Browse files
Rework reusable workflows to work with every repository
1 parent 2432afc commit 76e284f

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

.github/workflows/reusable-debian-build.yml

+15-7
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ jobs:
3232
runs-on: ubuntu-latest
3333
env:
3434
ROS_DISTRO: ${{ inputs.ros_distro }}
35-
path: src/control_toolbox
3635
container: ghcr.io/ros-controls/ros:${{ inputs.ros_distro }}-debian
3736
steps:
37+
- name: Get repository name
38+
# Extract the repository name from the GITHUB_REPOSITORY environment variable
39+
# ${{ github.event.repository.name }} seems to be not working with act
40+
run: echo "path=src/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
3841
- name: Checkout default ref when build is not scheduled
3942
if: ${{ github.event_name != 'schedule' }}
4043
uses: actions/checkout@v4
@@ -46,20 +49,25 @@ jobs:
4649
with:
4750
ref: ${{ inputs.ref_for_scheduled_build }}
4851
path: ${{ env.path }}
49-
- name: Build workspace
52+
- name: Import upstream workspace
5053
shell: bash
5154
run: |
52-
source /opt/ros2_ws/install/setup.bash
5355
if [[ -n "${{ inputs.upstream_workspace }}" ]]; then
5456
vcs import src < ${{ env.path }}/${{ inputs.upstream_workspace }}
5557
fi
56-
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
57-
colcon build --packages-up-to $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
58+
- name: Get list of packages
59+
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
60+
run: |
61+
echo "package_list=$(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only)" >> $GITHUB_ENV
62+
- name: Build workspace
63+
shell: bash
64+
run: |
65+
source /opt/ros2_ws/install/setup.bash
66+
colcon build --packages-up-to ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
5867
- name: Test workspace
5968
shell: bash
6069
continue-on-error: true
6170
run: |
6271
source /opt/ros2_ws/install/setup.bash
63-
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
64-
colcon test --packages-select $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
72+
colcon test --packages-select ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
6573
colcon test-result --verbose

.github/workflows/reusable-rhel-binary-build.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ jobs:
2929
rhel_binary:
3030
name: ${{ inputs.ros_distro }} RHEL binary build
3131
runs-on: ubuntu-latest
32-
env:
33-
path: src/control_toolbox
3432
container: ghcr.io/ros-controls/ros:${{ inputs.ros_distro }}-rhel
3533
steps:
34+
- name: Get repository name
35+
# Extract the repository name from the GITHUB_REPOSITORY environment variable
36+
# ${{ github.event.repository.name }} seems to be not working with act
37+
run: echo "path=src/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
3638
- name: Checkout default ref when build is not scheduled
3739
if: ${{ github.event_name != 'schedule' }}
3840
uses: actions/checkout@v4
@@ -45,6 +47,7 @@ jobs:
4547
ref: ${{ inputs.ref_for_scheduled_build }}
4648
path: ${{ env.path }}
4749
- name: Install dependencies
50+
shell: bash
4851
run: |
4952
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
5053
source /opt/ros2_ws/install/local_setup.bash
@@ -53,19 +56,22 @@ jobs:
5356
fi
5457
rosdep update
5558
rosdep install -iyr --from-path src || true
59+
- name: Get list of packages
60+
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
61+
run: |
62+
echo "package_list=$(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only)" >> $GITHUB_ENV
5663
- name: Build workspace
64+
shell: bash
5765
# source also underlay workspace with generate_parameter_library on rhel9
5866
run: |
5967
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
6068
source /opt/ros2_ws/install/local_setup.bash
61-
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
62-
colcon build --packages-up-to $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
69+
colcon build --packages-up-to ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
6370
- name: Test workspace
6471
shell: bash
6572
continue-on-error: true
6673
run: |
6774
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
6875
source /opt/ros2_ws/install/local_setup.bash
69-
# we need both paths, there is no wildcard/glob for packages defined in the root folder and subfolders at the same time
70-
colcon test --packages-select $(colcon list --paths ${{ env.path }} --names-only) $(colcon list --paths ${{ env.path }}/* --names-only) --packages-skip ${{ inputs.skip_packages }}
76+
colcon test --packages-select ${{ env.package_list }} --packages-skip ${{ inputs.skip_packages }}
7177
colcon test-result --verbose

0 commit comments

Comments
 (0)