Skip to content

Commit

Permalink
fix(webauto-ci): custom build spec (#5087)
Browse files Browse the repository at this point in the history
Signed-off-by: rxnew <[email protected]>
  • Loading branch information
rxnew authored Sep 9, 2024
1 parent b17202b commit 247b298
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 4 deletions.
74 changes: 70 additions & 4 deletions .webauto-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,77 @@
# The configuration file for Web.Auto CI/CD tool.
# https://docs.web.auto/user-manuals/evaluator/configuration/reference/introduction

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
import_path: src
environment_variables:
AUTOWARE_PATH: /opt/autoware
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
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/**/*
base_container_image:
from: ubuntu:22.04
output_container_image:
from: autoware-build
workdir: /opt/autoware
user: autoware

simulations:
- name: lexus_planning_sim
Expand All @@ -13,9 +81,7 @@ simulations:
type: container
artifact: main
runtime:
type: simulator/standard1/amd64/medium
cpu: 8
memory: 16384
type: standard1/amd64/medium
parameters:
launch_autoware: "true"
autoware_launch_package: autoware_launch
Expand Down
44 changes: 44 additions & 0 deletions .webauto-ci/main/autoware-build/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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}"

sudo mkdir "$AUTOWARE_PATH"
sudo chown "$(whoami)": "$AUTOWARE_PATH"
cd "$WEBAUTO_CI_SOURCE_PATH"
cp -r src .webauto-ci.* "$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=SC2012
ROS_DISTRO=$(ls -1 /opt/ros | head -1)
# shellcheck disable=SC1090
source "/opt/ros/$ROS_DISTRO/setup.bash"
rosdep update
rosdep install -y --from-paths src --ignore-src --rosdistro "$ROS_DISTRO"

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

colcon build \
--cmake-args -DCMAKE_BUILD_TYPE="$build_type" -DBUILD_TESTING=off -Wno-dev --no-warn-unused-cli \
--symlink-install \
--catkin-skip-building-tests \
--executor parallel \
--parallel-workers "$PARALLEL_WORKERS"

sudo -E apt-get -y autoremove
20 changes: 20 additions & 0 deletions .webauto-ci/main/autoware-setup/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -e

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")
ansible_args+=("--extra-vars" "ros2_installation_type=ros-base")
ansible_args+=("--extra-vars" "install_devel=false")

# 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/universe.yaml" \
"${ansible_args[@]}" \
-e WORKSPACE_ROOT="$(pwd)" \
--skip-tags vcs
14 changes: 14 additions & 0 deletions .webauto-ci/main/environment-setup/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

apt-get update

apt-get -y install sudo curl wget unzip gnupg lsb-release ccache python3-apt python3-pip apt-utils software-properties-common jq
add-apt-repository universe

pip install --no-cache-dir 'ansible==6.*'

user=autoware
useradd -m "$user" -s /bin/bash
echo "$user:$user" | chpasswd
echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers
gpasswd -a "$user" sudo

0 comments on commit 247b298

Please sign in to comment.