Skip to content

Commit af2758c

Browse files
committed
Merge remote-tracking branch 'origin/master' into secure-pin-swap-fix-flow
2 parents 2914ac9 + 56eb1b9 commit af2758c

File tree

11 files changed

+407
-289
lines changed

11 files changed

+407
-289
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ jobs:
4545
sudo service docker restart
4646
- name: Run installer
4747
run: |
48-
./etc/DockerHelper.sh create -target=dev -os=${{ matrix.os }}
48+
./etc/DockerHelper.sh create -target=dev -os=${{ matrix.os }} -tag=latest
4949
- name: Build project
5050
run: |
51-
./etc/DockerHelper.sh create -target=builder -os=${{ matrix.os }}
51+
./etc/DockerHelper.sh create -target=builder -os=${{ matrix.os }} -tag=latest
5252
- name: Test build
5353
run: |
5454
cmd="source ./env.sh ; yosys -help ; openroad -help ; make -C flow ;"
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Build and publish ORFS images
2+
on:
3+
push:
4+
paths:
5+
- etc/DependencyInstaller.sh
6+
- etc/DockerHelper.sh
7+
- .github/workflows/github-actions-publish-docker-images.yml
8+
- build_openroad.sh
9+
- env.sh
10+
- flow/Makefile
11+
- docker/Dockerfile.dev
12+
- docker/Dockerfile.builder
13+
pull_request:
14+
paths:
15+
- etc/DependencyInstaller.sh
16+
- etc/DockerHelper.sh
17+
- .github/workflows/github-actions-publish-docker-images.yml
18+
- build_openroad.sh
19+
- env.sh
20+
- flow/Makefile
21+
- docker/Dockerfile.dev
22+
- docker/Dockerfile.builder
23+
24+
jobs:
25+
buildDependenciesImage:
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
os: [["ubuntu20.04", "ubuntu:20.04"], ["ubuntu22.04", "ubuntu:22.04"]]
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Check out repository code
33+
uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 1
36+
submodules: recursive
37+
38+
- name: Set environment variables
39+
run: |
40+
echo "IMAGE_DEPS=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-dev/${{ matrix.os[0] }}" >> $GITHUB_ENV
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to GitHub Container Registry (GHCR)
46+
if: github.event_name != 'pull_request'
47+
uses: docker/login-action@v2
48+
with:
49+
registry: ghcr.io
50+
username: gha
51+
password: ${{ github.token }}
52+
53+
- name: Copy OpenROAD installer
54+
run: cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh
55+
56+
- name: Build and export dependencies image
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: etc
60+
push: true
61+
tags: ${{ env.IMAGE_DEPS }}:latest
62+
file: docker/Dockerfile.dev
63+
build-args: |
64+
fromImage=${{ matrix.os[1] }}
65+
numThreads=$(nproc)
66+
cache-from: type=registry,ref=${{ env.IMAGE_DEPS }}:buildcache
67+
cache-to: type=registry,ref=${{ env.IMAGE_DEPS }}:buildcache,mode=max
68+
69+
buildORFSImage:
70+
needs: buildDependenciesImage
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
os: ["ubuntu20.04", "ubuntu22.04"]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Free Disk Space
78+
uses: jlumbroso/free-disk-space@main
79+
with:
80+
tool-cache: false
81+
82+
- name: Check out repository code
83+
uses: actions/checkout@v3
84+
with:
85+
fetch-depth: 1
86+
submodules: recursive
87+
88+
- name: Set environment variables
89+
run: |
90+
echo "IMAGE=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')/${{ matrix.os }}" >> $GITHUB_ENV
91+
echo "IMAGE_DEPS=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-dev/${{ matrix.os }}" >> $GITHUB_ENV
92+
93+
- name: Set up Docker Buildx
94+
uses: docker/setup-buildx-action@v3
95+
96+
# We don't use the build-push-action here because it hangs
97+
- name: Build ORFS image
98+
run: |
99+
docker buildx build \
100+
--load \
101+
--build-arg fromImage=${{ env.IMAGE_DEPS }}:latest \
102+
--build-arg numThreads=$(nproc) \
103+
--cache-from type=registry,ref=${{ env.IMAGE }}:buildcache \
104+
--tag ${{ env.IMAGE }}:latest \
105+
--file docker/Dockerfile.builder \
106+
.
107+
108+
- name: Test build
109+
run: |
110+
cmd="source ./env.sh && yosys -help && openroad -help && make -C flow ;"
111+
docker run ${{ env.IMAGE }}:latest /bin/bash -c "${cmd}"
112+
113+
- name: Login to GitHub Container Registry (GHCR)
114+
if: github.event_name != 'pull_request'
115+
uses: docker/login-action@v2
116+
with:
117+
registry: ghcr.io
118+
username: gha
119+
password: ${{ github.token }}
120+
121+
- name: Export ORFS image
122+
run: |
123+
docker buildx build \
124+
--build-arg fromImage=${{ env.IMAGE_DEPS }}:latest \
125+
--build-arg numThreads=$(nproc) \
126+
--cache-from type=registry,ref=${{ env.IMAGE }}:buildcache \
127+
--cache-to type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max \
128+
--tag ${{ env.IMAGE }}:latest \
129+
--file docker/Dockerfile.builder \
130+
--push \
131+
.

