Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull #5346

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
129 changes: 128 additions & 1 deletion .webauto-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,128 @@ version: 2

artifacts:
- name: main
metadata:
play-ondemand.ci.web.auto/buildspec: Autoware-Humble_v0.29.0
build:
type: tier4/universe/main/amd64/v1
type: custom
runtime:
type: standard1/amd64/large
source:
vcstool:
repositories_files:
- autoware.repos
- simulator.repos
- tools.repos
import_path: src
environment_variables:
AUTOWARE_PATH: /home/autoware/pilot-auto
ML_MODELS_PATH: /opt/autoware/mlmodels
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
developer_options:
- name: webauto:ci:caret_enabled
environment_variables:
WEBAUTO_CI_BUILD_OPTION_CARET_ENABLED: ENABLED
linux_parameters:
kernel_version: 5.15.0-72-generic
phases:
- name: environment-setup
user: root
exec: ./.webauto-ci/main/environment-setup/run.sh
caches:
- name: apt-lists
mountpoint: /var/lib/apt/lists
- name: apt-archives
mountpoint: /var/cache/apt/archives
build_result_reuse:
key_files:
- .webauto-ci/main/environment-setup/**/*
- name: autoware-setup
user: autoware
exec: ./.webauto-ci/main/autoware-setup/run.sh
caches:
- name: apt-lists
mountpoint: /var/lib/apt/lists
- name: apt-archives
mountpoint: /var/cache/apt/archives
build_result_reuse:
key_files:
- .webauto-ci/main/autoware-setup/**/*
- ansible/**/*
- ansible-galaxy-requirements.yaml
- amd64.env
incremental_build:
enabled: true
- name: autoware-build
user: autoware
exec: ./.webauto-ci/main/autoware-build/run.sh
environment_variables:
PARALLEL_WORKERS: "32"
CCACHE_DIR: /tmp/build/cache/ccache
caches:
- name: apt-lists
mountpoint: /var/lib/apt/lists
- name: apt-archives
mountpoint: /var/cache/apt/archives
- name: ccache
mountpoint: /tmp/build/cache/ccache
build_result_reuse:
key_files:
- .webauto-ci/main/autoware-build/**/*
- src/**/*
- "!src/ecu_system_setup/**"
incremental_build:
enabled: true
- name: ecu-system-setup
user: autoware
exec: ./.webauto-ci/main/ecu-system-setup/run.sh
environment_variables:
ECU_SYSTEM_SETUP_SOURCE_PATH: ansible
ECU_SYSTEM_SETUP_ANSIBLE_PLAYBOOK: ansible/playbooks/ecu_setup.yaml
caches:
- name: apt-lists
mountpoint: /var/lib/apt/lists
- name: apt-archives
mountpoint: /var/cache/apt/archives
build_result_reuse:
key_files:
- .webauto-ci/main/ecu-system-setup/**/*
- src/ecu_system_setup/**/*
- ansible/**/*
- ansible-galaxy-requirements.yaml
base_container_image:
from: ubuntu:22.04
# from: ghcr.io/tier4/pilot-auto/base-image:latest # use base image
output_container_image:
from: autoware-build
workdir: /home/autoware/pilot-auto
user: autoware
output_rootfs_image:
from: ecu-system-setup
persistent_file_path: /home/autoware/pilot-auto/.webauto-ci/main/ecu-system-setup/persistents.txt
output_installer_image:
from: ecu-system-setup
type: iso
base_iso: ubuntu-20.04.3-live-server-amd64

simulations:
- name: perception
type: perception
simulator:
deployment:
type: container
artifact: main
runtime:
type: gpu1/amd64/large
pre_tasks:
- exec: source /home/autoware/autoware.proj/install/setup.bash && ros2 launch lidar_centerpointlidar_centerpoint.launch.xml model_name:=centerpoint_tiny model_path:=/home/autoware/autoware_data/lidar_centerpoint model_param_path:=$(ros2 pkg prefixlidar_centerpoint --share)/config/centerpoint_tiny.param.yaml build_only:=true
mounts:
- volume: model
volumes:
- name: model
path: /home/autoware/autoware_data/lidar_centerpoint
preserve_original_files: true

