Skip to content

Commit c9ddf5a

Browse files
committed
[#61287] workflows: Build and publish ORFS image
Signed-off-by: Illia Vysochyn <[email protected]>
1 parent bb95054 commit c9ddf5a

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed
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+
.

0 commit comments

Comments
 (0)