-
Notifications
You must be signed in to change notification settings - Fork 7
404 lines (364 loc) · 16.1 KB
/
digest_sim.yml
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name: 'Fetch and Test SIM Model changes'
on:
#push:
repository_dispatch:
types: [digest_latest_Release]
env:
internal_model_path: "sim_models_internal/verilog/*.v sim_models_internal/verilog/*/*.v blackbox_models/*.v tb/*/*.v tb/*/*.sv specs_internal/*.yaml"
external_model_path: "sim_models/verilog/*.v"
jobs:
SIM_Model_Digest_and_test_internal:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
scenarios:
- pass
- fail
env:
MODE: ${{ matrix.scenarios }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: switch to branch
run: |
git branch -a
BRANCH='${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_internal'
set +e
git ls-remote --exit-code --heads origin $BRANCH >/dev/null 2>&1
EXIT_CODE=$?
if [[ $EXIT_CODE == '0' ]]; then
echo "Git branch '$BRANCH' exists in the remote repository"
main_last_commit=`git log -1 --pretty=format:"%H"`
git checkout $BRANCH
git pull origin $BRANCH
git reset --hard $main_last_commit
elif [[ $EXIT_CODE == '2' ]]; then
echo "Git branch '$BRANCH' does not exist in the remote repository"
fi
- name: Install Simulator
run: sudo apt install -y iverilog
- name: Download Latest Release
uses: robinraju/[email protected]
with:
repository: "${{ secrets.SRC_RELEASE_REPO }}"
latest: true
fileName: "generic-*.tar.gz"
token: "${{ secrets.SIM_MODEL_DOWNLOAD }}"
- name: Unzip Release
run: |
cd ..
echo "payload: ${{ github.event.client_payload.new_release }}"
for file in $(ls -1 $GITHUB_WORKSPACE/*.tar.gz)
do
echo $file
tar -xvf $file
done
ls -l
- name: tree
run: tree && cd .. && tree
- name: find the diff
run: |
python3 primitive_parser.py --src=./../sim_models_internal/verilog/ --dest=./sim_models_internal/verilog/ --release=${{ github.event.client_payload.new_release }}
- name: reverse the opposite changes
id: do_push
run: |
# logic: in case of pass, pass the file list from dump by python script to git add while in fail pass the same list to git checkout
case "${{ matrix.scenarios }}" in
"pass")
echo "updates are from ${{ matrix.scenarios }}"
passfile="Pass_prim.txt"
if [ -f "$passfile" ]; then
echo "Pass file found"
all_files=`cat $passfile`
echo $all_files
echo "path_to_commit=$all_files" >> $GITHUB_ENV
echo "has_changed=true" >> $GITHUB_OUTPUT
fi
;;
"fail")
echo "updates are from ${{ matrix.scenarios }}"
passfile="Pass_prim.txt"
if [ -f "$passfile" ]; then
echo "Pass file found"
all_files=`cat $passfile`
echo $all_files
# revert the changes that are passing so we have all failing files only
git checkout $all_files
if [ $? -eq 0 ]; then
echo "Checkout successful."
else
echo "Checkout failed for file: $passfile"
fi
fi
echo "path_to_commit=${{ env.internal_model_path}}" >> $GITHUB_ENV
any_change=`git status --porcelain ${{ env.internal_model_path}}`
if [ ! -z "$any_change" ]
then
echo "has_changed=true" >> $GITHUB_OUTPUT
fi
;;
*)
echo "Invalid value: ${{ matrix.scenarios }}"
;;
esac
- name: cat email.txt
if: success() || failure()
id: pr_decision
run: |
if [ -f email.txt ]
then
cat email.txt
else
echo "Kindly check your python script as it failed somewhere. Link to fail Github Action is ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> email.txt
fi
if [ -f subject.txt ]
then
cat subject.txt
else
echo "${{ github.repository }} Python Script failed to find the diff" >> subject.txt
fi
case "${{ matrix.scenarios }}" in
"pass")
echo "updates are from ${{ matrix.scenarios }}"
echo "email_ids=${{ secrets.ONLY_EMAIL_ID }}" >> $GITHUB_ENV
;;
"fail")
echo "updates are from ${{ matrix.scenarios }}"
echo "email_ids=${{ secrets.EMAIL_IDS }}" >> $GITHUB_ENV
#echo "email_ids=${{ secrets.ONLY_EMAIL_ID }}" >> $GITHUB_ENV
;;
*)
echo "Invalid value: ${{ matrix.scenarios }}"
;;
esac
- name: blackbox simulation
run: |
set +e
iverilog -g2012 ./blackbox_models/cell_sim_blackbox.v
if [ $? -eq 0 ]
then
echo -e "'\n\tBlack Box Compilation has passed\n" >> email.txt
else
echo -e "'\n\tBlack Box Compilation has failed\n" >> email.txt
fi
- name: show current status
run:
git status
- name: Add and Push
uses: GuillaumeFalourd/[email protected]
if: contains(steps.do_push.outputs.has_changed, 'true')
with:
email: [email protected]
name: NadeemYaseen
commit_message: Added SIM change files from ${{ github.event.client_payload.new_release }}
files: "${{ env.path_to_commit }}"
target_branch: ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_internal
access_token: ${{ secrets.SIM_MODEL_DOWNLOAD }}
force: true
# if all pass then create PR.
- name: Create PR
if: ${{ matrix.scenarios == 'pass' && steps.do_push.outputs.has_changed == 'true' }}
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_internal # branch having xmls files
destination_branch: "main" # name of branch on which PR go
pr_title: "Pulling SIMs release ${{ github.event.client_payload.new_release }} into main. " # Title of pull request
pr_body: "An automated PR to check in New SIMs Release. Click on the link to see regression results ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Full markdown support, requires pr_title
#pr_reviewer: "moinijaz" # Comma-separated list (no spaces)
pr_reviewer: "ashrafnisar"
pr_assignee: "NadeemYaseen" # Comma-separated list (no spaces)
pr_label: "openfpga_castor_pd_sim" # Comma-separated list (no spaces)
pr_allow_empty: true # Creates pull request even if there are no changes
github_token: ${{ secrets.SIM_MODEL_DOWNLOAD }}
- name: Send Email
if: success() || failure()
uses: dawidd6/[email protected]
with:
server_address: ${{secrets.MAIL_SERVER}}
server_port: ${{secrets.MAIL_SERVERPORT}}
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: "${{ env.SUBJECT }} for release ${{ github.event.client_payload.new_release }}. Changes are in branch ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_internal"
body: file://email.txt
#to: [email protected]
to: "${{ env.email_ids }}"
from: ${{secrets.MAIL_USERNAME}}
#attachments: and2_verilog.tar.gz
# --------------------------------------------------------------- #
SIM_Model_Digest_and_test_external:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
scenarios:
- pass
- fail
env:
MODE: ${{ matrix.scenarios }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: switch to branch
run: |
git branch -a
BRANCH='${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_external'
set +e
git ls-remote --exit-code --heads origin $BRANCH >/dev/null 2>&1
EXIT_CODE=$?
if [[ $EXIT_CODE == '0' ]]; then
echo "Git branch '$BRANCH' exists in the remote repository"
main_last_commit=`git log -1 --pretty=format:"%H"`
git checkout $BRANCH
git pull origin $BRANCH
git reset --hard $main_last_commit
elif [[ $EXIT_CODE == '2' ]]; then
echo "Git branch '$BRANCH' does not exist in the remote repository"
fi
- name: Install Simulator
run: sudo apt install -y iverilog
- name: Download Latest Release
uses: robinraju/[email protected]
with:
repository: "${{ secrets.SRC_RELEASE_REPO }}"
latest: true
fileName: "generic-*.tar.gz"
token: "${{ secrets.SIM_MODEL_DOWNLOAD }}"
- name: Unzip Release
run: |
cd ..
echo "payload: ${{ github.event.client_payload.new_release }}"
for file in $(ls -1 $GITHUB_WORKSPACE/*.tar.gz)
do
echo $file
tar -xvf $file
done
ls -l
- name: find the diff
run: |
python3 primitive_parser.py --src=./../sim_models/verilog/ --dest=./sim_models/verilog/ --release=${{ github.event.client_payload.new_release }}
- name: reverse the opposite changes
id: do_push
run: |
case "${{ matrix.scenarios }}" in
"pass")
echo "updates are from ${{ matrix.scenarios }}"
passfile="Pass_prim.txt"
if [ -f "$passfile" ]; then
echo "Pass file found"
all_files=`cat $passfile`
echo "file to commit in case of pass are $all_files"
echo "path_to_commit=$all_files" >> $GITHUB_ENV
echo "has_changed=true" >> $GITHUB_OUTPUT
fi
;;
"fail")
echo "updates are from ${{ matrix.scenarios }}"
passfile="Pass_prim.txt"
if [ -f "$passfile" ]; then
echo "Pass file found"
all_files=`cat $passfile`
echo $all_files
git checkout $all_files
if [ $? -eq 0 ]; then
echo "Checkout successful."
else
echo "Checkout failed for file: $passfile"
fi
fi
echo "path_to_commit=${{ env.external_model_path }}" >> $GITHUB_ENV
any_change=`git status --porcelain ${{ env.external_model_path }}`
if [ ! -z "$any_change" ]
then
echo "has_changed=true" >> $GITHUB_OUTPUT
fi
;;
*)
echo "Invalid value: ${{ matrix.scenarios }}"
;;
esac
- name: cat email.txt
if: success() || failure()
id: pr_decision
run: |
if [ -f email.txt ]
then
cat email.txt
else
echo "Kindly check your python script as it failed somewhere. Link to fail Github Action is ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> email.txt
fi
if [ -f subject.txt ]
then
cat subject.txt
else
echo "${{ github.repository }} Python Script failed to find the diff" >> subject.txt
fi
case "${{ matrix.scenarios }}" in
"pass")
echo "updates are from ${{ matrix.scenarios }}"
echo "email_ids=${{ secrets.ONLY_EMAIL_ID }}" >> $GITHUB_ENV
;;
"fail")
echo "updates are from ${{ matrix.scenarios }}"
echo "email_ids=${{ secrets.EMAIL_IDS }}" >> $GITHUB_ENV
#echo "email_ids=${{ secrets.ONLY_EMAIL_ID }}" >> $GITHUB_ENV
;;
*)
echo "Invalid value: ${{ matrix.scenarios }}"
;;
esac
- name: show current status
run:
git status
- name: Add and Push
if: contains(steps.do_push.outputs.has_changed, 'true')
uses: GuillaumeFalourd/[email protected]
with:
email: [email protected]
name: NadeemYaseen
commit_message: Added SIM change files from ${{ github.event.client_payload.new_release }}
files: "${{ env.path_to_commit }}"
target_branch: ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_external
access_token: ${{ secrets.SIM_MODEL_DOWNLOAD }}
force: true
# if all pass then create PR.
- name: Create PR
if: ${{ matrix.scenarios == 'pass' && steps.do_push.outputs.has_changed == 'true' }}
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_external # branch having xmls files
destination_branch: "main" # name of branch on which PR go
pr_title: "Pulling SIMs release ${{ github.event.client_payload.new_release }} into main. " # Title of pull request
pr_body: "An automated PR to check in New SIMs Release. Click on the link to see regression results ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Full markdown support, requires pr_title
#pr_reviewer: "moinijaz" # Comma-separated list (no spaces)
pr_reviewer: "ashrafnisar"
pr_assignee: "NadeemYaseen" # Comma-separated list (no spaces)
pr_label: "openfpga_castor_pd_sim" # Comma-separated list (no spaces)
pr_allow_empty: true # Creates pull request even if there are no changes
github_token: ${{ secrets.SIM_MODEL_DOWNLOAD }}
- name: Send Email
if: success() || failure()
uses: dawidd6/[email protected]
with:
server_address: ${{secrets.MAIL_SERVER}}
server_port: ${{secrets.MAIL_SERVERPORT}}
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: "${{ env.SUBJECT }} for release ${{ github.event.client_payload.new_release }}. Changes are in branch ${{ matrix.scenarios }}_sim_${{ github.event.client_payload.new_release }}_external"
body: file://email.txt
#to: [email protected]
to: "${{ env.email_ids }}"
from: ${{secrets.MAIL_USERNAME}}
#attachments: and2_verilog.tar.gz