Skip to content

Commit 9f18020

Browse files
committed
ci: pre-install ros-apt-source before setup-ros
ros-tooling/setup-ros@v0.7 (0.7.19) resolves the ros-apt-source version with an unauthenticated api.github.com 'releases/latest' call. That call hits the per-IP unauthenticated GitHub API rate limit shared across GitHub-hosted runners; when it is exhausted the version is empty, the action builds a .../download//ros2-apt-source_..._all.deb URL, gets a 404, and ROS never installs (jobs die with 'colcon: command not found', exit 127) - intermittently, independent of the change under test. Add a local composite action that installs the ros-apt-source package first (authenticated version lookup with a pinned fallback, no per-IP limit). With the ROS 2 apt repo already configured, setup-ros's isRosAptSourcePackageInstalled check passes and it skips the fragile fetch. Applied before every setup-ros step in ci.yml, quality.yml, and opcua-plugin.yml.
1 parent 226332c commit 9f18020

4 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Pre-install ROS 2 apt source
2+
description: >
3+
Installs the ros-apt-source package up front so ros-tooling/setup-ros skips its
4+
own unauthenticated api.github.com "releases/latest" lookup. That lookup is
5+
subject to the per-IP unauthenticated GitHub API rate limit, which is shared
6+
across all GitHub-hosted runners; when it is exhausted the call returns no
7+
version, setup-ros builds a .../download//ros2-apt-source_..._all.deb URL, gets
8+
a 404, and the whole job fails ("colcon: command not found", exit 127). By
9+
configuring the ROS 2 apt repo first, setup-ros's isRosAptSourcePackageInstalled
10+
check passes and it never performs the fragile fetch.
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Install ros-apt-source (skip setup-ros's rate-limited fetch)
16+
shell: bash
17+
env:
18+
# Authenticated API requests use the per-repo limit (~1000/h), not the
19+
# per-IP unauthenticated limit that setup-ros trips over.
20+
GH_TOKEN: ${{ github.token }}
21+
run: |
22+
set -euo pipefail
23+
24+
SUDO=""
25+
if [ "$(id -u)" -ne 0 ]; then SUDO="sudo"; fi
26+
27+
# Minimal container images may lack curl / CA certificates.
28+
if ! command -v curl >/dev/null 2>&1; then
29+
$SUDO apt-get update
30+
$SUDO apt-get install -y --no-install-recommends curl ca-certificates
31+
fi
32+
33+
codename="$(. /etc/os-release && echo "${UBUNTU_CODENAME:-${VERSION_CODENAME}}")"
34+
35+
# Resolve the latest ros-apt-source release via an AUTHENTICATED call, then
36+
# fall back to a known-good pin so the step is deterministic even if the
37+
# API is briefly unreachable.
38+
version=""
39+
if [ -n "${GH_TOKEN:-}" ]; then
40+
version="$(curl -fsSL -H "Authorization: Bearer ${GH_TOKEN}" \
41+
"https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest" \
42+
| grep -F '"tag_name"' | head -n1 | awk -F'"' '{print $4}' || true)"
43+
fi
44+
if [ -z "${version}" ]; then
45+
version="1.2.0"
46+
fi
47+
48+
deb="ros2-apt-source_${version}.${codename}_all.deb"
49+
url="https://github.com/ros-infrastructure/ros-apt-source/releases/download/${version}/${deb}"
50+
51+
echo "Installing ${deb} (ros-apt-source ${version}, ${codename})"
52+
curl --fail --location --retry 5 --retry-delay 3 -o "/tmp/${deb}" "${url}"
53+
$SUDO dpkg -i "/tmp/${deb}"
54+
rm -f "/tmp/${deb}"
55+
$SUDO apt-get update

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- name: Checkout repository
3434
uses: actions/checkout@v4
3535

36+
- name: Pre-install ROS 2 apt source
37+
uses: ./.github/actions/ros-apt-source
38+
3639
- name: Set up ROS 2 ${{ matrix.ros_distro }}
3740
uses: ros-tooling/setup-ros@v0.7
3841
with:
@@ -130,6 +133,9 @@ jobs:
130133
- name: Checkout repository
131134
uses: actions/checkout@v4
132135

136+
- name: Pre-install ROS 2 apt source
137+
uses: ./.github/actions/ros-apt-source
138+
133139
- name: Set up ROS 2 Jazzy
134140
uses: ros-tooling/setup-ros@v0.7
135141
with:
@@ -196,6 +202,9 @@ jobs:
196202
- name: Checkout repository
197203
uses: actions/checkout@v4
198204

205+
- name: Pre-install ROS 2 apt source
206+
uses: ./.github/actions/ros-apt-source
207+
199208
- name: Set up ROS 2 Jazzy
200209
uses: ros-tooling/setup-ros@v0.7
201210
with:
@@ -263,6 +272,9 @@ jobs:
263272
- name: Checkout repository
264273
uses: actions/checkout@v4
265274

275+
- name: Pre-install ROS 2 apt source
276+
uses: ./.github/actions/ros-apt-source
277+
266278
- name: Set up ROS 2 Jazzy
267279
uses: ros-tooling/setup-ros@v0.7
268280
with:

.github/workflows/opcua-plugin.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
- name: Checkout repository
6262
uses: actions/checkout@v4
6363

64+
- name: Pre-install ROS 2 apt source
65+
uses: ./.github/actions/ros-apt-source
66+
6467
- name: Set up ROS 2 ${{ matrix.ros_distro }}
6568
uses: ros-tooling/setup-ros@v0.7
6669
with:

.github/workflows/quality.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Checkout repository
3333
uses: actions/checkout@v4
3434

35+
- name: Pre-install ROS 2 apt source
36+
uses: ./.github/actions/ros-apt-source
37+
3538
- name: Set up ROS 2 Jazzy
3639
uses: ros-tooling/setup-ros@v0.7
3740
with:
@@ -102,6 +105,9 @@ jobs:
102105
- name: Fix git safe directory
103106
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
104107

108+
- name: Pre-install ROS 2 apt source
109+
uses: ./.github/actions/ros-apt-source
110+
105111
- name: Set up ROS 2 Jazzy
106112
uses: ros-tooling/setup-ros@v0.7
107113
with:
@@ -241,6 +247,9 @@ jobs:
241247
- name: Checkout repository
242248
uses: actions/checkout@v4
243249

250+
- name: Pre-install ROS 2 apt source
251+
uses: ./.github/actions/ros-apt-source
252+
244253
- name: Set up ROS 2 Jazzy
245254
uses: ros-tooling/setup-ros@v0.7
246255
with:
@@ -349,6 +358,9 @@ jobs:
349358
- name: Checkout repository
350359
uses: actions/checkout@v4
351360

361+
- name: Pre-install ROS 2 apt source
362+
uses: ./.github/actions/ros-apt-source
363+
352364
- name: Set up ROS 2 Jazzy
353365
uses: ros-tooling/setup-ros@v0.7
354366
with:

0 commit comments

Comments
 (0)