Skip to content

Commit 100bf9b

Browse files
committed
try gitlab workflows after migration
1 parent 8cce758 commit 100bf9b

File tree

3 files changed

+359
-0
lines changed

3 files changed

+359
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Generate Debian Packages
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
types: [ opened, synchronize, reopened, ready_for_review ]
7+
workflow_dispatch: # Manual trigger
8+
inputs:
9+
ros_distros:
10+
description: 'ROS distributions to build (comma-separated: humble,iron,jazzy,kilted,rolling)'
11+
required: false
12+
default: 'humble,jazzy'
13+
schedule:
14+
- cron: '0 2 * * *' # Nightly at 2 AM UTC
15+
16+
env:
17+
ROS_LOCALHOST_ONLY: 1
18+
ROS_AUTOMATIC_DISCOVERY_RANGE: LOCALHOST
19+
20+
jobs:
21+
# Only run if tests pass
22+
check-tests:
23+
if: github.event_name == 'pull_request'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Wait for tests
27+
uses: lewagon/[email protected]
28+
with:
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
check-name: 'Test ROS2 humble'
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
wait-interval: 30
33+
34+
determine-distros:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
distros: ${{ steps.set-distros.outputs.distros }}
38+
steps:
39+
- name: Determine ROS distributions to build
40+
id: set-distros
41+
run: |
42+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
43+
# Manual trigger - use input or default
44+
DISTROS="${{ github.event.inputs.ros_distros || 'humble,jazzy' }}"
45+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
46+
# PR - build key distributions
47+
DISTROS="humble,jazzy"
48+
else
49+
# Scheduled - build all distributions
50+
DISTROS="humble,iron,jazzy,kilted,rolling"
51+
fi
52+
echo "Building for distributions: $DISTROS"
53+
# Convert to JSON array for matrix
54+
JSON_ARRAY=$(echo $DISTROS | jq -R 'split(",") | map(select(length > 0))')
55+
echo "distros=$JSON_ARRAY" >> $GITHUB_OUTPUT
56+
57+
generate-debian:
58+
name: Generate Debian packages for ROS2 ${{ matrix.ros_distro }}
59+
runs-on: ubuntu-latest
60+
needs: [determine-distros]
61+
if: always() && (needs.check-tests.result == 'success' || needs.check-tests.result == 'skipped')
62+
container: ros:${{ matrix.ros_distro }}-ros-base-${{ matrix.ubuntu_distro }}
63+
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
ros_distro: ${{ fromJson(needs.determine-distros.outputs.distros) }}
68+
include:
69+
- ros_distro: humble
70+
ubuntu_distro: jammy
71+
- ros_distro: iron
72+
ubuntu_distro: jammy
73+
- ros_distro: jazzy
74+
ubuntu_distro: noble
75+
- ros_distro: kilted
76+
ubuntu_distro: noble
77+
- ros_distro: rolling
78+
ubuntu_distro: noble
79+
80+
steps:
81+
- name: Checkout code
82+
uses: actions/checkout@v4
83+
with:
84+
submodules: recursive
85+
86+
- name: Setup build environment
87+
run: |
88+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
89+
apt-get update -qq && apt-get install -y build-essential python3-pip python3-bloom python3-rosdep git lsb-release devscripts debhelper fakeroot
90+
91+
- name: Install Python dependencies
92+
run: |
93+
if [[ "${{ matrix.ros_distro }}" == "jazzy" || \
94+
"${{ matrix.ros_distro }}" == "kilted" || \
95+
"${{ matrix.ros_distro }}" == "rolling" ]]; then
96+
pip3 install --break-system-packages -I pygments -r requirements.txt
97+
python3 -m pip install -U --break-system-packages bloom
98+
else
99+
pip3 install -r requirements.txt
100+
python3 -m pip install -U bloom
101+
fi
102+
103+
- name: Build workspace
104+
run: |
105+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
106+
colcon build --packages-up-to r2s_gw
107+
source install/setup.bash
108+
109+
- name: Setup rosdep mappings
110+
run: |
111+
echo "Adding local rosdep mappings..."
112+
mkdir -p /root/.ros/rosdep
113+
cat >/root/.ros/rosdep/local.yaml <<EOF
114+
greenwave_monitor_interfaces:
115+
ubuntu:
116+
jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces]
117+
noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces]
118+
greenwave_monitor:
119+
ubuntu:
120+
jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor]
121+
noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor]
122+
EOF
123+
mkdir -p /etc/ros/rosdep/sources.list.d
124+
echo "yaml file:///root/.ros/rosdep/local.yaml" > /etc/ros/rosdep/sources.list.d/99-local.list
125+
rosdep init || true
126+
rosdep update --include-eol-distros
127+
128+
- name: Generate Debian packages
129+
run: |
130+
set -eo pipefail
131+
mkdir -p debian_packages/${{ matrix.ros_distro }}
132+
133+
# Generate debian packages for greenwave_monitor_interfaces
134+
echo "Generating debian for greenwave_monitor_interfaces..."
135+
cd greenwave_monitor_interfaces
136+
bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
137+
cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb ../debian_packages/${{ matrix.ros_distro }}/
138+
cd ..
139+
140+
# Install interfaces package
141+
echo "Installing greenwave_monitor_interfaces..."
142+
apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb
143+
144+
# Generate debian packages for greenwave_monitor
145+
echo "Generating debian for greenwave_monitor..."
146+
cd greenwave_monitor
147+
bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
148+
cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor_*.deb ../debian_packages/${{ matrix.ros_distro }}/
149+
cd ..
150+
apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor*.deb
151+
152+
# Generate debian packages for r2s_gw
153+
echo "Generating debian for r2s_gw..."
154+
cd r2s_gw
155+
bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
156+
cp ../ros-${{ matrix.ros_distro }}-r2s-gw_*.deb ../debian_packages/${{ matrix.ros_distro }}/
157+
cd ..
158+
159+
echo "Generated debian packages:"
160+
ls -la debian_packages/${{ matrix.ros_distro }}/
161+
162+
- name: Upload Debian packages
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: debian-packages-${{ matrix.ros_distro }}
166+
path: debian_packages/${{ matrix.ros_distro }}/
167+
retention-days: 30

