Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Sep 9, 2024
1 parent 2432a84 commit 82438e3
Show file tree
Hide file tree
Showing 13 changed files with 1,107 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/AutomaticApprove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Automatic Approve
on:
schedule:
- cron: "*/5 * * * *"

jobs:
automatic-approve:
name: Automatic Approve
if: github.repository_owner == 'SiEPIC'
#if: >-
#github.event.pull_request.user.login != 'SiEPIC' && repository_dispatch.organization
runs-on: ubuntu-latest
steps:
- name: Automatic Approve
uses: mheap/automatic-approve-action@v1
with:
token: ${{ secrets.PAT }}
workflows: "run-verification.yml"
53 changes: 53 additions & 0 deletions .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: PullRequest
on:
# pull_request:
# branches:
# - '**'
pull_request_target:
branches:
- '**'


jobs:
welcome:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
// Get a list of all issues created by the PR opener
// See: https://octokit.github.io/rest.js/#pagination
const creator = context.payload.sender.login
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
})
const issues = await github.paginate(opts)
for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
}
if (issue.pull_request) {
return // Creator is already a contributor.
}
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `**Welcome**, new contributor!
Thank you for uploading your design.
If you have not already checked it, please run the SiEPIC Functional Verification in KLayout, using the menu SiEPIC-Verification-Functional Layout Check (V).
Please note that we have added a new rule (on May 2, 2024) to SiEPIC-Tools and the EBeam PDK, so please make sure your tools are running the latest version. The rule is: The grating coupler spacing (pitch) must be at least 60.0 microns. This is to help avoid the probe station from accidentally aligning to an adjacent circuit.
You may continue making updates to your design, or even contributing additonal designs (using a separate file name), until the tape-out deadline.
`
})
142 changes: 142 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Run Merge Script

on:
workflow_dispatch:
# run after layout verification
workflow_run:
workflows: ["Run Layout Verification"]
types:
- completed

jobs:
merge:
# only run the merge script on the SiEPIC account
#if: github.repository_owner == 'SiEPIC'
# if: >-
# github.event.pull_request.user.login != 'SiEPIC' &&
# repository_dispatch.organization
runs-on: ubuntu-latest

steps:
- name: checkout repo content
uses: actions/checkout@v2
with:
# https://github.com/MestreLion/git-tools?tab=readme-ov-file#git-restore-mtime
fetch-depth: 0

- name: download verification trigger artifact
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ github.event.workflow_run.id }}
name: verification-trigger
path: .
search_artifacts: true
if: github.event_name != 'workflow_dispatch'

- name: check if verification action was triggered by a pull request
run: |
trigger_info=$(cat trigger_info.txt)
echo $trigger_info
if [[ "$trigger_info" == "pull_request" || "$trigger_info" == "pull_request_target" ]]; then
echo "This workflow was triggered by a pull request. Do not update url in read me."
TRIGGER_INFO='pull request'
echo "TRIGGER_INFO=$TRIGGER_INFO" >> $GITHUB_ENV
else
echo "This workflow was not triggered by a pull request. Continue with merge and update url in read me."
fi
if: github.event_name != 'workflow_dispatch'

# there is only an artifact to download if this action is triggered after the verification action
# if it is manually triggered we set the var trigger_info manually
- name: if this action was manually triggered set trigger_info var
run: |
trigger_info='workflow_dispatch'
echo "TRIGGER_INFO=$trigger_info" >> $GITHUB_ENV
if: github.event_name == 'workflow_dispatch'


- name: Restore original modification time of files based on the date of the most recent commit
uses: chetan/git-restore-mtime-action@v2
#run: |
# # https://github.com/MestreLion/git-tools?tab=readme-ov-file#installation
# sudo apt install git-restore-mtime
# git restore-mtime

# 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 pull origin main
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.TRIGGER_INFO != 'pull request' && github.repository_owner == 'SiEPIC'
120 changes: 120 additions & 0 deletions .github/workflows/python-to-oas_gds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Run Python Files

on:
workflow_dispatch:
push:
paths:
- "submissions/KLayout Python/**.py"
branches:
- '**'
pull_request:
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
if [ "${{ github.event_name }}" == "push" ]; then
FILES=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.sha }} -- "submissions/KLayout Python" | grep -E '\.py$' | sed 's|^submissions/KLayout Python/||')
else
FILES=$(git diff --name-only --diff-filter=ACM FETCH_HEAD -- "submissions/KLayout Python" | grep -i -E '\.py$' | sed 's|^submissions/KLayout Python/||')
fi
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 -rf 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 "submissions/KLayout Python/$file"
# Lukas: for some reason, the "submissions/KLayout" part was showing up twice, and now it isn't.
# 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 "*.oas" -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: move oas and gds files to a new folder
run: |
mkdir -p python_to_oas_gds
for file in $OUTPUT_FILES; do
cp "submissions/$file" python_to_oas_gds/
done
- name: upload .oas and .gds as an artifact
uses: actions/upload-artifact@v4
with:
name: python-to-oas-gds
path: python_to_oas_gds/

- 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 all produced oas/gds files
for file in $OUTPUT_FILES; do
git add "submissions/$file"
echo "done: git add $file"
done
git commit -m "Add oas and gds files produced from .py files"
echo "done: git commit"
git push
echo "done: git push"
if: github.event_name != 'pull_request'

Loading

0 comments on commit 82438e3

Please sign in to comment.