Skip to content

Commit 05ac511

Browse files
authored
Merge pull request #1709 from habibayassin/scripted-pipeline
jenkins: scripted pipelines and shared funcs
2 parents e7decbc + e345c79 commit 05ac511

File tree

9 files changed

+210
-448
lines changed

9 files changed

+210
-448
lines changed

.github/workflows/github-actions-cron-test-installer.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
os: ["ubuntu20.04", "ubuntu22.04", "centos7"]
29+
os: ["ubuntu20.04", "ubuntu22.04"]
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Check out repository code
@@ -52,9 +52,4 @@ jobs:
5252
- name: Test build
5353
run: |
5454
cmd="source ./env.sh ; yosys -help ; openroad -help ; make -C flow ;"
55-
if [[ ${{ matrix.os }} == "centos7" ]]; then
56-
cmd="source /opt/rh/devtoolset-8/enable; ${cmd}"
57-
cmd="source /opt/rh/llvm-toolset-7.0/enable; ${cmd}"
58-
cmd="source /opt/rh/rh-python38/enable; ${cmd}"
59-
fi
6055
docker run openroad/flow-${{ matrix.os }}-builder /bin/bash -c "${cmd}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ docs/main
8989
docs/build
9090
GitGuide.md
9191
mainREADME.md
92+
build

docker/Dockerfile.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# i.e., "./build_openroad.sh --local" from inside a docker container
33
# NOTE: don't use this file directly unless you know what you are doing,
44
# instead use etc/DockerHelper.sh
5-
ARG fromImage=openroad/flow-centos7-dev:latest
5+
ARG fromImage=openroad/flow-ubuntu22.04-dev:latest
66

77
FROM $fromImage
88

docker/Dockerfile.dev

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# create image with dependencies needed to compile openroad app and run openroad flow scripts
22
# NOTE: don't use this file directly unless you know what you are doing,
33
# instead use etc/DockerHelper.sh
4-
ARG fromImage=centos:centos7
4+
ARG fromImage=ubuntu:22.04
55

66
FROM $fromImage
77

@@ -12,11 +12,13 @@ COPY DependencyInstaller.sh .
1212
COPY InstallerOpenROAD.sh \
1313
/tmp/installer/tools/OpenROAD/etc/DependencyInstaller.sh
1414

15-
RUN ./DependencyInstaller.sh \
15+
ARG options=""
16+
17+
RUN ./DependencyInstaller.sh $options \
1618
&& rm -rf /tmp/installer
1719

1820
ARG fromImage
1921

2022
RUN echo "$fromImage" | grep -q "ubuntu" && \
2123
strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so || \
22-
echo "Skipping strip command as fromImage does not contain 'ubuntu'"
24+
echo "Skipping strip command as fromImage does not contain 'ubuntu'"

etc/DependencyInstaller.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,29 @@ _installDarwinPackages() {
111111
brew install --cask klayout
112112
}
113113

114+
_installCI() {
115+
apt-get -y update
116+
117+
#docker
118+
apt install -y \
119+
apt-transport-https \
120+
ca-certificates \
121+
curl \
122+
software-properties-common
123+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
124+
echo \
125+
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
126+
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
127+
apt-get -y update
128+
apt-get install -y docker-ce docker-ce-cli containerd.io
129+
130+
# python
131+
apt-get install -y python3
132+
133+
# stdbuf
134+
apt-get install -y coreutils
135+
}
136+
114137
_help() {
115138
cat <<EOF
116139
@@ -138,6 +161,8 @@ Usage: $0
138161
# "$HOME/.local". Only used with
139162
# -common. This flag cannot be used with
140163
# sudo or with root access.
164+
$0 -ci
165+
# Installs CI tools
141166
EOF
142167
exit "${1:-1}"
143168
}
@@ -150,6 +175,7 @@ PREFIX=""
150175
option="all"
151176
# default isLocal
152177
isLocal="false"
178+
CI="no"
153179

