Skip to content

Commit 56514ea

Browse files
Use pixi for windows workflow (#374)
1 parent 87a6cf1 commit 56514ea

File tree

2 files changed

+157
-93
lines changed

2 files changed

+157
-93
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Get package list"
2+
# pixi has to be installed and available in the PATH
3+
description: "Get a list of packages in the given path"
4+
inputs:
5+
path:
6+
description: "Path to the repository after checkout action, e.g. src/repo-name"
7+
required: false
8+
default: ""
9+
manifest-path:
10+
description: "Path to the pixi.toml file or workspace directory"
11+
required: true
12+
outputs:
13+
package_list:
14+
description: "A white-space separated list of packages"
15+
value: ${{ steps.colcon.outputs.package_list }}
16+
package_path_list:
17+
description: "A white-space separated list of package paths"
18+
value: ${{ steps.colcon.outputs.package_path_list }}
19+
repo_name:
20+
description: "The name of the repo, last part of github.repository"
21+
value: ${{ steps.split_repo.outputs.repo_name }}
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- id: colcon
27+
# if a path is given, list the packages in the given path and its subdirectories from the path
28+
# if no path is given, list all packages in the workspace
29+
run: |
30+
call pixi shell-hook -s cmd --manifest-path ${{ inputs.manifest-path }} > pixi_env.bat
31+
call pixi_env.bat
32+
setlocal enabledelayedexpansion
33+
set "package_list="
34+
set "package_path_list="
35+
if not "${{ inputs.path }}"=="" (
36+
for /f "delims=" %%a in ('colcon list --paths "${{ inputs.path }}" --names-only') do (
37+
set "package_list=!package_list! %%a"
38+
)
39+
for /f "delims=" %%a in ('colcon list --paths "${{ inputs.path }}\*" --names-only') do (
40+
set "package_list=!package_list! %%a"
41+
)
42+
for /f "delims=" %%a in ('colcon list --paths "${{ inputs.path }}" --paths-only') do (
43+
set "package_path_list=!package_path_list! %%a"
44+
)
45+
for /f "delims=" %%a in ('colcon list --paths "${{ inputs.path }}\*" --paths-only') do (
46+
set "package_path_list=!package_path_list! %%a"
47+
)
48+
) else (
49+
for /f "delims=" %%a in ('colcon list --names-only') do (
50+
set "package_list=!package_list! %%a"
51+
)
52+
for /f "delims=" %%a in ('colcon list --paths-only') do (
53+
set "package_path_list=!package_path_list! %%a"
54+
)
55+
)
56+
echo package_list=!package_list!>> %GITHUB_OUTPUT%
57+
echo package_path_list=!package_path_list!>> %GITHUB_OUTPUT%
58+
endlocal
59+
shell: cmd
60+
- id: split_repo
61+
run: |
62+
echo "repo_name=$(echo ${{ github.repository }} | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
63+
shell: bash
64+
- run: |
65+
echo "repo ${{ steps.split_repo.outputs.repo_name }} contains the packages: ${{ steps.colcon.outputs.package_list }}"
66+
shell: bash

.github/workflows/reusable-ros-tooling-win-build.yml

Lines changed: 91 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,55 @@ on:
55
workflow_call:
66
inputs:
77
ros_distro:
8-
description: 'ROS 2 distribution name. One of
9-
https://github.com/ros-tooling/setup-ros/blob/master/src/setup-ros-windows.ts'
8+
description: "ROS 2 distribution name, e.g. rolling"
109
required: true
1110
type: string
1211
ref_for_scheduled_build:
13-
description: 'Reference on which the repo should be checkout for scheduled build. Usually is this name of a branch or a tag.'
14-
default: ''
12+
description: "Reference on which the repo should be checkout for scheduled build. Usually is this name of a branch or a tag."
13+
default: ""
1514
required: false
1615
type: string
1716
os_name:
18-
description: 'On which OS to run the build job'
17+
description: "On which OS to run the build job"
1918
required: false
20-
default: 'windows-2019'
19+
default: "windows-2022"
2120
type: string
2221
container:
23-
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
22+
description: "Docker container to run the job in, e.g. ubuntu:noble"
2423
required: false
25-
default: ''
24+
default: ""
25+
type: string
26+
pixi_dependencies:
27+
description: "Whitespace separated list of additional pixi dependencies"
28+
required: false
29+
default: ""
2630
type: string
2731
windows_dependencies:
28-
description: 'Path to a repos file with additional windows dependencies'
32+
description: "Path to a repos file with additional windows dependencies"
33+
required: false
34+
default: ""
35+
type: string
36+
skip_packages:
37+
description: "Packages to skip from build"
38+
default: ""
2939
required: false
30-
default: ''
3140
type: string
32-
install_boost:
33-
description: 'Install boost for the build'
41+
ninja_packages:
42+
description: "Packages to be built with Ninja generator (default is MSVC otherwise)"
43+
default: ""
3444
required: false
35-
default: false
36-
type: boolean
45+
type: string
3746

3847
jobs:
3948
reusable_ros_tooling_source_build:
4049
name: ${{ inputs.ros_distro }} ${{ inputs.os_name }}
4150
runs-on: ${{ inputs.os_name }}
4251
container: ${{ inputs.container }}
4352
env:
53+
pixi_path: C:\dev
4454
# this will be src/{repo-owner}/{repo-name}
4555
repo_path: src/${{ github.repository }}
4656
steps:
47-
- uses: actions/setup-python@v5
48-
# setup-ros has hardcoded python 3.8, as it is the default version acc. to REP-2000 for jazzy
49-
# let's use the same version here for the later action-ros-ci step
50-
with:
51-
python-version: '3.8'
52-
53-
- uses: ros-tooling/[email protected]
54-
with:
55-
required-ros-distributions: ${{ inputs.ros_distro }}
56-
use-ros2-testing: true
57-
58-
- name: Install boost
59-
uses: MarkusJx/[email protected]
60-
if: ${{ inputs.install_boost }}
61-
id: install-boost
62-
with:
63-
# REQUIRED: Specify the required boost version
64-
# A list of supported versions can be found here:
65-
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
66-
boost_version: 1.86.0
67-
# OPTIONAL: Specify a platform version
68-
platform_version: 2019
69-
# OPTIONAL: Specify a toolset
70-
toolset: msvc
71-
# Whether the boost libraries will be supplied through static or shared libraries
72-
link: shared
73-
7457
- name: Checkout default ref when build is not scheduled
7558
if: ${{ github.event_name != 'schedule' }}
7659
uses: actions/checkout@v4
@@ -83,65 +66,80 @@ jobs:
8366
ref: ${{ inputs.ref_for_scheduled_build }}
8467
path: ${{ env.repo_path }}
8568

86-
- id: package_list_action
87-
uses: ros-controls/ros2_control_ci/.github/actions/set-package-list@master
69+
- name: Bootstrap pixi
70+
# https://docs.ros.org/en/rolling/Installation/Windows-Install-Binary.html
71+
run: |
72+
mkdir -p ${{ env.pixi_path }}
73+
Set-Location -Path ${{ env.pixi_path }}
74+
irm https://raw.githubusercontent.com/ros2/ros2/refs/heads/rolling/pixi.toml -OutFile pixi.toml
75+
76+
- name: Install pixi
77+
uses: prefix-dev/[email protected]
8878
with:
89-
path: ${{ env.repo_path }}
79+
manifest-path: ${{ env.pixi_path }}\pixi.toml
9080

91-
- name: Check for local repos file
92-
id: check_local_repos
81+
- name: Install additional pixi dependencies
82+
working-directory: ${{ env.pixi_path }}
9383
run: |
94-
if (Test-Path ${{ env.repo_path }}\${{ steps.package_list_action.outputs.repo_name }}.${{ inputs.ros_distro }}.repos) {
95-
Write-Output "Local repos file found"
96-
"repo_file=${{ env.repo_path }}\${{ steps.package_list_action.outputs.repo_name }}.${{ inputs.ros_distro }}.repos" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
97-
} else {
98-
Write-Output "No local repos file found"
99-
"repo_file=" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
100-
}
84+
pixi add ${{ inputs.pixi_dependencies }}
10185
102-
- name: Set windows dependencies variable
103-
id: set_windows_dependencies
86+
- name: Install ROS
87+
working-directory: ${{ env.pixi_path }}
88+
# Download and extract ROS 2 package
89+
# https://docs.ros.org/en/rolling/Installation/Windows-Install-Binary.html
10490
run: |
105-
if (![string]::IsNullOrWhiteSpace("${{ inputs.windows_dependencies }}") -and (Test-Path "${{ env.repo_path }}\${{ inputs.windows_dependencies }}")) {
106-
Write-Output "Windows repos file found"
107-
"repo_file=${{ env.repo_path }}\${{ inputs.windows_dependencies }}" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
108-
} else {
109-
Write-Output "No windows dependencies provided or file not found"
110-
"repo_file=" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append
111-
}
91+
$url = "https://ci.ros2.org/view/packaging/job/packaging_windows/lastSuccessfulBuild/artifact/ws/ros2-package-windows-AMD64.zip"
92+
$output = "ros2-package-windows-AMD64.zip"
93+
Invoke-WebRequest -Uri $url -OutFile $output
94+
Expand-Archive -Path $output -DestinationPath ros2_${{ inputs.ros_distro }}
11295
113-
- uses: ros-tooling/[email protected]
114-
# tests are disabled https://github.com/ros-tooling/action-ros-ci/pull/712#issuecomment-969495087
115-
env:
116-
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
96+
- name: Get package list
97+
id: package_list_action
98+
uses: ros-controls/ros2_control_ci/.github/actions/set-package-list-pixi@master
11799
with:
118-
target-ros2-distro: ${{ inputs.ros_distro }}
119-
package-name: ${{ steps.package_list_action.outputs.package_list }}
120-
vcs-repo-file-url: |
121-
${{ steps.check_local_repos.outputs.repo_file }}
122-
${{ steps.set_windows_dependencies.outputs.repo_file }}
100+
path: ${{ env.repo_path }}
101+
manifest-path: ${{ env.pixi_path }}
123102

124-
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
125-
colcon-defaults: |
126-
{
127-
"test": {
128-
"executor": "sequential"
129-
}
103+
- name: Install dependencies
104+
# check for repos files, and pass them to vcstool
105+
run: |
106+
Invoke-Expression ((& pixi shell-hook -s powershell --manifest-path ${{ env.pixi_path }}) -join "`n")
107+
$repo_file = "${{ env.repo_path }}\${{ steps.package_list_action.outputs.repo_name }}.${{ inputs.ros_distro }}.repos"
108+
if (Test-Path "$repo_file") {
109+
Write-Output "Local repos file found"
110+
vcs import --input $repo_file src
111+
}
112+
if (![string]::IsNullOrWhiteSpace("${{ inputs.windows_dependencies }}")) {
113+
$repo_file_win = "${{ env.repo_path }}\${{ inputs.windows_dependencies }}"
114+
if (Test-Path "$repo_file_win") {
115+
Write-Output "Windows repos file found"
116+
vcs import --input $repo_file_win src
130117
}
131-
id: action-ros
118+
}
132119
133-
- name: Download issue template for target failure # Has to be a local file
134-
if: ${{ always() && steps.action-ros.outcome == 'failure' && github.event_name == 'schedule' }}
135-
run:
136-
wget https://raw.githubusercontent.com/ros-controls/ros2_control_ci/master/.github/issue_template_failed_ci.md -O ${{ env.repo_path }}/.github/issue_template_failed_ci.md
137-
- uses: JasonEtco/create-an-issue@v2
138-
# action-ros-ci does not report more details on test failures afaik
139-
if: ${{ always() && steps.action-ros.outcome == 'failure' && github.event_name == 'schedule'}}
140-
env:
141-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142-
ACTION_NAME: ${{ inputs.ros_distro }}/source
143-
REF: ${{ inputs.ref_for_scheduled_build }}
144-
URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
145-
with:
146-
update_existing: true
147-
filename: ${{ env.repo_path }}/.github/issue_template_failed_ci.md
120+
- name: Build workspace
121+
# use Ninja generator optionally for selected packages.
122+
# This is needed for RSL, but doesn't work for msg packages
123+
# https://github.com/search?q=repo%3APickNikRobotics%2FRSL%20ninja&type=code
124+
# https://github.com/colcon/colcon-ros/issues/84#issuecomment-1862881299
125+
shell: cmd
126+
run: |
127+
call pixi shell-hook -s cmd --manifest-path ${{ env.pixi_path }} > pixi_env.bat
128+
call pixi_env.bat >nul 2>&1
129+
130+
call ${{ env.pixi_path }}\ros2_${{ inputs.ros_distro }}\ros2-windows\setup.bat
131+
132+
set up_to_arg=
133+
if not "${{ steps.package_list_action.outputs.package_list }}"=="" (
134+
set up_to_arg=--packages-up-to ${{ steps.package_list_action.outputs.package_list }}
135+
)
136+
set skip_arg=
137+
if not "${{ inputs.skip_packages }}"=="" (
138+
set skip_arg=--packages-skip ${{ inputs.skip_packages }}
139+
)
140+
set skip_ninja_arg=
141+
if not "${{ inputs.ninja_packages }}"=="" (
142+
colcon build --packages-up-to ${{ inputs.ninja_packages }} --cmake-args -G Ninja --event-handler console_cohesion+
143+
set skip_ninja_arg=--packages-skip ${{ inputs.ninja_packages }}
144+
)
145+
colcon build %up_to_arg% %skip_arg% %skip_ninja_arg% --event-handler console_cohesion+

0 commit comments

Comments
 (0)