- name: lexus_planning_sim
type: planning_sim_v2
simulator:
Expand All @@ -25,6 +143,15 @@ simulations:
sensor_model: sample_sensor_kit
initialize_duration: "90"

- name: localization
type: localization
simulator:
deployment:
type: container
artifact: main
runtime:
type: standard1/amd64/large

release:
components:
- name: planning
Expand Down
16 changes: 16 additions & 0 deletions .webauto-ci/main/asset-deploy/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -e

: "${WEBAUTO_CI_ML_PACKAGES_PATH:=}"

: "${ML_MODELS_PATH:=}"

if [ -n "$WEBAUTO_CI_ML_PACKAGES_PATH" ] && [ -n "$ML_MODELS_PATH" ]; then
sudo mkdir -p "$(dirname "$ML_MODELS_PATH")"
sudo chown "$(whoami):" "$(dirname "$ML_MODELS_PATH")"
cp -r "$WEBAUTO_CI_ML_PACKAGES_PATH" "$ML_MODELS_PATH"
find "$ML_MODELS_PATH" -type d -exec chmod 777 {} \;
find "$ML_MODELS_PATH" -type f -exec chmod 644 {} \;

echo "The following ML models have been deployed:"
ls "$ML_MODELS_PATH"
fi
134 changes: 134 additions & 0 deletions .webauto-ci/main/autoware-build/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash -e

: "${WEBAUTO_CI_SOURCE_PATH:?is not set}"
: "${WEBAUTO_CI_DEBUG_BUILD:?is not set}"

: "${AUTOWARE_PATH:?is not set}"
: "${CCACHE_DIR:=}"
: "${CCACHE_SIZE:=1G}"
: "${PARALLEL_WORKERS:=4}"

# get installed ros distro
# shellcheck disable=SC2012
ROS_DISTRO=$(ls -1 /opt/ros | head -1)

# CARET build
if [ "$WEBAUTO_CI_BUILD_OPTION_CARET_ENABLED" = "ENABLED" ]; then
echo "CARET ENABLED"

cd "$HOME"
rm -rf ros2_caret_ws

# download CARET
echo "===== GET CARET ====="
CARET_VERSION="rc/v0.5.2_for_evaluator"
export GITHUB_TOKEN="$WEBAUTO_CI_GITHUB_TOKEN"
git clone https://github.com/tier4/caret.git ros2_caret_ws
cd ros2_caret_ws
git checkout "$CARET_VERSION"

# setup CARET
echo "===== Setup CARET ====="
mkdir src
vcs import src <caret.repos
# shellcheck disable=SC1090
source "/opt/ros/${ROS_DISTRO}/setup.bash"
./setup_caret.sh -c

# build caret
echo "===== Build CARET ====="
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF

fi

# For incremental builds, the source files used in previous builds are already in place.
# Delete any files that have been removed from the new source, except for files specified in .gitignore.
# Also, to take advantage of incremental builds, preserve the timestamps of files with the same checksum.
src=$(mktemp -p /tmp -d src.XXXXX)
cp -rfT "$WEBAUTO_CI_SOURCE_PATH" "$src"
# shellcheck disable=SC2016
find "$src" -name '.gitignore' -printf '%P\0' | xargs -0 -I {} sh -c "sed -n "'s/^!//gp'" $src/{} > $src/"'$(dirname {})'"/.rsync-include"
# shellcheck disable=SC2016
find "$src" -name '.gitignore' -printf '%P\0' | xargs -0 -I {} sh -c "sed -n "'/^[^!]/p'" $src/{} > $src/"'$(dirname {})'"/.rsync-exclude"
rsync -rlpc -f":+ .rsync-include" -f":- .rsync-exclude" --del "$src"/ "$AUTOWARE_PATH"
# The `src` directory is excluded from the root .gitignore and must be synchronized separately.
rsync -rlpc -f":+ .rsync-include" -f":- .rsync-exclude" --del "$src"/src/ "$AUTOWARE_PATH"/src
# `.rsync-include` and `.rsync-exclude` must be included in the output of this phase for reference in the next incremental build.
# These files are removed in the ecu-system-setup phase.
#find "$AUTOWARE_PATH" \( -name ".rsync-include" -or -name ".rsync-exclude" \) -print0 | xargs -0 rm
rm -rf "$src"

chmod 755 "$AUTOWARE_PATH"
cd "$AUTOWARE_PATH"