154180
# default values, can be overwritten by cmdline args
155181
while [ "$#" -gt 0 ]; do
@@ -174,6 +200,9 @@ while [ "$#" -gt 0 ]; do
174200
-local)
175201
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -local"
176202
;;
203+
-ci)
204+
CI="yes"
205+
;;
177206
-prefix=*)
178207
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
179208
;;
@@ -209,6 +238,9 @@ esac
209238

210239
case "${os}" in
211240
"CentOS Linux" )
241+
if [[ ${CI} == "yes" ]]; then
242+
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
243+
fi
212244
_installORDependencies
213245
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
214246
_installCentosPackages
@@ -220,6 +252,10 @@ case "${os}" in
220252
;;
221253
"Ubuntu" )
222254
version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g')
255+
if [[ ${CI} == "yes" ]]; then
256+
echo "Installing CI Tools"
257+
_installCI
258+
fi
223259
_installORDependencies
224260
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
225261
_installUbuntuPackages "${version}"
@@ -232,6 +268,9 @@ case "${os}" in
232268
fi
233269
;;
234270
"Darwin" )
271+
if [[ ${CI} == "yes" ]]; then
272+
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
273+
fi
235274
_installORDependencies
236275
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
237276
_installDarwinPackages

etc/DockerHelper.sh

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ usage: $0 [CMD] [OPTIONS]
1818
push Push the docker image to Docker Hub
1919
2020
OPTIONS:
21-
-os=OS_NAME Choose beween centos7 (default), ubuntu20.04 and ubuntu22.04.
21+
-os=OS_NAME Choose beween ubuntu20.04 and ubuntu22.04 (default).
2222
-target=TARGET Choose target fo the Docker image:
2323
'dev': os + packages to compile app
2424
'builder': os + packages to compile app +
2525
copy source code and build app
2626
-threads Max number of threads to use if compiling.
2727
-sha Use git commit sha as the tag image. Default is
2828
'latest'.
29+
-ci Install CI tools in image
2930
-h -help Show this message and exits
31+
-username Docker Username
32+
-password Docker Password
3033
3134
EOF
3235
exit "${1:-1}"
3336
}
3437

