Skip to content

Commit

Permalink
Merge pull request #200 from jasminabrar/match_ebeam+add_scripted_layout
Browse files Browse the repository at this point in the history
Match new functionality of EBeam PDK + Add scripted layout action
  • Loading branch information
lukasc-ubc authored Jan 24, 2024
2 parents 964f3ff + 334dd2a commit 7c01da0
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 10 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/Scripted_Layout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Test that a SiEPIC EBeam PDK scripted layout successfully runs in Klayout using SiEPIC Tools code from the repo.
name: KLayout Scripted Layout Test

on:
workflow_dispatch:
push:
branches:
- '**'
pull_request:
branches:
- master

jobs:
run-scripted-layout:
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/SiEPIC-Tools
ref: ${{ github.ref }}

- name: Connect to Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull siepic_klayout image
run: docker pull ghcr.io/jasminabrar/siepic-tools/siepic_klayout:match-ebeam-latest

- name: Run docker container from image
run: docker run -itd --name scripted_layout -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --security-opt label=type:container_runtime_t ghcr.io/jasminabrar/siepic-tools/siepic_klayout:match-ebeam-latest

- name: Fetch changes from main repository
run: git fetch https://github.com/SiEPIC/SiEPIC-Tools.git master

- name: Find files that are different
id: changed-files
run: |
if [ "${{ github.repository }}" == "${{ env.GITHUB_REPOSITORY }}" ]; then
# If we are in the main repository, remove existing siepic tools & copy this siepic tools to the docker container
docker exec scripted_layout rm -r /root/.klayout/salt/SiEPIC-Tools
docker cp $GITHUB_WORKSPACE scripted_layout:/root/.klayout/salt
else
# If we are in a forked repository or another branch, copy changed files to scripted_layout
changed_files=$(git diff --name-only FETCH_HEAD)
IFS=$'\n' # Set Internal Field Separator to newline to handle multiple files
for file in $changed_files; do
# Determine the library folder based on the file path
folder=$(dirname "$file")
# Extract the last part of the path (directory name)
folder=$(basename "$folder")
# Extract the filename
filename=$(basename "$file")
# Define the destination path in the Docker container
destination_path="/root/.klayout/salt/SiEPIC-Tools"
echo "Copy $GITHUB_WORKSPACE/$file to $destination_path/$file"
# Perform docker cp for each file
docker cp "$GITHUB_WORKSPACE/$file" scripted_layout:"$destination_path/$file"
echo "Copied $file to $destination_path/$file"
done
fi
- name: Run scripted layout inside container and capture exit code
run: docker exec scripted_layout klayout -zz -r /root/.klayout/salt/SiEPIC_EBeam_PDK/klayout/EBeam/pymacros/Example_scripted_layouts/"Example - Ring_resonator_sweep.py" || echo "KLAYOUT_EXIT_CODE=$?" >> $GITHUB_ENV
continue-on-error: true

- name: Stop container and remove it
run: |
docker stop scripted_layout
docker rm scripted_layout
- name: Fail job if exit code is non-zero
run: |
if [ $KLAYOUT_EXIT_CODE -ne 0 ]; then
echo "KLayout exited with non-zero exit code"
exit 1
fi
38 changes: 33 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Create and Publish Docker image

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches: [ "master" ]
paths:
Expand All @@ -14,7 +17,7 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/klayout
IMAGE_NAME: ${{ github.repository }}/siepic_klayout

jobs:
build-and-push-image:
Expand All @@ -34,9 +37,34 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get the current date
id: date
run: echo "::set-output name=date::$(date +%Y%m%d)"
- name: install jq
run: |
sudo apt-get update -y
sudo apt-get install jq -y
# docker image always built with latest version
- name: get latest version of siepic ebeam pdk
id: ebeampdk
run: |
EBEAM_PDK=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/SiEPIC/SiEPIC_EBeam_PDK/releases/latest" \
| jq -r .tag_name)
echo "::set-output name=ebeampdk::${EBEAM_PDK}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

#docker image always built with latest version
- name: get latest version of siepic tools
id: siepictools
run: |
SIEPIC_TOOLS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/SiEPIC/SiEPIC-Tools/releases/latest" \
| jq -r .tag_name)
echo "::set-output name=siepictools::${SIEPIC_TOOLS}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
Expand Down Expand Up @@ -64,6 +92,6 @@ jobs:
with:
context: .
push: true
tags: "${{ steps.meta.outputs.tags }}.${{ steps.date.outputs.date }}.${{ github.run_number }}"
tags: "${{ steps.meta.outputs.tags }}.${{ steps.ebeampdk.outputs.ebeampdk }}.${{ steps.siepictools.outputs.siepictools}}"
labels: ${{ steps.meta.outputs.labels }}

4 changes: 2 additions & 2 deletions .github/workflows/sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
uses: actions/checkout@v3

- name: Pull klayout image
run: docker pull ghcr.io/jasminabrar/siepic-tools/klayout:master-latest
run: docker pull ghcr.io/siepic/siepic-tools/klayout:master-latest

- name: Run docker container from image
run: docker run -itd --name sample --security-opt label=type:container_runtime_t ghcr.io/jasminabrar/siepic-tools/klayout:master-latest
run: docker run -itd --name sample --security-opt label=type:container_runtime_t ghcr.io/siepic/siepic-tools/klayout:master-latest

# input code to run tests in klayout docker container

Expand Down
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ FROM quay.io/centos/centos:stream8

# Update the system and install necessary tools.
RUN dnf -y update && \
dnf -y install wget bzip2 unzip git mesa-dri-drivers
dnf -y install wget bzip2 unzip git mesa-dri-drivers python3 python3-pip

# Install Numpy
RUN pip3 install numpy

# Install the newest version of KLayout
RUN wget https://www.klayout.org/downloads/CentOS_8/klayout-0.28.12-0.x86_64.rpm -O ~/klayout.rpm && \
RUN wget https://www.klayout.org/downloads/CentOS_8/klayout-0.28.13-0.x86_64.rpm -O ~/klayout.rpm && \
dnf -y localinstall ~/klayout.rpm && \
rm ~/klayout.rpm

# Clone SiEPIC-Tools and SiEPIC_EBeam_PDK.
RUN mkdir -p /root/.klayout/salt && \
cd /root/.klayout/salt && \
git clone https://github.com/SiEPIC/SiEPIC-Tools.git && \
git clone https://github.com/SiEPIC/SiEPIC_EBeam_PDK.git

# Set the working directory
WORKDIR /home

# Set PATH
ENV PATH="/usr/local/bin:${PATH}"
ENV PATH="/usr/local/bin:${PATH}:/usr/local/bin/python3:/root/.local/bin"
ENV QT_QPA_PLATFORM=minimal

0 comments on commit 7c01da0

Please sign in to comment.