Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into secure-pin-swap-fix…
Browse files Browse the repository at this point in the history
…-flow
  • Loading branch information
precisionmoon committed Jul 8, 2024
2 parents 2914ac9 + 56eb1b9 commit af2758c
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 289 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-cron-test-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:
sudo service docker restart
- name: Run installer
run: |
./etc/DockerHelper.sh create -target=dev -os=${{ matrix.os }}
./etc/DockerHelper.sh create -target=dev -os=${{ matrix.os }} -tag=latest
- name: Build project
run: |
./etc/DockerHelper.sh create -target=builder -os=${{ matrix.os }}
./etc/DockerHelper.sh create -target=builder -os=${{ matrix.os }} -tag=latest
- name: Test build
run: |
cmd="source ./env.sh ; yosys -help ; openroad -help ; make -C flow ;"
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/github-actions-publish-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build and publish ORFS images
on:
push:
paths:
- etc/DependencyInstaller.sh
- etc/DockerHelper.sh
- .github/workflows/github-actions-publish-docker-images.yml
- build_openroad.sh
- env.sh
- flow/Makefile
- docker/Dockerfile.dev
- docker/Dockerfile.builder
pull_request:
paths:
- etc/DependencyInstaller.sh
- etc/DockerHelper.sh
- .github/workflows/github-actions-publish-docker-images.yml
- build_openroad.sh
- env.sh
- flow/Makefile
- docker/Dockerfile.dev
- docker/Dockerfile.builder

jobs:
buildDependenciesImage:
strategy:
fail-fast: false
matrix:
os: [["ubuntu20.04", "ubuntu:20.04"], ["ubuntu22.04", "ubuntu:22.04"]]
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: recursive

- name: Set environment variables
run: |
echo "IMAGE_DEPS=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-dev/${{ matrix.os[0] }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry (GHCR)
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: gha
password: ${{ github.token }}

- name: Copy OpenROAD installer
run: cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh

- name: Build and export dependencies image
uses: docker/build-push-action@v6
with:
context: etc
push: true
tags: ${{ env.IMAGE_DEPS }}:latest
file: docker/Dockerfile.dev
build-args: |
fromImage=${{ matrix.os[1] }}
numThreads=$(nproc)
cache-from: type=registry,ref=${{ env.IMAGE_DEPS }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_DEPS }}:buildcache,mode=max

buildORFSImage:
needs: buildDependenciesImage
strategy:
fail-fast: false
matrix:
os: ["ubuntu20.04", "ubuntu22.04"]
runs-on: ubuntu-latest
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false

- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: recursive

- name: Set environment variables
run: |
echo "IMAGE=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')/${{ matrix.os }}" >> $GITHUB_ENV
echo "IMAGE_DEPS=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-dev/${{ matrix.os }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# We don't use the build-push-action here because it hangs
- name: Build ORFS image
run: |
docker buildx build \
--load \
--build-arg fromImage=${{ env.IMAGE_DEPS }}:latest \
--build-arg numThreads=$(nproc) \
--cache-from type=registry,ref=${{ env.IMAGE }}:buildcache \
--tag ${{ env.IMAGE }}:latest \
--file docker/Dockerfile.builder \
.
- name: Test build
run: |
cmd="source ./env.sh && yosys -help && openroad -help && make -C flow ;"
docker run ${{ env.IMAGE }}:latest /bin/bash -c "${cmd}"
- name: Login to GitHub Container Registry (GHCR)
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: gha
password: ${{ github.token }}

- name: Export ORFS image
run: |
docker buildx build \
--build-arg fromImage=${{ env.IMAGE_DEPS }}:latest \
--build-arg numThreads=$(nproc) \
--cache-from type=registry,ref=${{ env.IMAGE }}:buildcache \
--cache-to type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max \
--tag ${{ env.IMAGE }}:latest \
--file docker/Dockerfile.builder \
--push \
.
2 changes: 1 addition & 1 deletion build_openroad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OPENROAD_APP_BRANCH="master"
INSTALL_PATH="$(pwd)/tools/install"

YOSYS_USER_ARGS=""
YOSYS_ARGS="CONFIG=gcc"
YOSYS_ARGS="CONFIG=clang ENABLE_NDEBUG=1"

OPENROAD_APP_USER_ARGS=""
OPENROAD_APP_ARGS=""
Expand Down
15 changes: 14 additions & 1 deletion docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@
# instead use etc/DockerHelper.sh
ARG fromImage=openroad/flow-ubuntu22.04-dev:latest

FROM $fromImage
FROM $fromImage AS openroad-builder-base

ARG numThreads=$(nproc)

COPY . /OpenROAD-flow-scripts
WORKDIR /OpenROAD-flow-scripts
RUN ./build_openroad.sh --no_init --local --threads ${numThreads}

