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

jenkins: scripted pipelines and shared funcs #1709

Merged
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
7 changes: 1 addition & 6 deletions .github/workflows/github-actions-cron-test-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu20.04", "ubuntu22.04", "centos7"]
os: ["ubuntu20.04", "ubuntu22.04"]
runs-on: ubuntu-latest
steps:
- name: Check out repository code
Expand All @@ -52,9 +52,4 @@ jobs:
- name: Test build
run: |
cmd="source ./env.sh ; yosys -help ; openroad -help ; make -C flow ;"
if [[ ${{ matrix.os }} == "centos7" ]]; then
cmd="source /opt/rh/devtoolset-8/enable; ${cmd}"
cmd="source /opt/rh/llvm-toolset-7.0/enable; ${cmd}"
cmd="source /opt/rh/rh-python38/enable; ${cmd}"
fi
docker run openroad/flow-${{ matrix.os }}-builder /bin/bash -c "${cmd}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,4 @@ docs/main
docs/build
GitGuide.md
mainREADME.md
build
2 changes: 1 addition & 1 deletion docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# i.e., "./build_openroad.sh --local" from inside a docker container
# NOTE: don't use this file directly unless you know what you are doing,
# instead use etc/DockerHelper.sh
ARG fromImage=openroad/flow-centos7-dev:latest
ARG fromImage=openroad/flow-ubuntu22.04-dev:latest

FROM $fromImage

Expand Down
8 changes: 5 additions & 3 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# create image with dependencies needed to compile openroad app and run openroad flow scripts
# NOTE: don't use this file directly unless you know what you are doing,
# instead use etc/DockerHelper.sh
ARG fromImage=centos:centos7
ARG fromImage=ubuntu:22.04

FROM $fromImage

Expand All @@ -12,11 +12,13 @@ COPY DependencyInstaller.sh .
COPY InstallerOpenROAD.sh \
/tmp/installer/tools/OpenROAD/etc/DependencyInstaller.sh

RUN ./DependencyInstaller.sh \
ARG options=""

RUN ./DependencyInstaller.sh $options \
&& rm -rf /tmp/installer

ARG fromImage

RUN echo "$fromImage" | grep -q "ubuntu" && \
strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so || \
echo "Skipping strip command as fromImage does not contain 'ubuntu'"
echo "Skipping strip command as fromImage does not contain 'ubuntu'"
39 changes: 39 additions & 0 deletions etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ _installDarwinPackages() {
brew install --cask klayout
}

_installCI() {
apt-get -y update

#docker
apt install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | 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" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get -y update
apt-get install -y docker-ce docker-ce-cli containerd.io

# python
apt-get install -y python3

# stdbuf
apt-get install -y coreutils
}

_help() {
cat <<EOF

Expand Down Expand Up @@ -138,6 +161,8 @@ Usage: $0
# "$HOME/.local". Only used with
# -common. This flag cannot be used with
# sudo or with root access.
$0 -ci
# Installs CI tools
EOF
exit "${1:-1}"
}
Expand All @@ -150,6 +175,7 @@ PREFIX=""
option="all"
# default isLocal
isLocal="false"
CI="no"

# default values, can be overwritten by cmdline args
while [ "$#" -gt 0 ]; do
Expand All @@ -174,6 +200,9 @@ while [ "$#" -gt 0 ]; do
-local)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -local"
;;
-ci)
CI="yes"
;;
-prefix=*)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
;;
Expand Down Expand Up @@ -209,6 +238,9 @@ esac

case "${os}" in
"CentOS Linux" )
if [[ ${CI} == "yes" ]]; then
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
fi
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installCentosPackages
Expand All @@ -220,6 +252,10 @@ case "${os}" in
;;
"Ubuntu" )
version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g')
if [[ ${CI} == "yes" ]]; then
echo "Installing CI Tools"
_installCI
fi
vvbandeira marked this conversation as resolved.
Show resolved Hide resolved
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installUbuntuPackages "${version}"
Expand All @@ -232,6 +268,9 @@ case "${os}" in
fi
;;
"Darwin" )
if [[ ${CI} == "yes" ]]; then
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
fi
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installDarwinPackages
Expand Down
104 changes: 63 additions & 41 deletions etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ usage: $0 [CMD] [OPTIONS]
push Push the docker image to Docker Hub

OPTIONS:
-os=OS_NAME Choose beween centos7 (default), ubuntu20.04 and ubuntu22.04.
-os=OS_NAME Choose beween ubuntu20.04 and ubuntu22.04 (default).
-target=TARGET Choose target fo the Docker image:
'dev': os + packages to compile app
'builder': os + packages to compile app +
copy source code and build app
-threads Max number of threads to use if compiling.
-sha Use git commit sha as the tag image. Default is
'latest'.
-ci Install CI tools in image
-h -help Show this message and exits
-username Docker Username
-password Docker Password

EOF
exit "${1:-1}"
}

