-
Notifications
You must be signed in to change notification settings - Fork 34
100 lines (71 loc) · 2.92 KB
/
python-to-oas_gds.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
name: Run Python Files
on:
workflow_dispatch:
push:
paths:
- "submissions/KLayout Python/**.py"
branches:
- '**'
jobs:
run-python:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2
with:
fetch-depth: 0
# can also specify python version if needed
- name: setup python
uses: actions/setup-python@v4
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install klayout SiEPIC siepic_ebeam_pdk
python -m pip install --upgrade SiEPIC
- name: run python scripts and get output gds / oas file
run: |
# get added/modified py files
export FILES=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.sha }} -- "submissions/KLayout Python" | grep -E '\.py$')
echo "FILES=$FILES" >> $GITHUB_ENV
echo "Added / modified Python files; $FILES"
# delete .oas and .gds files in the runner's submissions folder
# this is needed in the case where someone already has file_name.gds and is now trying to generate file_name.oas (or vice versa)
rm -f submissions/*.gds submissions/*.oas
IFS=$'\n'
OUTPUT_FILES=""
for file in $FILES; do
echo "Getting oas/gds output for $file"
# run file and generate a gds / oas output
python "$file"
# get output and save to OUTPUT_FILES
gds_files=$(find submissions -type f -name "*.gds" -exec basename {} .gds \;)
oas_files=$(find submissions -type f -name "*.gds" -exec basename {} .oas \;)
file_name=$(basename "$file")
file_name_no_py=$(basename "$file_name" .py)
output_files=""
if echo "$gds_files" | grep -q "$file_name_no_py"; then
output_file="${file_name_no_py}.gds"
else
output_file="${file_name_no_py}.oas"
fi
OUTPUT_FILES+="$output_file "
echo "Done for $file"
done
echo "output files; $OUTPUT_FILES"
echo "OUTPUT_FILES=$OUTPUT_FILES" >> $GITHUB_ENV
- name: write added oas and gds files to txt file
run: |
echo "$OUTPUT_FILES" > python-to-gds_oas.txt
- name: commit outputted oas and gds files into repository
run: |
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
git add python-to-gds_oas.txt
echo "git add python-to-gds_oas.txt"
# git add all produced oas files
for file in $OUTPUT_FILES; do
git add "submissions/$file"
echo "git add $file"
done
git commit -m "Add oas and gds files produced from .py files"
git push