diff --git a/.github/workflows/Docker_Image.yml b/.github/workflows/Docker_Image.yml new file mode 100644 index 00000000..bfa83108 --- /dev/null +++ b/.github/workflows/Docker_Image.yml @@ -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 }} diff --git a/.github/workflows/EBeam_Tests.yml b/.github/workflows/EBeam_Tests.yml index 693efbae..7936cdb3 100644 --- a/.github/workflows/EBeam_Tests.yml +++ b/.github/workflows/EBeam_Tests.yml @@ -1,5 +1,4 @@ - -name: EBeam Tests +name: EBeam Tests on: push: @@ -9,24 +8,24 @@ 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 @@ -34,10 +33,10 @@ jobs: 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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5e9cf57d --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/klayout/EBeam/pymacros/EBeam_Lib_PCellTests.py b/klayout/EBeam/pymacros/EBeam_Lib_PCellTests.py index 05fd072b..88869962 100644 --- a/klayout/EBeam/pymacros/EBeam_Lib_PCellTests.py +++ b/klayout/EBeam/pymacros/EBeam_Lib_PCellTests.py @@ -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}'. @@ -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.") - - - - - - - - - - - - - -