From fc3f2405218d6117ba2fc360670eca23c67f8f34 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 24 Nov 2020 14:24:58 -0800 Subject: [PATCH] Try to checkout same branch in dependencies This implements some behavior from our Jenkins CI that attemps to checkout a branch of the same name in all dependency packages. This requires setting `fetch-depth: 0` in the actions/checkout steps and installing git 2.18+ before those checkout steps. For 18.04, the git-core ppa is used; this will not be needed on 20.04. --- .github/try_vcs_checkout | 16 ++++++++++++++++ .github/workflows/build.yml | 24 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 .github/try_vcs_checkout diff --git a/.github/try_vcs_checkout b/.github/try_vcs_checkout new file mode 100755 index 00000000..18290b26 --- /dev/null +++ b/.github/try_vcs_checkout @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright 2020 Toyota Research Institute + +CHANGE_BRANCH=$1 +SRC_FOLDER=$2 + +echo try checking out ${CHANGE_BRANCH} +vcs custom $SRC_FOLDER --args branch -f $CHANGE_BRANCH origin/$CHANGE_BRANCH > /dev/null || true +vcs custom $SRC_FOLDER --args merge --no-edit $CHANGE_BRANCH > /dev/null || true +DIFF=$(vcs diff -s $SRC_FOLDER | tr -d '.\n') +if [ ! -z "$DIFF" ]; then + echo "Have merge conflicts!" + echo $DIFF + exit 1 +fi +vcs status $SRC_FOLDER diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 258806b3..98fb05b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,17 @@ jobs: container: image: ubuntu:18.04 steps: + # setup-ros first since it installs git, which is needed to fetch all branches from actions/checkout + - uses: ros-tooling/setup-ros@0.0.26 + # install git from ppa since git 2.18+ is needed to fetch all branches from actions/checkout + # this step can be removed on 20.04 + - name: install git from ppa + shell: bash + run: | + apt update; + apt install -y software-properties-common; + add-apt-repository -y -u ppa:git-core/ppa; + apt install -y git; - uses: actions/checkout@v2 with: path: ${{ env.ROS_WS }}/src/${{ env.PACKAGE_NAME }} @@ -22,40 +33,49 @@ jobs: - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/maliput + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/maliput token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/maliput-dragway + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/maliput_dragway token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/maliput-multilane + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/maliput_multilane token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/malidrive + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/malidrive token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/delphyne + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/delphyne token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/drake-vendor + fetch-depth: 0 path: ${{ env.ROS_WS }}/src/drake_vendor token: ${{ secrets.MALIPUT_TOKEN }} - uses: actions/checkout@v2 with: repository: ToyotaResearchInstitute/dsim-repos-index + fetch-depth: 0 path: dsim-repos-index token: ${{ secrets.MALIPUT_TOKEN }} - # use setup-ros action to get vcs, rosdep, and colcon - - uses: ros-tooling/setup-ros@0.0.25 + - name: check if dependencies have a matching branch + shell: bash + working-directory: ${{ env.ROS_WS }}/src + run: ./${PACKAGE_NAME}/.github/try_vcs_checkout ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} . # install drake_vendor prereqs using dsim-repos-index/tools/prereqs.lib - name: install drake_vendor prereqs shell: bash