if [ -n "$CCACHE_DIR" ]; then
mkdir -p "$CCACHE_DIR"
export USE_CCACHE=1
export CCACHE_DIR="$CCACHE_DIR"
export CC="/usr/lib/ccache/gcc"
export CXX="/usr/lib/ccache/g++"
ccache -M "$CCACHE_SIZE"
fi

sudo -E apt-get -y update

# shellcheck disable=SC1090
source "/opt/ros/${ROS_DISTRO}/setup.bash"
rosdep update
rosdep install -y --from-paths src --ignore-src --rosdistro "$ROS_DISTRO"

# CARET setup
ADDITIONAL_OPTIONS=""
if [ "$WEBAUTO_CI_BUILD_OPTION_CARET_ENABLED" = "ENABLED" ]; then
echo "===== Modify ament_cmake_auto as workaround ====="
backup_date="$(date +"%Y%m%d_%H%M%S")"
cd /opt/ros/humble/share/ament_cmake_auto/cmake &&
sudo cp ament_auto_add_executable.cmake ament_auto_add_executable.cmake_"$backup_date" &&
sudo cp ament_auto_add_library.cmake ament_auto_add_library.cmake_"$backup_date" &&
sudo sed -i -e 's/SYSTEM//g' ament_auto_add_executable.cmake &&
sudo sed -i -e 's/SYSTEM//g' ament_auto_add_library.cmake

# cspell: ignore libtracetools
echo "===== Modify pcl_ros (libtracetools.so) as workaround ====="
cd /opt/ros/humble/share/pcl_ros/cmake &&
sudo cp export_pcl_rosExport.cmake export_pcl_rosExport.cmake_"$backup_date" &&
sudo sed -i -e 's/\/opt\/ros\/humble\/lib\/libtracetools.so;//g' export_pcl_rosExport.cmake

echo "===== Modify pcl_ros (rclcpp) as workaround ====="
cd /opt/ros/humble/share/pcl_ros/cmake &&
sudo cp export_pcl_rosExport.cmake export_pcl_rosExport.cmake_"$backup_date"_2 &&
sudo sed -i -e 's/\/opt\/ros\/humble\/include\/rclcpp;//g' export_pcl_rosExport.cmake

cd "$AUTOWARE_PATH"
rm -f caret_topic_filter.bash
wget https://raw.githubusercontent.com/tier4/caret_report/main/sample_autoware/caret_topic_filter.bash

# shellcheck disable=SC1090
source "/opt/ros/${ROS_DISTRO}/setup.bash"
# shellcheck disable=SC1091
source "$HOME/ros2_caret_ws/install/local_setup.sh"
echo "===== Finish CARET SETUP ====="

ADDITIONAL_OPTIONS="--packages-skip rclcpp rclcpp_action rclcpp_components rclcpp_lifecycle"
fi
cd "$AUTOWARE_PATH"

[[ $WEBAUTO_CI_DEBUG_BUILD == "true" ]] && build_type="RelWithDebInfo" || build_type="Release"

# shellcheck disable=SC2086
colcon build \
--symlink-install \
--cmake-args -DCMAKE_BUILD_TYPE="$build_type" -DCMAKE_CXX_FLAGS="-w" -DBUILD_TESTING=off \
--catkin-skip-building-tests \
--executor parallel \
--parallel-workers "$PARALLEL_WORKERS" \
$ADDITIONAL_OPTIONS

if [ "$WEBAUTO_CI_BUILD_OPTION_CARET_ENABLED" = "ENABLED" ]; then
echo "===== Check CARET SETUP ====="
# shellcheck disable=SC1090,SC1091,SC2015
source "/opt/ros/${ROS_DISTRO}/setup.sh" &&
source "$HOME/ros2_caret_ws/install/local_setup.sh" &&
ros2 caret check_caret_rclcpp ./ ||
(echo "CARET build is failed" && exit 1)
fi
32 changes: 32 additions & 0 deletions .webauto-ci/main/autoware-setup/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -e

: "${WEBAUTO_CI_GITHUB_TOKEN:?is not set}"

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 $(source /etc/os-release && echo "$UBUNTU_CODENAME") main" | sudo tee /etc/apt/sources.list.d/ros2.list >/dev/null
sudo -E apt-get -y update
sudo -E apt-get -y install usbutils # For kvaser

