Skip to content

Commit c0c5bc6

Browse files
committed
ms-openroad: GitHub Actions Azure build+run
1 parent 3b0048d commit c0c5bc6

File tree

4 files changed

+197
-1
lines changed

4 files changed

+197
-1
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ flow/vars*.gdb
2525
# Common temp files
2626
flow/*.log
2727

28+
# Git metadata (can be huge; not needed in image)
29+
.git
30+
2831
# Platforms
2932
# Reduce Docker build context for ms-openroad
3033
flow/platforms/*
@@ -33,6 +36,16 @@ flow/platforms/*
3336
!flow/platforms/nangate45/
3437
!flow/platforms/nangate45/**
3538

39+
# Designs
40+
# Reduce Docker build context for ms-openroad (only need nangate45/gcd).
41+
flow/designs/*
42+
!flow/designs/src/
43+
!flow/designs/src/gcd/
44+
!flow/designs/src/gcd/**
45+
!flow/designs/nangate45/
46+
!flow/designs/nangate45/gcd/
47+
!flow/designs/nangate45/gcd/**
48+
3649

3750
# network
3851
.nfs*
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: ms-openroad (Azure gcd)
2+
3+
on:
4+
push:
5+
branches:
6+
- microsoft-openroad
7+
paths:
8+
- ".dockerignore"
9+
- ".github/workflows/ms-openroad-azure-gcd.yml"
10+
- "env.sh"
11+
- "flow/Makefile"
12+
- "flow/scripts/**"
13+
- "flow/util/**"
14+
- "flow/designs/nangate45/gcd/**"
15+
- "flow/designs/src/gcd/**"
16+
- "flow/platforms/common/**"
17+
- "flow/platforms/nangate45/**"
18+
- "ms-openroad/**"
19+
workflow_dispatch: {}
20+
21+
permissions:
22+
contents: read
23+
id-token: write
24+
25+
concurrency:
26+
group: ms-openroad-azure-gcd-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
env:
30+
# Azure environment (ms-openroad subscription)
31+
AZ_RG: orfs-rg-42d38e
32+
AZ_ACR_NAME: orfs42d38e
33+
AZ_STORAGE_ACCOUNT: orfs42d38esa
34+
AZ_FILE_SHARE: orfs-share
35+
AZ_IDENTITY_ID: /subscriptions/ea2e8ed3-281b-4422-a24d-41d87cd070c3/resourcegroups/orfs-rg-42d38e/providers/Microsoft.ManagedIdentity/userAssignedIdentities/orfs-aci-mi-42d38e
36+
37+
# GitHub OIDC → Azure federated credential (no secrets)
38+
AZURE_TENANT_ID: 8a198873-4fec-4e76-8182-ca479edbbd60
39+
AZURE_SUBSCRIPTION_ID: ea2e8ed3-281b-4422-a24d-41d87cd070c3
40+
AZURE_CLIENT_ID: b6b68521-9572-49e8-8dd7-0cacad242f24
41+
42+
# Flow defaults
43+
IMAGE_REPO: orfs-flow
44+
DESIGN: gcd
45+
PLATFORM: nangate45
46+
FLOW_VARIANT: base
47+
CPU: "4"
48+
MEMORY_GB: "16"
49+
SKIP_CTS_REPAIR_TIMING: "1"
50+
51+
jobs:
52+
build-and-run:
53+
runs-on: ubuntu-latest
54+
timeout-minutes: 180
55+
steps:
56+
- name: Azure login (OIDC)
57+
uses: azure/login@v2
58+
with:
59+
client-id: ${{ env.AZURE_CLIENT_ID }}
60+
tenant-id: ${{ env.AZURE_TENANT_ID }}
61+
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
62+
63+
- name: Build image in ACR from this branch
64+
shell: bash
65+
run: |
66+
set -euo pipefail
67+
short_sha="${GITHUB_SHA::12}"
68+
image_tag="sha-${short_sha}"
69+
context_url="https://github.com/${GITHUB_REPOSITORY}.git#${GITHUB_REF_NAME}"
70+
71+
echo "ACR build:"
72+
echo " registry=${AZ_ACR_NAME}"
73+
echo " context=${context_url}"
74+
echo " dockerfile=ms-openroad/Dockerfile"
75+
echo " tags=${IMAGE_REPO}:microsoft-openroad, ${IMAGE_REPO}:${image_tag}"
76+
77+
az acr build \
78+
--resource-group "${AZ_RG}" \
79+
--registry "${AZ_ACR_NAME}" \
80+
--file ms-openroad/Dockerfile \
81+
--image "${IMAGE_REPO}:microsoft-openroad" \
82+
--image "${IMAGE_REPO}:${image_tag}" \
83+
--build-arg "VCS_REF=${GITHUB_SHA}" \
84+
--build-arg "BASE_IMAGE=openroad/orfs:latest" \
85+
"${context_url}"
86+
87+
- name: Run nangate45/gcd on Azure Container Instances
88+
shell: bash
89+
run: |
90+
set -euo pipefail
91+
92+
short_sha="${GITHUB_SHA::12}"
93+
image_tag="sha-${short_sha}"
94+
acr_login_server="$(az acr show -n "${AZ_ACR_NAME}" --query loginServer -o tsv)"
95+
image_fqn="${acr_login_server}/${IMAGE_REPO}:${image_tag}"
96+
97+
run_id="${DESIGN}-${short_sha}-${GITHUB_RUN_ID}"
98+
work_home="/work/${run_id}"
99+
100+
aci_name_raw="orfs-${run_id}"
101+
aci_name="$(echo "${aci_name_raw}" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9-' '-' | cut -c1-63 | sed 's/^-//; s/-$//')"
102+
103+
storage_key="$(az storage account keys list \
104+
--account-name "${AZ_STORAGE_ACCOUNT}" \
105+
--resource-group "${AZ_RG}" \
106+
--query '[0].value' -o tsv)"
107+
108+
echo "ACI run:"
109+
echo " rg=${AZ_RG}"
110+
echo " name=${aci_name}"
111+
echo " image=${image_fqn}"
112+
echo " cpu=${CPU} memory_gb=${MEMORY_GB}"
113+
echo " work_home=${work_home}"
114+
115+
az container create \
116+
--resource-group "${AZ_RG}" \
117+
--name "${aci_name}" \
118+
--image "${image_fqn}" \
119+
--os-type Linux \
120+
--restart-policy Never \
121+
--cpu "${CPU}" \
122+
--memory "${MEMORY_GB}" \
123+
--assign-identity "${AZ_IDENTITY_ID}" \
124+
--acr-identity "${AZ_IDENTITY_ID}" \
125+
--azure-file-volume-account-name "${AZ_STORAGE_ACCOUNT}" \
126+
--azure-file-volume-account-key "${storage_key}" \
127+
--azure-file-volume-share-name "${AZ_FILE_SHARE}" \
128+
--azure-file-volume-mount-path /work \
129+
--command-line "/usr/local/bin/run-orfs.sh" \
130+
--environment-variables \
131+
DESIGN="${DESIGN}" \
132+
PLATFORM="${PLATFORM}" \
133+
FLOW_VARIANT="${FLOW_VARIANT}" \
134+
WORK_HOME="${work_home}" \
135+
NPROC="${CPU}" \
136+
SKIP_CTS_REPAIR_TIMING="${SKIP_CTS_REPAIR_TIMING}" \
137+
1>/dev/null
138+
139+
echo "Waiting for completion..."
140+
exit_code=""
141+
while true; do
142+
read -r group_state container_state exit_code < <(az container show \
143+
--resource-group "${AZ_RG}" \
144+
--name "${aci_name}" \
145+
--query '{g:instanceView.state, c:containers[0].instanceView.currentState.state, e:containers[0].instanceView.currentState.exitCode}' \
146+
-o tsv)
147+
148+
if [[ "${exit_code:-}" == "None" ]]; then
149+
exit_code=""
150+
fi
151+
152+
echo " group=${group_state} container=${container_state} exitCode=${exit_code:-}"
153+
154+
if [[ "${container_state}" == "Terminated" || "${group_state}" == "Failed" || "${group_state}" == "Succeeded" || "${group_state}" == "Terminated" || "${group_state}" == "Stopped" ]]; then
155+
break
156+
fi
157+
sleep 20
158+
done
159+
160+
echo ""
161+
echo "Logs:"
162+
az container logs --resource-group "${AZ_RG}" --name "${aci_name}" || true
163+
164+
if [[ -z "${exit_code:-}" ]]; then
165+
exit_code="$(az container show --resource-group "${AZ_RG}" --name "${aci_name}" --query 'containers[0].instanceView.currentState.exitCode' -o tsv 2>/dev/null || true)"
166+
fi
167+
exit_code="${exit_code:-0}"
168+
169+
echo ""
170+
echo "Artifacts are in Azure Files share '${AZ_FILE_SHARE}' under: ${run_id}/"
171+
172+
if [[ "${exit_code}" != "0" ]]; then
173+
echo "ERROR: container exited with code ${exit_code}" >&2
174+
exit "${exit_code}"
175+
fi

ms-openroad/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
ARG BASE_IMAGE=openroad/orfs:latest
77
FROM ${BASE_IMAGE}
88

9+
ARG VCS_REF=unknown
10+
LABEL org.opencontainers.image.revision=$VCS_REF
11+
912
WORKDIR /OpenROAD-flow-scripts
1013

1114
# Overlay flow scripts from this repo/branch
@@ -14,14 +17,16 @@ COPY env.sh /OpenROAD-flow-scripts/env.sh
1417
COPY flow/Makefile /OpenROAD-flow-scripts/flow/Makefile
1518
COPY flow/scripts /OpenROAD-flow-scripts/flow/scripts
1619
COPY flow/util /OpenROAD-flow-scripts/flow/util
17-
COPY flow/designs /OpenROAD-flow-scripts/flow/designs
20+
COPY flow/designs/src/gcd /OpenROAD-flow-scripts/flow/designs/src/gcd
21+
COPY flow/designs/nangate45/gcd /OpenROAD-flow-scripts/flow/designs/nangate45/gcd
1822
COPY flow/platforms/common /OpenROAD-flow-scripts/flow/platforms/common
1923
COPY flow/platforms/nangate45 /OpenROAD-flow-scripts/flow/platforms/nangate45
2024

2125
COPY ms-openroad/run-orfs.sh /usr/local/bin/run-orfs.sh
2226
COPY ms-openroad/orfs-extra.mk /usr/local/share/orfs-extra.mk
2327

2428
RUN chmod +x /usr/local/bin/run-orfs.sh \
29+
&& echo "${VCS_REF}" >/OpenROAD-flow-scripts/.ms-openroad-revision \
2530
&& chmod o+rw -R /OpenROAD-flow-scripts
2631

2732
ENTRYPOINT ["/usr/local/bin/run-orfs.sh"]

ms-openroad/run-orfs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ log "DESIGN_CONFIG=${DESIGN_CONFIG}"
4242
log "FLOW_VARIANT=${FLOW_VARIANT}"
4343
log "NPROC=${NPROC}"
4444
log "MAKE_TARGET=${MAKE_TARGET:-<default>}"
45+
if [[ -f /OpenROAD-flow-scripts/.ms-openroad-revision ]]; then
46+
log "IMAGE_REVISION=$(cat /OpenROAD-flow-scripts/.ms-openroad-revision)"
47+
fi
4548

4649
make_args=(
4750
"DESIGN_CONFIG=${DESIGN_CONFIG}"

0 commit comments

Comments
 (0)