_setup() {
commitSha="$(git rev-parse HEAD)"
commitSha="$(git rev-parse HEAD | tr -cd 'a-zA-Z0-9-')"
case "${os}" in
"centos7")
osBaseImage="centos:centos7"
;;
"ubuntu20.04")
osBaseImage="ubuntu:20.04"
;;
Expand All @@ -50,13 +50,12 @@ _setup() {
;;
esac
imageName="${IMAGE_NAME_OVERRIDE:-"${org}/flow-${os}-${target}"}"
if [[ "${useCommitSha}" == "yes" ]]; then
imageTag="${commitSha}"
else
imageTag="latest"
imageTag="${commitSha}"
if [[ "${tag}" != "NONE" ]]; then
imageTag="${tag}"
fi
case "${target}" in
"builder" )
"builder" | "master")
fromImage="${FROM_IMAGE_OVERRIDE:-"${org}/flow-${os}-dev"}:${imageTag}"
context="."
buildArgs="--build-arg numThreads=${numThreads}"
Expand All @@ -65,7 +64,7 @@ _setup() {
fromImage="${FROM_IMAGE_OVERRIDE:-$osBaseImage}"
cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh
context="etc"
buildArgs=""
buildArgs="--build-arg options=${options}"
;;
*)
echo "Target ${target} not found" >&2
Expand All @@ -79,38 +78,51 @@ _setup() {

_create() {
echo "Create docker image ${imagePath} using ${file}"
docker build --file "${file}" --tag "${imagePath}" ${buildArgs} "${context}"
docker build \
--file "${file}" \
--tag "${imagePath}" \
${buildArgs} \
"${context}" \
--progress plain
rm -f etc/InstallerOpenROAD.sh
}

_push() {
if [[ -z ${username+x} ]]; then
echo "Missing required -username=<USER> argument"
_help
fi
if [[ -z ${password+x} ]]; then
echo "Missing required -password=<PASS> argument"
_help
fi
docker login --username ${username} --password ${password}
if [[ "${tag}" == "NONE" ]]; then
tag="latest"
fi
mkdir -p build
case "${target}" in
"dev" )
read -p "Will push docker image ${imagePath} to DockerHub [y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mkdir -p build

OS_LIST="centos7 ubuntu20.04 ubuntu22.04"
# create image with sha and latest tag for all os
for os in ${OS_LIST}; do
./etc/DockerHelper.sh create -target=dev \
2>&1 | tee build/create-${os}-latest.log
./etc/DockerHelper.sh create -target=dev -sha \
2>&1 | tee build/create-${os}-${commitSha}.log
done

for os in ${OS_LIST}; do
echo [DRY-RUN] docker push openroad/flow-${os}-dev:latest
echo [DRY-RUN] docker push openroad/flow-${os}-dev:${commitSha}
done

else
echo "Will not push."
fi
./etc/DockerHelper.sh create -os=${os} -ci -target=${target} \
2>&1 | tee build/create-${os}-${target}-${tag}.log
docker push ${imagePath}
;;

"master" )
# Create dev image needed as a base for builder image
./etc/DockerHelper.sh create -os=${os} -target=dev \
2>&1 | tee build/create-${os}-dev-${target}-${tag}.log
# Create builder image
./etc/DockerHelper.sh create -os=${os} -target=builder \
2>&1 | tee build/create-${os}-${target}-${tag}.log
docker push ${org}/flow-${os}-dev:${commitSha}
docker push ${org}/flow-${os}-dev:${commitSha} ${org}/flow-${os}-dev:latest
docker push ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${commitSha}
docker push ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${tag}
;;

*)
echo "Target ${target} is not valid candidate for push to DockerHub." >&2
echo "Target ${target} is not valid candidate for push to Docker Hub." >&2
_help
;;
esac
Expand Down Expand Up @@ -139,17 +151,21 @@ if [[ -z $(command -v "${_rule}") ]]; then
_help
fi

# default values, can be overwritten by cmdline args
os="centos7"
# default values, can be overwritten by command line arguments
os="ubuntu22.04"
target="dev"
useCommitSha="no"
numThreads="-1"
tag="NONE"
options=""

while [ "$#" -gt 0 ]; do
case "${1}" in
-h|-help)
_help 0
;;
-ci )
options="-ci"
;;
-os=* )
os="${1#*=}"
;;
Expand All @@ -159,10 +175,16 @@ while [ "$#" -gt 0 ]; do
-threads=* )
numThreads="${1#*=}"
;;
-sha )
useCommitSha=yes
-username=* )
username="${1#*=}"
;;
-password=* )
password="${1#*=}"
;;
-tag=* )
tag="${1#*=}"
;;
-os | -target )
-os | -target | -threads | -username | -password | -tag )
echo "${1} requires an argument" >&2
_help
;;
Expand Down
1 change: 1 addition & 0 deletions flow/test/test_delta_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# variable names such as $(false), unused variables, etc.
set -ue -o pipefail

cd flow
testname=uart

make DESIGN_CONFIG=designs/asap7/$testname/config.mk place
Expand Down
Loading
Loading