3538
_setup() {
36-
commitSha="$(git rev-parse HEAD)"
39+
commitSha="$(git rev-parse HEAD | tr -cd 'a-zA-Z0-9-')"
3740
case "${os}" in
38-
"centos7")
39-
osBaseImage="centos:centos7"
40-
;;
4141
"ubuntu20.04")
4242
osBaseImage="ubuntu:20.04"
4343
;;
@@ -50,13 +50,12 @@ _setup() {
5050
;;
5151
esac
5252
imageName="${IMAGE_NAME_OVERRIDE:-"${org}/flow-${os}-${target}"}"
53-
if [[ "${useCommitSha}" == "yes" ]]; then
54-
imageTag="${commitSha}"
55-
else
56-
imageTag="latest"
53+
imageTag="${commitSha}"
54+
if [[ "${tag}" != "NONE" ]]; then
55+
imageTag="${tag}"
5756
fi
5857
case "${target}" in
59-
"builder" )
58+
"builder" | "master")
6059
fromImage="${FROM_IMAGE_OVERRIDE:-"${org}/flow-${os}-dev"}:${imageTag}"
6160
context="."
6261
buildArgs="--build-arg numThreads=${numThreads}"
@@ -65,7 +64,7 @@ _setup() {
6564
fromImage="${FROM_IMAGE_OVERRIDE:-$osBaseImage}"
6665
cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh
6766
context="etc"
68-
buildArgs=""
67+
buildArgs="--build-arg options=${options}"
6968
;;
7069
*)
7170
echo "Target ${target} not found" >&2
@@ -79,38 +78,51 @@ _setup() {
7978

8079
_create() {
8180
echo "Create docker image ${imagePath} using ${file}"
82-
docker build --file "${file}" --tag "${imagePath}" ${buildArgs} "${context}"
81+
docker build \
82+
--file "${file}" \
83+
--tag "${imagePath}" \
84+
${buildArgs} \
85+
"${context}" \
86+
--progress plain
8387
rm -f etc/InstallerOpenROAD.sh
8488
}
8589

8690
_push() {
91+
if [[ -z ${username+x} ]]; then
92+
echo "Missing required -username=<USER> argument"
93+
_help
94+
fi
95+
if [[ -z ${password+x} ]]; then
96+
echo "Missing required -password=<PASS> argument"
97+
_help
98+
fi
99+
docker login --username ${username} --password ${password}
100+
if [[ "${tag}" == "NONE" ]]; then
101+
tag="latest"
102+
fi
103+
mkdir -p build
87104
case "${target}" in
88105
"dev" )
89-
read -p "Will push docker image ${imagePath} to DockerHub [y/N]" -n 1 -r
90-
echo
91-
if [[ $REPLY =~ ^[Yy]$ ]]; then
92-
mkdir -p build
93-
94-
OS_LIST="centos7 ubuntu20.04 ubuntu22.04"
95-
# create image with sha and latest tag for all os
96-
for os in ${OS_LIST}; do
97-
./etc/DockerHelper.sh create -target=dev \
98-
2>&1 | tee build/create-${os}-latest.log
99-
./etc/DockerHelper.sh create -target=dev -sha \
100-
2>&1 | tee build/create-${os}-${commitSha}.log
101-
done
102-
103-
for os in ${OS_LIST}; do
104-
echo [DRY-RUN] docker push openroad/flow-${os}-dev:latest
105-
echo [DRY-RUN] docker push openroad/flow-${os}-dev:${commitSha}
106-
done
107-
108-
else
109-
echo "Will not push."
110-
fi
106+
./etc/DockerHelper.sh create -os=${os} -ci -target=${target} \
107+
2>&1 | tee build/create-${os}-${target}-${tag}.log
108+
docker push ${imagePath}
111109
;;
110+
111+
"master" )
112+
# Create dev image needed as a base for builder image
113+
./etc/DockerHelper.sh create -os=${os} -target=dev \
114+
2>&1 | tee build/create-${os}-dev-${target}-${tag}.log
115+
# Create builder image
116+
./etc/DockerHelper.sh create -os=${os} -target=builder \
117+
2>&1 | tee build/create-${os}-${target}-${tag}.log
118+
docker push ${org}/flow-${os}-dev:${commitSha}
119+
docker push ${org}/flow-${os}-dev:${commitSha} ${org}/flow-${os}-dev:latest
120+
docker push ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${commitSha}
121+
docker push ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${tag}
122+
;;
123+
112124
*)
113-
echo "Target ${target} is not valid candidate for push to DockerHub." >&2
125+
echo "Target ${target} is not valid candidate for push to Docker Hub." >&2
114126
_help
115127
;;
116128
esac
@@ -139,17 +151,21 @@ if [[ -z $(command -v "${_rule}") ]]; then
139151
_help
140152
fi
141153

142-
# default values, can be overwritten by cmdline args
143-
os="centos7"
154+
# default values, can be overwritten by command line arguments
155+
os="ubuntu22.04"
144156
target="dev"
145-
useCommitSha="no"
146157
numThreads="-1"
158+
tag="NONE"
159+
options=""
147160

148161
while [ "$#" -gt 0 ]; do
149162
case "${1}" in
150163
-h|-help)
151164
_help 0
152165
;;
166+
-ci )
167+
options="-ci"
168+
;;
153169
-os=* )
154170
os="${1#*=}"
155171
;;
@@ -159,10 +175,16 @@ while [ "$#" -gt 0 ]; do
159175
-threads=* )
160176
numThreads="${1#*=}"
161177
;;
162-
-sha )
163-
useCommitSha=yes
178+
-username=* )
179+
username="${1#*=}"
180+
;;
181+
-password=* )
182+
password="${1#*=}"
183+
;;
184+
-tag=* )
185+
tag="${1#*=}"
164186
;;
165-
-os | -target )
187+
-os | -target | -threads | -username | -password | -tag )
166188
echo "${1} requires an argument" >&2
167189
_help
168190
;;

flow/test/test_delta_debug.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# variable names such as $(false), unused variables, etc.
77
set -ue -o pipefail
88

9+
cd flow
910
testname=uart
1011

1112
make DESIGN_CONFIG=designs/asap7/$testname/config.mk place

0 commit comments

Comments
 (0)