-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (93 loc) · 4.01 KB
/
build-test.yaml
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
name: build test
on:
pull_request:
types:
- labeled
env:
CARGO_TERM_COLOR: always
jobs:
build_and_test:
if: ${{ github.event.label.name == 'run-build-test' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for .cpp or .hpp file changes
id: check_changes_cpp
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E '\.cpp$|\.hpp|$'; then
echo ".cpp or .hpp or .rs files changed"
echo "cpp_changed=true" >> $GITHUB_ENV
else
echo "No .cpp or .hpp or .rs files changed"
echo "cpp_changed=false" >> $GITHUB_ENV
fi
- name: Check for .rs file changes
id: check_changes_rust
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.rs$'; then
echo ".rs files changed"
echo "rust_changed=true" >> $GITHUB_ENV
else
echo "No .rs files changed"
echo "rust_changed=false" >> $GITHUB_ENV
fi
# TODO: Cache apt packages
- name: Cache ROS2 workspace
if: steps.check_changes_cpp.outputs.cpp_changed == 'true' || steps.check_changes_rust.outputs.rust_changed == 'true'
uses: actions/cache@v2
with:
path: /opt/ros/humble
key: ${{ runner.os }}-ros2-${{ hashFiles('**/package.xml') }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-ros2-
- name: Setup ROS 2 environment
if: steps.check_changes_cpp.outputs.cpp_changed == 'true' || steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
sudo apt update
sudo apt install -y software-properties-common curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
sudo apt install -y ros-humble-desktop python3-colcon-common-extensions ros-humble-ament-cmake
- name: Install dependencies
if: steps.check_changes_cpp.outputs.cpp_changed == 'true' || steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
source /opt/ros/humble/setup.bash
sudo apt install -y python3-rosdep
sudo rosdep init
rosdep update
rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
- name: Build src
if: steps.check_changes_cpp.outputs.cpp_changed == 'true' || steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
source /opt/ros/humble/setup.bash
colcon build
- name: run tests
if: steps.check_changes_cpp.outputs.cpp_changed == 'true' || steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
source /opt/ros/humble/setup.bash
colcon test --event-handlers console_cohesion+
colcon test-result --verbose
- name: Setup Rust environment
if: steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
rustup toolchain install nightly-2024-08-13
rustup default nightly-2024-08-13
rustup component add clippy rustfmt
- name: Run rustfmt on agnocast_heaphook_rust
if: steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
cd src/agnocast_heaphook_rust
cargo fmt && git diff --exit-code
- name: Run clippy on agnocast_heaphook_rust
if: steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
cd src/agnocast_heaphook_rust
cargo clippy -- --deny warnings
- name: Build agnocast_heaphook_rust
if: steps.check_changes_rust.outputs.rust_changed == 'true'
run: |
cd src/agnocast_heaphook_rust
cargo build