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

Enable support for gitlab #120

Merged
merged 5 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# the following block is needed for the shared Docker-based runner
image: docker:git # docker and git clients
variables:
DOCKER_DRIVER: "overlay" # recommended for docker-in-docker, needs overlay kernel module loaded on host
services:
- docker:dind # enable docker-in-docker

before_script:
- apk add --update bash coreutils # install industrial_ci dependencies
- git clone https://github.com/ros-industrial/industrial_ci .ci_config

indigo:
script: .ci_config/gitlab.sh
variables:
ROS_DISTRO: "indigo"

jade:
script: .ci_config/gitlab.sh
variables:
ROS_DISTRO: "jade"
PRERELEASE: "true"
PRERELEASE_REPONAME: "std_msgs"

kinetic:
script: .ci_config/gitlab.sh ROS_DISTRO=kinetic # alternate syntax
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ env:
- ROS_DISTRO=indigo USE_DEB=false # Checking backup compatibility with UPSTREAM_WORKSPACE
- ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-indigo-opencv3" VERBOSE_OUTPUT='false'
- ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='true' EXPECT_EXIT_CODE=100 # This should fail (trying from a wrong distro).
- ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass.
- ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet _DO_NOT_FOLD=true # Passing wrong SKS URL as a break test. Should still pass.
- ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall # Testing arbitrary file name without ROS_DISTRO suffix. As of 6/3/2016 this fails due to https://github.com/ros-industrial/industrial_core/pull/144#issuecomment-223186764
- ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.i.do.not.exist EXPECT_EXIT_CODE=1
- ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=i_do_not_exist EXPECT_EXIT_CODE=1 PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail, to test the capability of capturing Prerelease Test failure.
Expand Down
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ To start using CI config stored in this repo

With the following few short steps, you can start in your client repository using CI confiurations stored in here (`industrial_ci` repository).

1. Don't forget to activate CI on your github repository (you may do so on https://travis-ci.org/profile/YOUR_GITHUB_ORGANIZATION or https://travis-ci.org/profile/YOUR_GITHUB_USER).
1. Don't forget to activate Travis CI on your github repository (you may do so on https://travis-ci.org/profile/YOUR_GITHUB_ORGANIZATION or https://travis-ci.org/profile/YOUR_GITHUB_USER).

2. In `.travis.yml` file in your client repo, add in `before_config` section a sentence `git clone https://github.com/ros-industrial/industrial_ci.git .ci_config`, like below:

Expand All @@ -114,6 +114,7 @@ With the following few short steps, you can start in your client repository usin

* Note that `.ci_config` is the required name of the cloned folder; it is hardcoded so you need to use this name.
* Example of entire file `.travis.yml` can be found in `industrial_core/.travis.yml <https://github.com/ros-industrial/industrial_core/blob/indigo-devel/.travis.yml>`_.
* A Gitlab CI config can be found in `.gitlab-ci.yml <https://github.com/ros-industrial/industrial_ci/blob/master/.gitlab-ci.yml>`_.

That's it.

Expand Down
28 changes: 28 additions & 0 deletions gitlab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Copyright (c) 2016, Isaac I. Y. Saito
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright must be @ipa-mdl ;)

# Copyright (c) 2017, Mathias Lüdtke
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file remains as "travis.sh" at the top directory of industrial_ci repository only to keep backward compatibility between version 0.2.2 and the newer.

# 2016/05/18 http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR_THIS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export TARGET_REPO_PATH=$CI_PROJECT_DIR
export TARGET_REPO_NAME=$CI_PROJECT_NAME
export _DO_NOT_FOLD=true

env "$@" bash $DIR_THIS/industrial_ci/src/ci_main.sh
1 change: 1 addition & 0 deletions industrial_ci/scripts/run_ci
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fi

