From c6bfff24b05710b84d5ef3fb16d6deeaf9a6baff Mon Sep 17 00:00:00 2001 From: David Galloway Date: Fri, 20 Aug 2021 17:00:33 -0400 Subject: [PATCH] Add build-make-check-container job Signed-off-by: David Galloway --- build-make-check-container/build/Dockerfile | 45 +++++++++ build-make-check-container/build/build | 20 ++++ build-make-check-container/build/setup | 29 ++++++ .../build-make-check-container.yml | 92 +++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 build-make-check-container/build/Dockerfile create mode 100644 build-make-check-container/build/build create mode 100644 build-make-check-container/build/setup create mode 100644 build-make-check-container/config/definitions/build-make-check-container.yml diff --git a/build-make-check-container/build/Dockerfile b/build-make-check-container/build/Dockerfile new file mode 100644 index 000000000..447d33d19 --- /dev/null +++ b/build-make-check-container/build/Dockerfile @@ -0,0 +1,45 @@ +# This is just the default. Overridden by `docker build --build-arg DISTRO=$DISTRO` at build time +ARG DISTRO='ubuntu:20.04' +FROM $DISTRO +RUN if command -v yum; then \ + yum install -y epel-release; \ + yum install -y git sudo ccache clang; \ + yum update -y; \ + else \ + apt update && DEBIAN_FRONTEND="noninteractive" apt install -y git-core sudo ccache; \ + fi +RUN git clone https://github.com/ceph/ceph /opt/ceph +RUN git clone https://github.com/ceph/ceph-ci /opt/ceph-ci +# Set some defaults (again, overridden using --build-arg) +ARG INSTALL_DEPS_REPO=ceph +ARG INSTALL_DEPS_BRANCH=master +RUN cd /opt/$INSTALL_DEPS_REPO \ + && if ! git checkout $INSTALL_DEPS_BRANCH; then \ + echo $INSTALL_DEPS_BRANCH doesn\'t exist; \ + exit 1; \ + fi \ + && DEBIAN_FRONTEND="noninteractive" ./install-deps.sh \ + && git submodule update --init --recursive +# Doesn't work yet +# # To populate ccache +# && ./src/script/run-make.sh \ +# && rm -rf build +# Some defaults. Overridden by `docker run -e VAR=$VAR` at runtime +ENV REPO=${REPO:-ceph} +ENV BRANCH=${BRANCH:-master} +ENV PULLREQUEST_ID=${PULLREQUEST_ID} +# Uncertain on the proper order here. Do I need to `pull` after checking out the branch again? +CMD cd /opt/$REPO \ + && git fetch --all \ + && if [ "$PULLREQUEST_ID" == "" ]; then \ + echo "PULLREQUEST_ID was not defined. Using the \$BRANCH var"; \ + echo -e "****************\n\nChecking out branch: $BRANCH\n\n****************"; \ + git checkout $BRANCH; \ + git pull; \ + else \ + echo -e "****************\n\nChecking out Pull Request ID: $PULLREQUEST_ID\n\n****************"; \ + git fetch origin pull/$PULLREQUEST_ID/head:PR$PULLREQUEST_ID; \ + git checkout PR$PULLREQUEST_ID; \ + fi \ + && ./install-deps.sh \ + && timeout 3h ./run-make-check.sh diff --git a/build-make-check-container/build/build b/build-make-check-container/build/build new file mode 100644 index 000000000..a44c41910 --- /dev/null +++ b/build-make-check-container/build/build @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +# Uncomment these to run locally on your workstation +#DISTRO="ubuntu:20.04" +#DISTRO="centos:8" +#BRANCH=${BRANCH:-master} +#WORKSPACE=~/git/ceph/ceph-build + +DASHED_DISTRO=$(echo "$DISTRO" | sed 's/:/-/') + +cd "$WORKSPACE"/build-make-check-container/build + +sudo docker build --build-arg INSTALL_DEPS_BRANCH=$BRANCH --build-arg DISTRO=$DISTRO -t make-check:$BRANCH-$DASHED_DISTRO . + +sudo docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" quay.ceph.io + +sudo docker image tag make-check:$BRANCH-$DASHED_DISTRO quay.ceph.io/cephci/make-check:$BRANCH-$DASHED_DISTRO + +sudo docker push quay.ceph.io/cephci/make-check:$BRANCH-$DASHED_DISTRO diff --git a/build-make-check-container/build/setup b/build-make-check-container/build/setup new file mode 100644 index 000000000..caade72e6 --- /dev/null +++ b/build-make-check-container/build/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -ex + +if [[ $(command -v docker) == '' ]]; then + # Set up docker official repo and install docker. + sudo apt update -y + sudo apt install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo \ + "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt update -y + sudo apt install -y docker-ce docker-ce-cli containerd.io +fi +sudo groupadd docker || true +sudo usermod -aG docker $(id -un) +sudo systemctl start docker +sudo chgrp "$(id -un)" /var/run/docker.sock + +docker info +docker container prune -f + + diff --git a/build-make-check-container/config/definitions/build-make-check-container.yml b/build-make-check-container/config/definitions/build-make-check-container.yml new file mode 100644 index 000000000..e7a512710 --- /dev/null +++ b/build-make-check-container/config/definitions/build-make-check-container.yml @@ -0,0 +1,92 @@ +- job: + name: build-make-check-container + node: master + project-type: matrix + defaults: global + display-name: 'Builds the ceph-make-check container and pushes to quay.ceph.io' + quiet-period: 5 + block-downstream: false + block-upstream: false + retry-count: 3 + execution-strategy: + combination-filter: | + !(BRANCH=="master" && DISTRO=="centos:7") && + !(BRANCH=="pacific" && DISTRO=="centos:7") && + !(BRANCH=="master" && DISTRO=="ubuntu:18.04") && + !(BRANCH=="pacific" && DISTRO=="ubuntu:18.04") + properties: + - build-discarder: + days-to-keep: 14 + +# parameters: +# - string: +# name: BRANCH +# description: "Base branch you want to the container to have install-deps run for" +# default: master +# +# - string: +# name: DISTRO +# description: "Distro you want install-deps run on" +# default: 'ubuntu:20.04' + + axes: + - axis: + type: label-expression + name: MACHINE_SIZE + values: + - huge + - axis: + type: label-expression + name: MACHINE_TYPE + values: + - focal + - axis: + type: label-expression + name: MACHINE_ARCH + values: + - x86_64 + + - axis: + type: user-defined + name: BRANCH + values: + - master + - octopus + - pacific + + - axis: + type: user-defined + name: DISTRO + values: + - 'centos:7' + - 'centos:8' + - 'ubuntu:18.04' + - 'ubuntu:20.04' + + triggers: + - timed: '@daily' + + scm: + - git: + url: https://github.com/ceph/ceph-build.git + branches: + - build-make-check-container + browser: auto + timeout: 20 + + builders: + - shell: + !include-raw: +# - ../../../scripts/build_utils.sh + - ../../build/setup + - ../../build/build + + wrappers: + - inject-passwords: + global: true + mask-password-params: true + - credentials-binding: + - username-password-separated: + credential-id: quay-ceph-io-make-check-bot + username: REGISTRY_USERNAME + password: REGISTRY_PASSWORD