feat(description): create fourth_robot pkg #92
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-test-differential | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
build_and_test_differential: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-22.04 | |
rosdistro: | |
- humble | |
runs-on: ubuntu-latest | |
container: | |
image: ros:${{ matrix.rosdistro }}-ros-base | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Git Safe Directory | |
run: | | |
git config --global --add safe.directory /__w/wheel_stuck_ws/wheel_stuck_ws | |
- name: Check for changed files | |
id: changed-files | |
run: | | |
echo "Base: ${{ github.event.pull_request.base.sha }}" | |
echo "Head: ${{ github.sha }}" | |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) | |
CHANGED_PACKAGE_DIRS=$(echo "$CHANGED_FILES" | grep -E '^(src/[^/]+(/[^/]+)*)' | while read -r file; do | |
dir=$(dirname "$file") | |
while [ "$dir" != "." ]; do | |
if [ -f "$dir/package.xml" ]; then | |
echo "$dir" | |
break | |
fi | |
dir=$(dirname "$dir") | |
done | |
done | sort -u) | |
CHANGED_PACKAGES=$(echo "$CHANGED_PACKAGE_DIRS" | awk -F'/' '{print $NF}' | sort -u) | |
if [ -z "$CHANGED_PACKAGES" ]; then | |
echo "No changed packages found." | |
echo "::set-output name=packages::" | |
else | |
echo "Changed packages: $CHANGED_PACKAGES" | |
echo "::set-output name=packages::$CHANGED_PACKAGES" | |
fi | |
if [ $(echo "$CHANGED_FILES" | grep -c "depend_packages_ci.repos") -eq 1 ]; then | |
echo "depend_packages_ci.repos is changed" | |
echo "::set-output name=repos_file_changed::true" | |
else | |
echo "depend_packages_ci.repos is not changed" | |
echo "::set-output name=repos_file_changed::false" | |
fi | |
- name: Install dependencies | |
if: steps.changed-files.outputs.repos_file_changed == 'true' || steps.changed-files.outputs.packages != '' | |
run: | | |
rosdep update && | |
apt-get update && | |
vcs import src < depend_packages_ci.repos && | |
rosdep install --from-path . -i -y --rosdistro ${{ matrix.rosdistro }} | |
- name: Install diagnostic-updater | |
if: steps.changed-files.outputs.packages != '' | |
run: apt-get install ros-${{ matrix.rosdistro }}-diagnostic-updater | |
- name: Build tests | |
if: steps.changed-files.outputs.packages != '' | |
id: build_test | |
run: | | |
. /opt/ros/${{ matrix.rosdistro }}/setup.sh && | |
colcon build --packages-up-to ${{ steps.changed-files.outputs.packages }} | |
exit_code=$? | |
if [ "$exit_code" -eq 0 ]; then | |
echo "Build succeeded" | |
else | |
echo "Build failed" | |
exit 1 | |
fi | |
- name: Run tests | |
if: steps.changed-files.outputs.packages != '' | |
id: run_test | |
run: | | |
. /opt/ros/${{ matrix.rosdistro }}/setup.sh && | |
colcon test --packages-select ${{ steps.changed-files.outputs.packages }} && | |
colcon test-result | |
exit_code=$? | |
if [ "$exit_code" -eq 0 ]; then | |
echo "Test succeeded" | |
else | |
echo "Test failed" | |
exit 1 | |
fi |