FROM $fromImage AS openroad-flow-scripts-base

COPY . /OpenROAD-flow-scripts

RUN rm -rf /OpenROAD-flow-scripts/tools /OpenROAD-flow-scripts/.git

COPY --from=openroad-builder-base /OpenROAD-flow-scripts/tools/install /OpenROAD-flow-scripts/tools/install

FROM $fromImage

COPY --from=openroad-flow-scripts-base /OpenROAD-flow-scripts /OpenROAD-flow-scripts
WORKDIR /OpenROAD-flow-scripts
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY InstallerOpenROAD.sh \
ARG options=""

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

ARG fromImage

Expand Down
6 changes: 3 additions & 3 deletions etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ _installCommon() {
fi
local pkgs="pandas numpy firebase_admin click pyyaml"
if [[ $(id -u) == 0 ]]; then
pip3 install -U $pkgs
pip3 install --no-cache-dir -U $pkgs
else
pip3 install --user -U $pkgs
pip3 install --no-cache-dir --user -U $pkgs
fi
}

Expand Down Expand Up @@ -70,7 +70,7 @@ _installUbuntuCleanUp() {
_installUbuntuPackages() {
export DEBIAN_FRONTEND="noninteractive"
apt-get -y update
apt-get -y install \
apt-get -y install --no-install-recommends \
libqt5multimediawidgets5 \
libqt5svg5-dev \
libqt5xmlpatterns5-dev \
Expand Down
52 changes: 37 additions & 15 deletions etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ baseDir="$(pwd)"
# docker hub organization/user from where to pull/push images
org=openroad

DOCKER_CMD="docker"

_help() {
cat <<EOF
usage: $0 [CMD] [OPTIONS]
Expand All @@ -18,17 +20,19 @@ usage: $0 [CMD] [OPTIONS]
push Push the docker image to Docker Hub
OPTIONS:
-os=OS_NAME Choose beween ubuntu20.04 and ubuntu22.04 (default).
-target=TARGET Choose target fo the Docker image:
-os=OS_NAME Choose between ubuntu20.04 and ubuntu22.04 (default).
-target=TARGET Choose target for 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.
-threads=N Max number of threads to use if compiling.
Default = \$(nproc)
-tag=TAG Use as the image tag. Default is git commit sha.
-username=USERNAME Username to loging at the docker registry.
-password=PASSWORD Password to loging at the docker registry.
-ci Install CI tools in image
-dry-run Do not push images to the repository
-h -help Show this message and exits
-username Docker Username
-password Docker Password
EOF
exit "${1:-1}"
Expand Down Expand Up @@ -77,7 +81,7 @@ _setup() {

_create() {
echo "Create docker image ${imagePath} using ${file}"
docker build \
${DOCKER_CMD} build \
--file "${file}" \
--tag "${imagePath}" \
${buildArgs} \
Expand All @@ -99,28 +103,42 @@ _push() {
_help
fi

docker login --username "${username}" --password "${password}"
if [[ "${dryRun}" == 1 ]]; then
echo "Skipping docker login"
else
${DOCKER_CMD} login --username "${username}" --password "${password}"
fi

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

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

docker push "${imageName}:${tag}"
if [[ "${target}" == "dev" ]]; then
./etc/DockerHelper.sh create -os=${os} -target=dev -tag=${tag} -ci \
2>&1 | tee build/create-${os}-dev-${tag}.log

if [[ "${dryRun}" != 1 ]]; then
${DOCKER_CMD} push "${org}/flow-${os}-dev:${tag}"
fi
fi

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

docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
docker push ${org}/orfs:${tag}
docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
docker push ${org}/orfs:${tag}
builderTag=${org}/flow-${os}-builder:${imageTag}
orfsTag=${org}/orfs:${tag}
echo "Renaming docker image: ${builderTag} -> ${orfsTag}"
${DOCKER_CMD} tag ${builderTag} ${orfsTag}
if [[ "${dryRun}" == 1 ]]; then
echo "[DRY-RUN] ${DOCKER_CMD} push ${orfsTag}"
else
${DOCKER_CMD} push ${orfsTag}
fi
fi
}

Expand Down Expand Up @@ -153,6 +171,7 @@ target="dev"
numThreads="-1"
tag=""
options=""
dryRun=0

while [ "$#" -gt 0 ]; do
case "${1}" in
Expand All @@ -162,6 +181,9 @@ while [ "$#" -gt 0 ]; do
-ci )
options="-ci"
;;
-dry-run )
dryRun=1
;;
-os=* )
os="${1#*=}"
;;
Expand Down
Loading

0 comments on commit af2758c

Please sign in to comment.