-
Notifications
You must be signed in to change notification settings - Fork 208
142 lines (125 loc) · 5.31 KB
/
Copy pathgenerate-bindings.yml
File metadata and controls
142 lines (125 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Generate bindings
on:
schedule:
# Run the CI at 00:11 UTC every night
# We pick an arbitrary time outside of most of the world's work hours
# to minimize the likelihood of running alongside a heavy workload.
- cron: '11 0 * * *'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
ros_distribution:
- humble
- jazzy
- kilted
- lyrical
- rolling
include:
# Humble Hawksbill (May 2022 - May 2027)
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
ros_distribution: humble
ros_version: 2
# Jazzy Jalisco (May 2024 - May 2029)
- docker_image: rostooling/setup-ros-docker:ubuntu-noble-ros-jazzy-ros-base-latest
ros_distribution: jazzy
ros_version: 2
# Kilted Kaiju (May 2025 - Dec 2026)
- docker_image: rostooling/setup-ros-docker:ubuntu-noble-ros-kilted-ros-base-latest
ros_distribution: kilted
ros_version: 2
# Lyrical Luth (May 2026 - May 2031)
- docker_image: rostooling/setup-ros-docker:ubuntu-resolute-ros-lyrical-ros-base-latest
ros_distribution: lyrical
ros_version: 2
# Rolling Ridley (June 2020 - Present)
- docker_image: rostooling/setup-ros-docker:ubuntu-noble-ros-rolling-ros-base-latest
ros_distribution: rolling
ros_version: 2
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' || (
github.event_name == 'schedule' && github.repository == 'ros2-rust/ros2_rust'
)
permissions:
contents: write
pull-requests: write
container:
image: ${{ matrix.docker_image }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup ROS environment
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
use-ros2-testing: ${{ matrix.ros_distribution == 'rolling' }}
- name: Update environment and force upgrade new packages
run: |
apt-get update
apt-get dist-upgrade -y
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.85
with:
components: clippy, rustfmt
- name: Install cargo binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install bindgen
run: cargo binstall -y bindgen-cli
- name: Install GitHub CLI tool
run: |
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Generate bindings
run: |
. /opt/ros/${{ matrix.ros_distribution }}/setup.sh
cd rclrs/src
../generate_bindings.py rcl_wrapper.h ${{ matrix.ros_distribution }} .
- name: Submit PR
run: |
cd $GITHUB_WORKSPACE
git config --global --add safe.directory $GITHUB_WORKSPACE
if git diff --exit-code; then
echo "No changes detected, skipping PR creation"
exit 0
fi
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch origin
echo "Github env set and origin is fetched! Now checking if PR exists.."
BRANCH_NAME="update-bindings-${{ matrix.ros_distribution }}"
if gh pr list --head "$BRANCH_NAME" --state open --json number --jq length | grep -q '^0$'; then
echo "No existing PR found, will create new one"
CREATE_PR=1
else
echo "PR already exists, will update it"
CREATE_PR=0
fi
git add rclrs/src/rcl_bindings_generated_${{ matrix.ros_distribution }}.rs
git commit -m "build(bindings): regenerate bindings for ${{ matrix.ros_distribution }}"
git push -f origin HEAD:refs/heads/$BRANCH_NAME
if [ $CREATE_PR -eq 1 ]; then
gh pr create \
--base main \
--head "$BRANCH_NAME" \
--title "build(bindings): regenerate bindings for ${{ matrix.ros_distribution }}" \
--body "This PR regenerates the bindings for ${{ matrix.ros_distribution }}."
echo "Created new PR!"
else
echo "PR already exists and has been updated with new commit"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}