Skip to content

Commit

Permalink
codecov, pytest for all PCells
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Dec 12, 2023
1 parent 6b8afe3 commit a367ae6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/run-layout-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run SiEPIC-Tool Layout tests

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


jobs:
test_layouts:
runs-on: ubuntu-latest

steps:
- name: checkout repo content
uses: actions/checkout@v3

# 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 numpy scipy pytest pytest-cov SiEPIC
- name: Test with pytest
run: pytest --cov=klayout/siepic_ebeam_pdk klayout/siepic_ebeam_pdk/pymacros/tests/tests_All_Library_Cells.py --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true

5 changes: 3 additions & 2 deletions klayout/EBeam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# Load the KLayout technology, when running in Script mode
import pya, os
tech = pya.Technology().create_technology('EBeam')
tech.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'EBeam.lyt'))
if not pya.Technology().has_technology('EBeam'):
tech = pya.Technology().create_technology('EBeam')
tech.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'EBeam.lyt'))

# then import all the technology modules
from . import pymacros
Expand Down
53 changes: 53 additions & 0 deletions klayout/EBeam/pymacros/tests/test_All_Library_Cells.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# $description: Unit testing: all EBeam libraries' cells
# $show-in-menu
# $group-name: Examples_EBeam
# $menu-path: siepic_menu.exlayout.end
# Unit testing for all library layout fixed cells and PCells

tech_name = 'EBeam'

import pya # klayout
import os, sys
import SiEPIC
from SiEPIC._globals import Python_Env
print('KLayout running in mode: %s' % Python_Env)
from SiEPIC.utils.layout import new_layout, floorplan
from SiEPIC.utils import load_klayout_technology
from SiEPIC.scripts import instantiate_all_library_cells, zoom_out, export_layout

def test_all_library_cells():

if Python_Env == 'Script':
# Load the PDK from a folder, e.g, GitHub, when running externally from the KLayout Application
import sys
path = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0,os.path.abspath(os.path.join(path, '../../..')))
import siepic_ebeam_pdk


# Create a new layout
topcell, ly = new_layout(tech_name, "UnitTesting", GUI=True, overwrite = True)

# Instantiate all cells
instantiate_all_library_cells(topcell)

'''
# Save the layout
path_out = os.path.dirname(os.path.realpath(__file__))
ly.write(os.path.join(path_out,'a.gds'))
export_layout(topcell, path_out,'a_static',format='oas')
print('done')
'''

# Check if there are any errors
for cell_id in topcell.called_cells():
c = ly.cell(cell_id)
error_shapes = c.shapes(ly.error_layer())
for error in error_shapes.each():
raise Exception('Error in cell: %s, %s' % (c.name, error.text))
if c.is_empty() or c.bbox().area() == 0:
raise Exception('Empty cell: %s' % c.name)


if __name__ == "__main__":
test_all_library_cells()
5 changes: 0 additions & 5 deletions klayout/EBeam/test.py

This file was deleted.

0 comments on commit a367ae6

Please sign in to comment.