From 6f2c0e48ccdf62fad6dc46e1cd222a07568add45 Mon Sep 17 00:00:00 2001 From: Illia Vysochyn Date: Tue, 2 Jul 2024 12:23:07 +0200 Subject: [PATCH] [#61287] WIP: workflows: Refactor ORFS image workflow Signed-off-by: Illia Vysochyn --- .../github-actions-publish-docker-images.yml | 121 ++++++++++-------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/.github/workflows/github-actions-publish-docker-images.yml b/.github/workflows/github-actions-publish-docker-images.yml index d72d38791f..c50b26b619 100644 --- a/.github/workflows/github-actions-publish-docker-images.yml +++ b/.github/workflows/github-actions-publish-docker-images.yml @@ -1,39 +1,34 @@ -name: Build and publish ORFS image +name: Build and publish ORFS images on: - schedule: - - cron: "0 8 * * SUN" 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' + - 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' - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + - 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: - testInstaller: + buildDependenciesImage: strategy: fail-fast: false matrix: os: [["ubuntu20.04", "ubuntu:20.04"], ["ubuntu22.04", "ubuntu:22.04"]] runs-on: ubuntu-latest env: - IMAGE: ghcr.io/antmicro/openroad-flow-scripts-test-cache/${{ matrix.os[0] }} IMAGE_DEPS: ghcr.io/antmicro/openroad-flow-scripts-test-cache-deps/${{ matrix.os[0] }} steps: - name: Check out repository code @@ -42,16 +37,6 @@ jobs: fetch-depth: 1 submodules: recursive - - name: Network Setup - run: | - sudo apt-get update - sudo apt-get install -y bridge-utils - sudo pkill docker - sudo iptables -t nat -F - sudo ifconfig docker0 down - sudo brctl delbr docker0 - sudo service docker restart - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -79,39 +64,63 @@ jobs: 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 + env: + IMAGE: ghcr.io/antmicro/openroad-flow-scripts-test-cache/${{ matrix.os }} + IMAGE_DEPS: ghcr.io/antmicro/openroad-flow-scripts-test-cache-deps/${{ matrix.os }} + steps: - name: Free Disk Space uses: jlumbroso/free-disk-space@main with: - # We clear docker images as docker buildx driver is isolated tool-cache: false - - name: Build ORFS image - uses: docker/build-push-action@v6 + - name: Check out repository code + uses: actions/checkout@v3 with: - context: . - load: true - push: false - tags: ${{ env.IMAGE }}:latest - file: docker/Dockerfile.builder - build-args: | - fromImage=${{ env.IMAGE_DEPS }}:latest - numThreads=$(nproc) - cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache + fetch-depth: 1 + submodules: recursive + + - 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 \ + --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: Export ORFS image - uses: docker/build-push-action@v6 + - name: Login to GitHub Container Registry (GHCR) + if: github.event_name != 'pull_request' && github.repository == 'antmicro/OpenROAD-flow-scripts' + uses: docker/login-action@v2 with: - context: . - push: true - tags: ${{ env.IMAGE }}:latest - file: docker/Dockerfile.builder - build-args: | - fromImage=${{ env.IMAGE_DEPS }}rlatest - numThreads=$(nproc) - cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache - cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max + 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 \ + .