export GITHUB_TOKEN="$WEBAUTO_CI_GITHUB_TOKEN"
git config --global --add url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "https://github.com/"
git config --global --add url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "[email protected]:"

ansible_args=()
ansible_args+=("--extra-vars" "prompt_install_nvidia=y")
ansible_args+=("--extra-vars" "prompt_download_artifacts=y")
ansible_args+=("--extra-vars" "data_dir=$HOME/autoware_data")

# read amd64 env file and expand ansible arguments
source 'amd64.env'
while read -r env_name; do
ansible_args+=("--extra-vars" "${env_name}=${!env_name}")
done < <(sed "s/=.*//" <amd64.env)

ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
ansible-playbook "ansible/playbooks/local_dev_env.yaml" \
"${ansible_args[@]}" \
-e WORKSPACE_ROOT="$(pwd)" \
-e install_devel="y" \
--skip-tags vcs

git config --global --unset-all url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf
17 changes: 17 additions & 0 deletions .webauto-ci/main/ecu-system-setup/persistents.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'/etc/hosts'
'/etc/hostname'
'/etc/resolv.conf'
'/etc/netplan'
'/etc/udev/rules.d/70-persistent-disk.rules'
'/etc/dhcpd.conf'
'/etc/nftables.conf'
'/etc/tpm2_pkcs11/tpm2_pkcs11.sqlite3'
'/etc/usbguard/rules.conf'
'/etc/nftables.conf'
'/home/autoware/vehicle.env'
'/greengrass/config/config.json'
'/greengrass/certs'
'/opt/autoware/maps'
'/opt/autoware/area_map'
'/opt/devtools'
'/opt/dssad/'
40 changes: 40 additions & 0 deletions .webauto-ci/main/ecu-system-setup/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -e

: "${WEBAUTO_CI_SOURCE_PATH:?is not set}"
: "${WEBAUTO_CI_GITHUB_TOKEN:?is not set}"

: "${AUTOWARE_PATH:?is not set}"
: "${ECU_SYSTEM_SETUP_SOURCE_PATH:?is not set}"
: "${ECU_SYSTEM_SETUP_ANSIBLE_PLAYBOOK:?is not set}"

cd "$AUTOWARE_PATH"
# Delete files for incremental builds created in the autoware-build phase.
find "$AUTOWARE_PATH" \( -name ".rsync-include" -or -name ".rsync-exclude" \) -print0 | xargs -0 rm

rm -rf "$ECU_SYSTEM_SETUP_SOURCE_PATH"
cp -r "${WEBAUTO_CI_SOURCE_PATH}/${ECU_SYSTEM_SETUP_SOURCE_PATH}" "$ECU_SYSTEM_SETUP_SOURCE_PATH"

sudo -E apt-get -y update
sudo -E apt-get -y install "linux-image-$(uname -r)" "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)"
sudo -E apt-get -y install systemd udev kmod
sudo -E apt-get -y install ubuntu-minimal openssh-server fonts-ubuntu systemd-coredump vim grub-efi-amd64
sudo -E apt-get -y install ubuntu-desktop-minimal --no-install-recommends

# Disable auto suspend
sudo sed -i 's/\(.*sleep-inactive-ac-timeout=.*\)/sleep-inactive-ac-timeout=0/g' /etc/gdm3/greeter.dconf-defaults
sudo sed -i 's/\(.*sleep-inactive-battery-timeout=.*\)/sleep-inactive-battery-timeout=0/g' /etc/gdm3/greeter.dconf-defaults

export GITHUB_TOKEN="$WEBAUTO_CI_GITHUB_TOKEN"
git config --global --add url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "https://github.com/"
git config --global --add url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "[email protected]:"

readonly dummy_vehicle_id=default # Reconfigure during OTA update
ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
ansible-playbook "${ECU_SYSTEM_SETUP_ANSIBLE_PLAYBOOK}" \
-e autoware_install_dir="$(pwd)" \
-e vehicle_id="${dummy_vehicle_id}" \
-e reload_systemd=no

git config --global --unset-all url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf

sudo sed -i '/^autoware\sALL=(ALL)\sNOPASSWD:ALL/d' /etc/sudoers
Loading
Loading