Skip to content

Commit

Permalink
Merge pull request #266 from jasminabrar/master
Browse files Browse the repository at this point in the history
Added automated docker build process
  • Loading branch information
lukasc-ubc committed Nov 23, 2023
2 parents e4146fa + a336a88 commit be6e8fa
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 26 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/Docker_Image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Create and Publish Docker Image

on:
release:
types:
- created
repository:
- 'SiEPIC/SiEPIC_EBeam_PDK'
- 'SiEPIC/SiEPIC-Tools'

push:
branches: [ "master" ]
paths:
- 'Dockerfile'
pull_request:
types:
- closed
branches: [ "master" ]
paths:
- 'Dockerfile'

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

jobs:
build-and-push-image:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check pull request was merged
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == false
run: |
echo "Error: Pull request is not merged."
exit 1
- 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: Log in to the container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image as latest image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}-latest
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image as unique image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: "${{ steps.meta.outputs.tags }}.${{ steps.date.outputs.date }}.${{ github.run_number }}"
labels: ${{ steps.meta.outputs.labels }}
19 changes: 9 additions & 10 deletions .github/workflows/EBeam_Tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

name: EBeam Tests
name: EBeam Tests

on:
push:
Expand All @@ -9,35 +8,35 @@ on:
branches:
- master

jobs:
jobs:
ebeam-lib-pcell-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Pull siepic_klayout image
run: docker pull ghcr.io/farihais/siepic_klayout:latest

- name: Pull siepic_klayout image
run: docker pull ghcr.io/jasminabrar/siepic_ebeam_pdk/siepic_klayout:master-latest

- name: Run docker container from image
run: docker run -itd --name ebeam_test -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --security-opt label=type:container_runtime_t ghcr.io/farihais/siepic_klayout:latest
run: docker run -itd --name ebeam_test -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --security-opt label=type:container_runtime_t ghcr.io/jasminabrar/siepic_ebeam_pdk/siepic_klayout:master-latest

- name: Copy pymacros folder to docker container
run: docker cp $GITHUB_WORKSPACE/klayout/EBeam/pymacros ebeam_test:/home/pymacros

- name: Run KLayout Python script inside container and capture exit code
- name: Run KLayout Python script inside container and capture exit code
run: docker exec ebeam_test klayout -zz -r pymacros/EBeam_Lib_PCellTests.py || echo "KLAYOUT_EXIT_CODE=$?" >> $GITHUB_ENV
continue-on-error: true

- name: Stop container and remove it
run: |
docker stop ebeam_test
docker rm ebeam_test
- 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
fi
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 python3-pip

# 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 && \
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}:/usr/local/bin/python3:/root/.local/bin"
ENV QT_QPA_PLATFORM=minimal
19 changes: 3 additions & 16 deletions klayout/EBeam/pymacros/EBeam_Lib_PCellTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
exec(open(custom_exceptions_path).read())

"""
Python script to test that all Pcells are properly registered in their respective library and will display polygons when placed on a new layout.
Python script to test that all EBeam libraries are registered and all Pcells are properly registered in their respective library and
will display polygons when placed on a new layout.
To run this script from the command line: '{path to klayout} -zz -r {path to this script/EBeam_Lib_PCellTests.py}'.
Expand Down Expand Up @@ -97,24 +98,10 @@
#inst = topcell.insert(CellInstArray(pcell.cell_index(), t))


except (PCellRegistrationError, PCellInstantiationError) as e:
except (PCellRegistrationError, PCellInstantiationError, Exception) as e:
print("Caught {}: {}".format(type(e).__name__, str(e)))
pya.Application.instance().exit(1)

print("Complete. All pcells from {} folder were successfully registered in {} library".format(library_folders[i], library_names[i]))

print("Complete. All pcells were succcessfully registered in all libraries.")














0 comments on commit be6e8fa

Please sign in to comment.