Skip to content

Commit

Permalink
Support Multi-Arch Docker Builds (The-OpenROAD-Project#1075)
Browse files Browse the repository at this point in the history
Tested on Apple M1 and AWS Graviton.

+ Add support for multiple-architecture building
    + Support for amd64, ppc64le and arm64v8 added
    + amd64 and arm64v8 will be automatically built by the CI

~ Major CI Overhauls
   ~ Added composite actions for the Docker build and setting environment variables
   ~ pdk build is now its own job, and amd64/aarch64 have a job each
   ~ matrix -> design_matrix, designs only tested on amd64 for performance reasons

~ run/build base docker images now pushed to Docker Hub based on a hash of dependency lists (to work with the buildx `docker-container` driver)

- Remove pandas (overkill for what we're using it for)

- Remove `cugr`, `drcu` *for now* (they're x86-64 Linux-only utilities)
  • Loading branch information
donn authored May 21, 2022
1 parent 0dc6fb7 commit 601eede
Show file tree
Hide file tree
Showing 39 changed files with 602 additions and 468 deletions.
59 changes: 59 additions & 0 deletions .github/actions/docker_build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Build
description: Build an OpenLane Docker Container
inputs:
arch:
description: "The Docker architecture/platform to build for"
required: true
default: "amd64"
dockerhub_user:
description: The input dockerhub user
required: false
default: ""
dockerhub_password:
description: The input dockerhub password
required: false
default: ""
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
- uses: ./.github/actions/set_env_variables

- name: Check If Going To Push An Image To Docker
shell: bash
run: |
export PUSHING=$(ruby -e 'if ("${{ github.event_name }}" != "pull_request" && "${{ inputs.dockerhub_user }}" != ""); print(1) else print(0) end')
echo "PUSHING=$PUSHING" >> $GITHUB_ENV
- name: Login to DockerHub
if: ${{ env.PUSHING == '1' }}
uses: docker/login-action@v1
with:
username: ${{ inputs.dockerhub_user }}
password: ${{ inputs.dockerhub_password }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Docker Build
shell: bash
run: |
export BUILD_IF_CANT_PULL=1
export BUILD_COMMAND="docker build"
if [ "$PUSHING" = "1" ]; then
export BUILD_IF_CANT_PULL_THEN_PUSH=1
export BUILD_COMMAND="docker buildx build --load --cache-from=type=gha --cache-to=type=gha,scope=${{ github.workflow }}}"
fi
export BUILD_ARCH=${{ inputs.arch }}
cd docker/ && make merge
- name: Export Docker Image
shell: bash
run: docker save -o /tmp/image-${{ inputs.arch }}.tar ${{ env.OPENLANE_IMAGE_NAME }}-${{ inputs.arch }}

- name: Upload Docker Image
uses: actions/upload-artifact@v2
with:
name: docker-image-${{ inputs.arch }}
path: /tmp/image-${{ inputs.arch }}.tar
20 changes: 20 additions & 0 deletions .github/actions/set_env_variables/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Set up environment variables
description: Sets up various environment variables required by various OpenLane steps.
runs:
using: "composite"
steps:
- name: Export Repo URL
shell: bash
run: echo "REPO_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV

- name: Export PDK ROOT
shell: bash
run: echo "PDK_ROOT=/usr/local/pdk" >> $GITHUB_ENV

- name: Export Branch Name
shell: bash
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Export Temp Image Name
shell: bash
run: echo "OPENLANE_IMAGE_NAME=openlane:intermediate" >> $GITHUB_ENV
2 changes: 1 addition & 1 deletion .github/scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import subprocess
from gh import gh

threads_used = int(subprocess.check_output(["nproc"]).decode("utf-8")) - 1
threads_used = os.cpu_count() - 1
test_name = "ci_test"
design = sys.argv[1]
print(f"Running on designs {test_name} using {threads_used} threads…")
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Lint
on:
# Runs on pushes to all but CID-latest-branches
# CID-latest branches automatically create PRs, let's just let the tests run on those
# Runs on all pushes to branches
push:
# Runs on Pull Requests
# Runs on all PRs
pull_request:
# Runs manually
# Manual Dispatch
workflow_dispatch:

jobs:
Expand Down
Loading

0 comments on commit 601eede

Please sign in to comment.