.github/workflows/ros-tests.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: ROS2 Tests
2+
3+
on:
4+
push:
5+
branches: [ "**" ] # Run on all branches
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
ROS_LOCALHOST_ONLY: 1
11+
ROS_AUTOMATIC_DISCOVERY_RANGE: LOCALHOST
12+
13+
jobs:
14+
test:
15+
name: Test ROS2 ${{ matrix.ros_distro }}
16+
runs-on: ubuntu-latest
17+
container: ros:${{ matrix.ros_distro }}-ros-base-${{ matrix.ubuntu_distro }}
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- ros_distro: humble
24+
ubuntu_distro: jammy
25+
- ros_distro: iron
26+
ubuntu_distro: jammy
27+
- ros_distro: jazzy
28+
ubuntu_distro: noble
29+
- ros_distro: kilted
30+
ubuntu_distro: noble
31+
- ros_distro: rolling
32+
ubuntu_distro: noble
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
with:
38+
submodules: recursive
39+
40+
- name: Setup ROS environment
41+
run: |
42+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
43+
apt-get update -qq && apt-get install -y build-essential python3-pip
44+
45+
- name: Install Python dependencies
46+
run: |
47+
if [[ "${{ matrix.ros_distro }}" == "jazzy" || \
48+
"${{ matrix.ros_distro }}" == "kilted" || \
49+
"${{ matrix.ros_distro }}" == "rolling" ]]; then
50+
pip3 install --break-system-packages -I pygments -r requirements.txt
51+
else
52+
pip3 install -r requirements.txt
53+
fi
54+
55+
- name: Build packages
56+
run: |
57+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
58+
echo "Building and testing on ROS2 ${{ matrix.ros_distro }}"
59+
colcon build --packages-up-to r2s_gw
60+
61+
- name: Run tests
62+
run: |
63+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
64+
colcon test --event-handlers console_direct+ --return-code-on-test-failure --packages-up-to r2s_gw
65+
66+
- name: Upload test results
67+
uses: actions/upload-artifact@v4
68+
if: always()
69+
with:
70+
name: test-results-${{ matrix.ros_distro }}
71+
path: |
72+
build/
73+
install/
74+
log/
75+
retention-days: 7
76+
77+
- name: Publish test results
78+
uses: EnricoMi/publish-unit-test-result-action@v2
79+
if: always()
80+
with:
81+
files: log/test_results/*/junit.xml
82+
check_name: "Test Results (${{ matrix.ros_distro }})"

.github/workflows/smoke-tests.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Smoke Tests
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Generate Debian Packages"]
6+
types: [completed]
7+
branches: [main]
8+
workflow_dispatch: # Manual trigger
9+
inputs:
10+
ros_distros:
11+
description: 'ROS distributions to test (comma-separated: humble,iron,jazzy,kilted,rolling)'
12+
required: false
13+
default: 'humble,jazzy'
14+
15+
env:
16+
ROS_LOCALHOST_ONLY: 1
17+
ROS_AUTOMATIC_DISCOVERY_RANGE: LOCALHOST
18+
19+
jobs:
20+
determine-distros:
21+
runs-on: ubuntu-latest
22+
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch'
23+
outputs:
24+
distros: ${{ steps.set-distros.outputs.distros }}
25+
steps:
26+
- name: Determine ROS distributions to test
27+
id: set-distros
28+
run: |
29+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
30+
DISTROS="${{ github.event.inputs.ros_distros || 'humble,jazzy' }}"
31+
else
32+
# Use same distributions as the completed workflow
33+
DISTROS="humble,iron,jazzy,kilted,rolling"
34+
fi
35+
echo "Testing distributions: $DISTROS"
36+
JSON_ARRAY=$(echo $DISTROS | jq -R 'split(",") | map(select(length > 0))')
37+
echo "distros=$JSON_ARRAY" >> $GITHUB_OUTPUT
38+
39+
smoke-test:
40+
name: Smoke test ROS2 ${{ matrix.ros_distro }}
41+
runs-on: ubuntu-latest
42+
needs: [determine-distros]
43+
container: ros:${{ matrix.ros_distro }}-ros-base-${{ matrix.ubuntu_distro }}
44+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
ros_distro: ${{ fromJson(needs.determine-distros.outputs.distros) }}
49+
include:
50+
- ros_distro: humble
51+
ubuntu_distro: jammy
52+
- ros_distro: iron
53+
ubuntu_distro: jammy
54+
- ros_distro: jazzy
55+
ubuntu_distro: noble
56+
- ros_distro: kilted
57+
ubuntu_distro: noble
58+
- ros_distro: rolling
59+
ubuntu_distro: noble
60+
61+
steps:
62+
- name: Setup environment
63+
run: |
64+
apt-get update -qq
65+
66+
- name: Download Debian packages
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: debian-packages-${{ matrix.ros_distro }}
70+
path: debian_packages/${{ matrix.ros_distro }}/
71+
72+
- name: Install and test packages
73+
run: |
74+
set -eo pipefail
75+
echo "Smoke testing install on ROS2 ${{ matrix.ros_distro }}"
76+
ls -la debian_packages/${{ matrix.ros_distro }}/
77+
78+
# Install the debian packages
79+
apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor_*.deb ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-r2s-gw_*.deb
80+
81+
# Verify packages are installed
82+
dpkg -s ros-${{ matrix.ros_distro }}-r2s-gw ros-${{ matrix.ros_distro }}-greenwave-monitor ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces
83+
84+
# Install Python dependencies
85+
apt-get install -y python3-pip || true
86+
if [[ "${{ matrix.ros_distro }}" == "jazzy" || \
87+
"${{ matrix.ros_distro }}" == "kilted" || \
88+
"${{ matrix.ros_distro }}" == "rolling" ]]; then
89+
# Download requirements.txt from the repo since we don't have checkout
90+
curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/r2s_gw/requirements.txt > /tmp/requirements.txt
91+
python3 -m pip install -I pygments -r /tmp/requirements.txt --break-system-packages
92+
else
93+
curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/r2s_gw/requirements.txt > /tmp/requirements.txt
94+
python3 -m pip install -r /tmp/requirements.txt
95+
fi
96+
97+
- name: Test r2s_gw execution
98+
run: |
99+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
100+
timeout 10s bash -lc "script -qfec 'ros2 run r2s_gw r2s_gw' /dev/null <<< \$'q'" || true
101+
102+
- name: Test greenwave_monitor execution
103+
run: |
104+
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
105+
ros2 run greenwave_monitor greenwave_monitor & echo $! > /tmp/gwm.pid
106+
sleep 3
107+
ros2 node list | tee /tmp/nodes.txt
108+
grep -q greenwave_monitor /tmp/nodes.txt
109+
kill -TERM "$(cat /tmp/gwm.pid)" || true
110+
wait "$(cat /tmp/gwm.pid)" || true

0 commit comments

Comments
 (0)