build_openroad.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OPENROAD_APP_BRANCH="master"
2020
INSTALL_PATH="$(pwd)/tools/install"
2121

2222
YOSYS_USER_ARGS=""
23-
YOSYS_ARGS="CONFIG=gcc"
23+
YOSYS_ARGS="CONFIG=clang ENABLE_NDEBUG=1"
2424

2525
OPENROAD_APP_USER_ARGS=""
2626
OPENROAD_APP_ARGS=""

docker/Dockerfile.builder

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@
44
# instead use etc/DockerHelper.sh
55
ARG fromImage=openroad/flow-ubuntu22.04-dev:latest
66

7-
FROM $fromImage
7+
FROM $fromImage AS openroad-builder-base
88

99
ARG numThreads=$(nproc)
1010

1111
COPY . /OpenROAD-flow-scripts
1212
WORKDIR /OpenROAD-flow-scripts
1313
1414
RUN ./build_openroad.sh --no_init --local --threads ${numThreads}
15+
16+
FROM $fromImage AS openroad-flow-scripts-base
17+
18+
COPY . /OpenROAD-flow-scripts
19+
20+
RUN rm -rf /OpenROAD-flow-scripts/tools /OpenROAD-flow-scripts/.git
21+
22+
COPY --from=openroad-builder-base /OpenROAD-flow-scripts/tools/install /OpenROAD-flow-scripts/tools/install
23+
24+
FROM $fromImage
25+
26+
COPY --from=openroad-flow-scripts-base /OpenROAD-flow-scripts /OpenROAD-flow-scripts
27+
WORKDIR /OpenROAD-flow-scripts

docker/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COPY InstallerOpenROAD.sh \
1515
ARG options=""
1616

