-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (155 loc) · 6.18 KB
/
main.yaml
File metadata and controls
175 lines (155 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
on:
push:
branches:
- 'main'
- 'latest-release'
pull_request:
merge_group:
repository_dispatch:
types: [backend-test]
workflow_dispatch:
inputs:
release:
description: Test with the release lock
type: boolean
default: false
ENVIRONMENT:
required: true
type: environment
backend_version:
description: 'Backend version/tag to test against (overrides vars.CHIPFLOW_BACKEND_VERSION)'
required: false
type: string
build_mode:
description: 'Build mode (synth_only is faster, full includes P&R and GDS)'
required: false
type: choice
default: synth_only
options:
- synth_only
- full
env:
lock_pdm: ${{ ! (github.ref_name == 'refs/heads/latest-release' || inputs.release) }}
BACKEND_VERSION: ${{ inputs.backend_version || github.event.client_payload.backend_version || vars.CHIPFLOW_BACKEND_VERSION }}
# repository_dispatch (backend-test) always uses full; workflow_dispatch uses input; others default to synth_only
BUILD_MODE: ${{ github.event_name == 'repository_dispatch' && 'full' || inputs.build_mode || 'synth_only' }}
name: CI
run-name: ${{ github.event_name == 'repository_dispatch' && format('Backend Test - {0}', github.event.client_payload.backend_version) || (inputs.backend_version && format('CI - Backend {0}', inputs.backend_version) || (inputs.release && 'Release' || 'CI')) }}
jobs:
submit:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT || 'staging' }}
strategy:
matrix:
design: ['mcu_soc', 'minimal']
steps:
- name: Parse PR body for backend version override
id: pr-config
if: github.event_name == 'pull_request'
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
# Extract BACKEND_VERSION from PR body (format: BACKEND_VERSION: <value>)
if [[ "$PR_BODY" =~ BACKEND_VERSION:[[:space:]]*([^[:space:]]+) ]]; then
echo "backend_version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
echo "Found BACKEND_VERSION override: ${BASH_REMATCH[1]}"
fi
- name: Check out source code
uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version-file: pyproject.toml
cache-dependency-path: pyproject.toml
cache: true
- name: Install dependencies with multirepo
uses: chipflow/pdm-multirepo@v1
- name: Cache ~/.cache directory
uses: actions/cache@v4
with:
path: ~/.cache
key: cache-${{ runner.os }}-${{ matrix.design }}-${{ hashFiles('**/pyproject.toml', '**/pdm.lock') }}
restore-keys: |
cache-${{ runner.os }}-${{ matrix.design }}-
cache-${{ runner.os }}-
- name: Lock pins
working-directory: ./${{ matrix.design }}
run: pdm run chipflow pin lock
- name: Submit to cloud backend
working-directory: ./${{ matrix.design }}
run: pdm run chipflow -vv silicon submit --wait
env:
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}
CHIPFLOW_API_ORIGIN: ${{ vars.CHIPFLOW_API_ORIGIN }}
# Priority: PR body override > workflow input > repository_dispatch > vars
CHIPFLOW_BACKEND_VERSION: ${{ steps.pr-config.outputs.backend_version || env.BACKEND_VERSION }}
CHIPFLOW_BUILD_MODE: ${{ env.BUILD_MODE }}
test:
runs-on: ubuntu-latest
strategy:
matrix:
design: ['mcu_soc', 'minimal']
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version-file: pyproject.toml
cache-dependency-path: pyproject.toml
cache: true
- name: Install dependencies with multirepo
uses: chipflow/pdm-multirepo@v1
- name: Cache ~/.cache directory
uses: actions/cache@v4
with:
path: ~/.cache
key: cache-${{ runner.os }}-${{ matrix.design }}-${{ hashFiles('**/pyproject.toml', '**/pdm.lock') }}
restore-keys: |
cache-${{ runner.os }}-${{ matrix.design }}-
cache-${{ runner.os }}-
- name: Lock pins
working-directory: ./${{ matrix.design }}
run: pdm run chipflow pin lock
- name: Run unit tests
working-directory: ./${{ matrix.design }}
run: |
pdm test
- name: Run simulation tests
working-directory: ./${{ matrix.design }}
run: |
pdm sim-check
- name: Test submit dry run
working-directory: ./${{ matrix.design }}
run: |
pdm run chipflow silicon submit --dry-run
report-status:
# Report status back to chipflow-backend for repository_dispatch triggers
if: always() && github.event_name == 'repository_dispatch'
needs: [submit, test]
runs-on: ubuntu-latest
steps:
- name: Determine overall status
id: status
run: |
if [[ "${{ needs.submit.result }}" == "success" && "${{ needs.test.result }}" == "success" ]]; then
echo "state=success" >> $GITHUB_OUTPUT
echo "description=All integration tests passed" >> $GITHUB_OUTPUT
else
echo "state=failure" >> $GITHUB_OUTPUT
echo "description=Integration tests failed (submit: ${{ needs.submit.result }}, test: ${{ needs.test.result }})" >> $GITHUB_OUTPUT
fi
- name: Report status to chipflow-backend
env:
GH_TOKEN: ${{ secrets.BACKEND_STATUS_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/ChipFlow/chipflow-backend/statuses/${{ github.event.client_payload.backend_sha }} \
-f state='${{ steps.status.outputs.state }}' \
-f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='${{ steps.status.outputs.description }}' \
-f context='chipflow-examples/backend-test'