export TARGET_REPO_PATH=$(cd "$repo_dir" && pwd)
export TARGET_REPO_NAME=${TARGET_REPO_PATH##*/}
export _DO_NOT_FOLD=true
echo "Testing $TARGET_REPO_PATH"

if [ -f "$script_dir/../src/ci_main.sh" ]; then # devel space
Expand Down
1 change: 1 addition & 0 deletions industrial_ci/src/docker.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_DO_NOT_FOLD
ADDITIONAL_DEBS
AFTER_SCRIPT
BEFORE_SCRIPT
Expand Down
4 changes: 3 additions & 1 deletion industrial_ci/src/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ function ici_run_cmd_in_docker() {
--env-file "${ICI_SRC_PATH}"/docker.env \
"${ssh_docker_opts[@]}" \
"$@")
docker cp ~/.ssh "$cid:/root/" # pass SSH settings to container
if [ -d ~/.ssh ]; then
docker cp ~/.ssh "$cid:/root/" # pass SSH settings to container
fi

docker start -a "$cid" &
trap 'docker kill $cid' INT
Expand Down
29 changes: 20 additions & 9 deletions industrial_ci/src/tests/ros_prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
# limitations under the License.

function setup_environment() {
export WORKSPACE
WORKSPACE=$(mktemp -d)
echo "WORKSPACE: $WORKSPACE"

if [ -e /var/run/docker.sock ]; then
DIND_OPTS=-"v /var/run/docker.sock:/var/run/docker.sock"
user_cmd="groupadd -g $(stat -c%g /var/run/docker.sock) host_docker && useradd -G host_docker ci"
else
DIND_OPTS="-e DOCKER_HOST=$DOCKER_PORT"
user_cmd="useradd ci"
fi

docker build -t "industrial-ci/prerelease" - <<EOF > /dev/null
FROM ubuntu:xenial

Expand All @@ -35,18 +47,16 @@ RUN apt-get update -qq \
sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g $(stat -c%g /var/run/docker.sock) host_docker \
&& groupadd -g $(id -g) buildfarm \
&& useradd -u $(id -u) -g buildfarm -G host_docker buildfarm
USER buildfarm
RUN $user_cmd
USER ci
ENV WORKSPACE $WORKSPACE
WORKDIR $WORKSPACE
ENTRYPOINT ["/opt/ros/kinetic/env.sh"]
EOF
}

function run_in_prerelease_docker() {
ici_run_cmd_in_docker -v /var/run/docker.sock:/var/run/docker.sock \
ici_run_cmd_in_docker $DIND_OPTS \
-v "$WORKSPACE:$WORKSPACE:rw" \
"industrial-ci/prerelease" \
"$@"
Expand All @@ -55,9 +65,6 @@ function run_in_prerelease_docker() {
function run_ros_prerelease() {
# Environment vars.
local downstream_depth=${PRERELEASE_DOWNSTREAM_DEPTH:-"0"}
export WORKSPACE
WORKSPACE=$(mktemp -d)
echo "WORKSPACE: $WORKSPACE:"

ici_time_start setup_environment
setup_environment
Expand All @@ -73,7 +80,11 @@ function run_ros_prerelease() {
cp -a "$TARGET_REPO_PATH"/* "$WORKSPACE/catkin_workspace/src/"
clone_underlay=false
fi
run_in_prerelease_docker generate_prerelease_script.py https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/production/index.yaml "$ROS_DISTRO" default ubuntu "$UBUNTU_OS_CODE_NAME" amd64 "${reponame}" --level "$downstream_depth" --output-dir .

# ensure access rights
ici_run_cmd_in_docker $DIND_OPTS -v "$WORKSPACE:$WORKSPACE:rw" --user root "industrial-ci/prerelease" chown -R ci:ci $WORKSPACE

run_in_prerelease_docker generate_prerelease_script.py https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/production/index.yaml "$ROS_DISTRO" default ubuntu "$UBUNTU_OS_CODE_NAME" amd64 "${reponame}" --level "$downstream_depth" --output-dir .
ici_time_end # setup_prerelease_scripts

if [ "$clone_underlay" = true ]; then
Expand Down
14 changes: 10 additions & 4 deletions industrial_ci/src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ function ici_time_start {
ICI_START_TIME=$(date +%s%N)
ICI_TIME_ID=$(printf "%x" $ICI_START_TIME)
ICI_FOLD_NAME=$1
echo -e "\e[0Kici_fold:start:$ICI_FOLD_NAME"
echo -e "\e[0Kici_time:start:$ICI_TIME_ID\e[34m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\e[0m"
if [ "$_DO_NOT_FOLD" != "true" ]; then
echo -e "\e[0Kici_fold:start:$ICI_FOLD_NAME"
echo -en "\e[0Kici_time:start:$ICI_TIME_ID"
fi
echo -e "\e[34m>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\e[0m"
if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi
}

Expand All @@ -67,8 +70,11 @@ function ici_time_end {
if [ -z $ICI_START_TIME ]; then echo '[ici_time_end] var ICI_START_TIME is not set. You need to call `ici_time_start` in advance. Rerutning.'; return; fi
local end_time=$(date +%s%N)
local elapsed_seconds=$(( ($end_time - $ICI_START_TIME)/1000000000 ))
echo -e "ici_time:end:$ICI_TIME_ID:start=$ICI_START_TIME,finish=$end_time,duration=$(($end_time - $ICI_START_TIME))\e[0K"
echo -e "ici_fold:end:$ICI_FOLD_NAME\e[${color_wrap}m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m"
if [ "$_DO_NOT_FOLD" != "true" ]; then
echo -e "ici_time:end:$ICI_TIME_ID:start=$ICI_START_TIME,finish=$end_time,duration=$(($end_time - $ICI_START_TIME))\e[0K"
echo -en "ici_fold:end:$ICI_FOLD_NAME"
fi
echo -e "\e[${color_wrap}m<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\e[0m"
echo -e "\e[0K\e[${color_wrap}mFunction $ICI_FOLD_NAME returned with code '${exit_code}' after $(( $elapsed_seconds / 60 )) min $(( $elapsed_seconds % 60 )) sec \e[0m"

unset ICI_FOLD_NAME
Expand Down
3 changes: 2 additions & 1 deletion travis.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

# Copyright (c) 2016, Isaac I. Y. Saito
# Copyright (c) 2017, Mathias Lüdtke
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,4 +24,4 @@ DIR_THIS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TARGET_REPO_PATH=$(pwd)
export TARGET_REPO_NAME=${PWD##*/}

bash $DIR_THIS/industrial_ci/src/ci_main.sh
env "$@" bash $DIR_THIS/industrial_ci/src/ci_main.sh