1717
RUN ./DependencyInstaller.sh $options \
18-
&& rm -rf /tmp/installer
18+
&& rm -rf /tmp/installer /tmp/* /var/tmp/* /var/lib/apt/lists/*
1919

2020
ARG fromImage
2121

etc/DependencyInstaller.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ _installCommon() {
3030
fi
3131
local pkgs="pandas numpy firebase_admin click pyyaml"
3232
if [[ $(id -u) == 0 ]]; then
33-
pip3 install -U $pkgs
33+
pip3 install --no-cache-dir -U $pkgs
3434
else
35-
pip3 install --user -U $pkgs
35+
pip3 install --no-cache-dir --user -U $pkgs
3636
fi
3737
}
3838

@@ -70,7 +70,7 @@ _installUbuntuCleanUp() {
7070
_installUbuntuPackages() {
7171
export DEBIAN_FRONTEND="noninteractive"
7272
apt-get -y update
73-
apt-get -y install \
73+
apt-get -y install --no-install-recommends \
7474
libqt5multimediawidgets5 \
7575
libqt5svg5-dev \
7676
libqt5xmlpatterns5-dev \

etc/DockerHelper.sh

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ baseDir="$(pwd)"
88
# docker hub organization/user from where to pull/push images
99
org=openroad
1010

11+
DOCKER_CMD="docker"
12+
1113
_help() {
1214
cat <<EOF
1315
usage: $0 [CMD] [OPTIONS]
@@ -18,17 +20,19 @@ usage: $0 [CMD] [OPTIONS]
1820
push Push the docker image to Docker Hub
1921
2022
OPTIONS:
21-
-os=OS_NAME Choose beween ubuntu20.04 and ubuntu22.04 (default).
22-
-target=TARGET Choose target fo the Docker image:
23+
-os=OS_NAME Choose between ubuntu20.04 and ubuntu22.04 (default).
24+
-target=TARGET Choose target for the Docker image:
2325
'dev': os + packages to compile app
2426
'builder': os + packages to compile app +
2527
copy source code and build app
26-
-threads Max number of threads to use if compiling.
28+
-threads=N Max number of threads to use if compiling.
2729
Default = \$(nproc)
30+
-tag=TAG Use as the image tag. Default is git commit sha.
31+
-username=USERNAME Username to loging at the docker registry.
32+
-password=PASSWORD Password to loging at the docker registry.
2833
-ci Install CI tools in image
34+
-dry-run Do not push images to the repository
2935
-h -help Show this message and exits
30-
-username Docker Username
31-
-password Docker Password
3236
3337
EOF
3438
exit "${1:-1}"
@@ -77,7 +81,7 @@ _setup() {
7781

7882
_create() {
7983
echo "Create docker image ${imagePath} using ${file}"
80-
docker build \
84+
${DOCKER_CMD} build \
8185
--file "${file}" \
8286
--tag "${imagePath}" \
8387
${buildArgs} \
@@ -99,28 +103,42 @@ _push() {
99103
_help
100104
fi
101105

102-
docker login --username "${username}" --password "${password}"
106+
if [[ "${dryRun}" == 1 ]]; then
107+
echo "Skipping docker login"
108+
else
109+
${DOCKER_CMD} login --username "${username}" --password "${password}"
110+
fi
103111

104112
if [[ "${tag}" == "" ]]; then
105113
tag=$(./etc/DockerTag.sh -dev)
106114
fi
107115

108116
mkdir -p build
109-
./etc/DockerHelper.sh create -os=${os} -target=dev -tag=${tag} -ci \
110-
2>&1 | tee build/create-${os}-dev-${tag}.log
111117

112-
docker push "${imageName}:${tag}"
118+
if [[ "${target}" == "dev" ]]; then
119+
./etc/DockerHelper.sh create -os=${os} -target=dev -tag=${tag} -ci \
120+
2>&1 | tee build/create-${os}-dev-${tag}.log
121+
122+
if [[ "${dryRun}" != 1 ]]; then
123+
${DOCKER_CMD} push "${org}/flow-${os}-dev:${tag}"
124+
fi
125+
fi
113126

114127
if [[ "${target}" == "master" ]]; then
115128
tag=$(./etc/DockerTag.sh -master)
116129
# Create builder image
117-
./etc/DockerHelper.sh create -os=${os} -target=builder -tag=${tag} \
130+
./etc/DockerHelper.sh create -os=${os} -target=builder \
118131
2>&1 | tee build/create-${os}-${target}-${tag}.log
119132

120-
docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
121-
docker push ${org}/orfs:${tag}
122-
docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
123-
docker push ${org}/orfs:${tag}
133+
builderTag=${org}/flow-${os}-builder:${imageTag}
134+
orfsTag=${org}/orfs:${tag}
135+
echo "Renaming docker image: ${builderTag} -> ${orfsTag}"
136+
${DOCKER_CMD} tag ${builderTag} ${orfsTag}
137+
if [[ "${dryRun}" == 1 ]]; then
138+
echo "[DRY-RUN] ${DOCKER_CMD} push ${orfsTag}"
139+
else
140+
${DOCKER_CMD} push ${orfsTag}
141+
fi
124142
fi
125143
}
126144

@@ -153,6 +171,7 @@ target="dev"
153171
numThreads="-1"
154172
tag=""
155173
options=""
174+
dryRun=0
156175

157176
while [ "$#" -gt 0 ]; do
158177
case "${1}" in
@@ -162,6 +181,9 @@ while [ "$#" -gt 0 ]; do
162181
-ci )
163182
options="-ci"
164183
;;
184+
-dry-run )
185+
dryRun=1
186+
;;
165187
-os=* )
166188
os="${1#*=}"
167189
;;

0 commit comments

Comments
 (0)