-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
889dd31
commit 085ae90
Showing
15 changed files
with
1,178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Run Merge Script | ||
|
||
on: | ||
workflow_dispatch: | ||
# run after layout verification | ||
workflow_run: | ||
workflows: ["Run Layout Verification"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
merge: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout repo content | ||
uses: actions/checkout@v2 | ||
|
||
# can also specify python version if needed | ||
- name: setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
|
||
- name: install python packages | ||
run: | | ||
#python -m pip install --upgrade pip | ||
pip install klayout SiEPIC siepic_ebeam_pdk pandas | ||
python -m pip install --upgrade SiEPIC | ||
- name: run merge script | ||
run: | | ||
python merge/EBeam_merge.py | ||
- name: move merge output files to new folder | ||
run: | | ||
#output_files="EBeam.gds EBeam.oas EBeam.txt EBeam.coords" | ||
output_files="EBeam.oas EBeam.txt" | ||
IFS=' ' | ||
mkdir -p merge_output | ||
for file in $output_files; do | ||
cp "merge/$file" merge_output/ | ||
done | ||
- name: upload artifact | ||
uses: actions/upload-artifact@v4 | ||
id: artifact-upload | ||
with: | ||
name: merge-files | ||
path: merge_output/ | ||
|
||
- name: get artifact url | ||
run: | | ||
IFS='/' read -ra REPO <<< "$GITHUB_REPOSITORY" | ||
OWNER="${REPO[0]}" | ||
REPO_NAME="${REPO[1]}" | ||
echo "Owner: $OWNER" | ||
echo "Repository: $REPO_NAME" | ||
RUN_ID=${{ github.run_id }} | ||
ARTIFACT_ID=${{ steps.artifact-upload.outputs.artifact-id }} | ||
ARTIFACT_URL="https://github.com/$OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID" | ||
echo "Artifact URL: $ARTIFACT_URL" | ||
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV | ||
echo "OWNER=$OWNER" >> $GITHUB_ENV | ||
- name: update url in runner README | ||
run: | | ||
start_delim="<!-- start-link -->" | ||
end_delim="<!-- end-link -->" | ||
# remove current URL | ||
sed -i "/$start_delim/,/$end_delim/d" README.md | ||
# add new URL | ||
printf "$start_delim\n$ARTIFACT_URL\n$end_delim\n" >> README.md | ||
# merge script always runs on any PR, this ensures link is only updated after a PR is merged into SiEPIC | ||
- name: commit and push changes to README if we are in SiEPIC repo | ||
run: | | ||
git diff | ||
git config --local user.email "${{ github.actor }}@users.noreply.github.com" | ||
git config --local user.name "${{ github.actor }}" | ||
git add README.md | ||
git commit -m "update README with new artifact url $ARTIFACT_URL" | ||
git push | ||
if: ${{ env.OWNER == 'SiEPIC'}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Run Layout Verification | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Run Python Files"] | ||
types: | ||
- completed | ||
push: | ||
paths: | ||
- 'submissions/**.gds' | ||
- 'submissions/**.oas' | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
|
||
jobs: | ||
verification: | ||
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: get .gds and .oas files, run example layout verification | ||
id: run-script | ||
run: | | ||
# if the action is being triggered after running python files, get resulting oas files from txt file | ||
# github actions is not configured to detect files pushed from another action, thus we cannot use the method below | ||
if [ -s "python-to-gds_oas.txt" ] && [ -n "$(cat python-to-gds_oas.txt)" ]; then | ||
export FILES=$(cat python-to-gds_oas.txt) | ||
IFS=' ' | ||
echo "" > python-to-gds_oas.txt | ||
# push empty text file to repo | ||
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 | ||
git commit -m "Emptying text file" | ||
git push | ||
else | ||
if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
# triggered on pull request, get all changed / added files from forked repo | ||
export FILES=$(git diff --name-only --diff-filter=ACM FETCH_HEAD | grep -E '\.(gds|oas)$' | sed 's|^submissions/||') | ||
else | ||
# triggered push, locate the changed / added .gds and .oas files in the submission folder | ||
export FILES=$(git diff --name-status --diff-filter=ACM --relative=submissions ${{ github.event.before }} ${{ github.sha }} submissions | grep -E '\.(gds|oas)$' | awk '{print $2}') | ||
fi | ||
IFS=$'\n' | ||
fi | ||
# print the names of the files | ||
echo "Files for verification; $FILES" | ||
files_with_errors="" | ||
# run verification on all files | ||
for file in $FILES; do | ||
echo "Running verification on $file" | ||
output=$(python run_verification.py "submissions/$file") | ||
# get number of errors | ||
errors_from_output=$(echo "$output" | tail -n 1) | ||
echo "$errors_from_output errors detected for $file" | ||
# if file results in verification errors add to string files_with_errors | ||
if [[ "$errors_from_output" -ge 1 ]]; then | ||
files_with_errors+="$file, $errors_from_output errors. " | ||
fi | ||
echo "Done verification on $file" | ||
done | ||
echo "files_with_errors=$files_with_errors" >> $GITHUB_ENV | ||
- name: move output files to new folder | ||
run: | | ||
export OUTPUT_FILES=$(find /home/runner/work/openEBL-2024-02/openEBL-2024-02/submissions -name "*.lyrdb") | ||
echo "Output files: $OUTPUT_FILES" | ||
mkdir -p verification_output | ||
for file in $OUTPUT_FILES; do | ||
cp "$file" verification_output/ | ||
done | ||
- name: upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: layout-errors | ||
path: verification_output/ | ||
|
||
- name: fail if there are errors from layout verification | ||
run: | | ||
if [ -z "$files_with_errors" ]; then | ||
echo "No errors detected." | ||
else | ||
echo "Errors detected: $files_with_errors" | ||
exit 1 | ||
fi | ||
Oops, something went wrong.