Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #26 from mithro/actions.yml
Browse files Browse the repository at this point in the history
run-drc-for-cell-gds-using-magic: Add action.yml
  • Loading branch information
mithro committed Jun 3, 2021
2 parents 77e8b45 + e89d4b7 commit bd5ca87
Show file tree
Hide file tree
Showing 18 changed files with 284 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Test Docker Image for Run DRC for cell GDS (using Magic) Action

on:
workflow_dispatch:
push:
pull_request:


permissions:
contents: read


jobs:

test:
name: Basic Test

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Check tests/action-local/action.yml is up to date
run: |
cd run-drc-for-cell-gds-using-magic
make ./tests/action-local/action.yml
git diff --exit-code --color=always ./tests/action-local/action.yml
- uses: ./run-drc-for-cell-gds-using-magic/tests/action-local
name: Clean cells should pass.
with:
top: ./run-drc-for-cell-gds-using-magic/tests/clean

- uses: ./run-drc-for-cell-gds-using-magic/tests/action-local
name: Broken cells is filtered (--known-bad).
with:
top: ./run-drc-for-cell-gds-using-magic/tests/broken
known-bad: sky130_fd_sc_hd__clkdlybuf4s15_1

- uses: ./run-drc-for-cell-gds-using-magic/tests/action-local
name: Broken cells is filtered (--match-cells).
with:
top: ./run-drc-for-cell-gds-using-magic/tests/broken
match-cell-directories: clean_cell

- uses: ./run-drc-for-cell-gds-using-magic/tests/action-local
name: Broken cells should fail.
id: broken-should-fail
continue-on-error: true
with:
top: ./run-drc-for-cell-gds-using-magic/tests/broken

- name: Error on success
if: steps.broken-should-fail.outcome != 'failure'
run:
echo "The action should have failed!"
exit 1
48 changes: 48 additions & 0 deletions run-drc-for-cell-gds-using-magic/.update-test-action-local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 SkyWater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import pathlib

__dir__ = pathlib.Path(__file__).parent.resolve()

src_action_yml = __dir__ / 'action.yml'
dst_action_yml = (__dir__ / 'tests' / 'action-local' / 'action.yml').resolve()

print('Base action.yml file at:', src_action_yml)
print('Test action.yml file at:', dst_action_yml)

with open(src_action_yml) as f:
action_data = f.read()

name = 'run-drc-for-cell-gds-using-magic'
action_data = action_data.replace(
f'image: docker://gcr.io/skywater-pdk/actions/{name}:main',
'image: ../../Dockerfile',
)

action_data = action_data.replace(
'\nname:',
"""
# WARNING! Don't modify this file, modify the base `action.yml` file and then
# run `make tests/action-local/action.yml`.
name:""")

with open(dst_action_yml, 'w') as f:
f.write(action_data)
9 changes: 8 additions & 1 deletion run-drc-for-cell-gds-using-magic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/..)

NAME := run-drc-for-cell-gds-using-magic

tests/action-local/action.yml: action.yml .update-test-action-local.py
$(TOP_DIR)/$(NAME)/.update-test-action-local.py

.PHONY: tests/action-local/action.yml

README.rst: README.src.rst $(TOP_DIR)/docs/*.rst $(TOP_DIR)/Makefile
make -C $(TOP_DIR) run-drc-for-cell-gds-using-magic/README.rst
make -C $(TOP_DIR) $(NAME)/README.rst

# Redirect everything to the top directory by default.
%:
Expand Down
4 changes: 1 addition & 3 deletions run-drc-for-cell-gds-using-magic/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ Add this to any push, PR or manual dispatch workflow:
- uses: actions/checkout@v2
- name: Run DRC for cell GDS (using Magic)
uses: docker://gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:latest
with:
args: --acceptable-errors-file /dev/null --match-directories . --known-bad ''
uses: google/skywater-pdk-actions/run-drc-for-cell-gds-using-magic@main
Check the Python file for more documentation on arguments.

Expand Down
4 changes: 1 addition & 3 deletions run-drc-for-cell-gds-using-magic/README.src.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ Add this to any push, PR or manual dispatch workflow:
- uses: actions/checkout@v2
- name: Run DRC for cell GDS (using Magic)
uses: docker://gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:latest
with:
args: --acceptable-errors-file /dev/null --match-directories . --known-bad ''
uses: google/skywater-pdk-actions/run-drc-for-cell-gds-using-magic@main
Check the Python file for more documentation on arguments.

Expand Down
52 changes: 52 additions & 0 deletions run-drc-for-cell-gds-using-magic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2020 SkyWater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

name: run-drc-for-cell-gds-using-magic
description: >-
This GitHub action runs Design Rule Checks on all GDS files inside the /cells
directory.
inputs:
top:
description: >-
What directory to run the check inside.
default: .
acceptable-errors-file:
description: >-
A file containing a list of newline-delimited acceptable DRC errors.
default: /dev/null
match-cell-directories:
description: >-
A regex that will match cell names to be checked.
default: ^.*$
known-bad:
description: >-
Common separated list of known bad cells that should be ignored.
default:


runs:
using: 'docker'
image: docker://gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:main
args:
- --top
- ${{ inputs.top }}
- --acceptable-errors-file
- ${{ inputs.acceptable-errors-file }}
- --match-cell-directories
- ${{ inputs.match-cell-directories }}
- --known-bad
- ${{ inputs.known-bad }}
56 changes: 42 additions & 14 deletions run-drc-for-cell-gds-using-magic/run_all_drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ def drc_gds(path: str) -> Tuple[str, List[DRCError]]:


@click.command()
@click.option(
"-t",
"--top",
default=".",
help="Directory to run the process inside."
" Default: Current working directory"
)
@click.option(
"-a",
"--acceptable-errors-file",
Expand All @@ -143,10 +150,11 @@ def drc_gds(path: str) -> Tuple[str, List[DRCError]]:
)
@click.option(
"-m",
"--match-directories",
default=".",
help="A regex that will match subdirectories under cells/."
" Default: . (matches everything.)"
"--match-cell-directories",
default="^.*$",
help="A regex that that will match cell names to be checked (which will"
" match subdirectories under cells/)."
" Default: ^.*$ (matches everything)"
)
@click.option(
"-b",
Expand All @@ -156,28 +164,44 @@ def drc_gds(path: str) -> Tuple[str, List[DRCError]]:
" thus do not cause a non-zero exit upon failure."
" Default: empty string (None of them.)"
)
def run_all_drc(acceptable_errors_file, match_directories, known_bad):
print("Testing cells in directories matching /%s/…" % match_directories)
def run_all_drc(
top,
acceptable_errors_file,
match_cell_directories,
known_bad,
):

os.chdir(top)
print("Testing cells in %s directories matching /%s/…" % (
os.getcwd(), match_cell_directories))

global acceptable_errors
acceptable_errors_str = open(acceptable_errors_file).read()
acceptable_errors = acceptable_errors_str.split("\n")
acceptable_errors = []
with open(acceptable_errors_file) as f:
acceptable_errors += f.read().split("\n")

cells_dir = "./cells"
lib_acceptable_errors_file = os.path.join(cells_dir, 'allowed_drc_errors')
if os.path.exists(lib_acceptable_errors_file):
with open(lib_acceptable_errors_file) as f:
acceptable_errors += f.read().split("\n")

known_bad_list = known_bad.split(",")

nproc = os.cpu_count()
with futures.ThreadPoolExecutor(max_workers=nproc) as executor:
future_list = []

cells_dir = "./cells"
cells = os.listdir(cells_dir)

for cell in cells:
if not re.match(match_directories, cell):
if not re.fullmatch(match_cell_directories, cell):
print("Skipping directory %s…" % cell)
continue

cell_dir = os.path.join(cells_dir, cell)
if not os.path.isdir(cell_dir):
continue

gds_list = list(
filter(lambda x: x.endswith(".gds"), os.listdir(cell_dir))
Expand All @@ -195,19 +219,23 @@ def run_all_drc(acceptable_errors_file, match_directories, known_bad):
total += 1
cell_name, errors = future.result()

symbol = "❌"
message = "ERROR"
if len(errors) == 0:
successes += 1
# This tick is rendered black on all major platforms except for
# Microsoft.
symbol = "✔\ufe0f"
message = "CLEAN"
elif cell_name in known_bad_list:
symbol = "✘\ufe0f"
message = "ERROR (ignored as known bad)"
else:
symbol = "❌"
message = "ERROR"
exit_code = 65

print("%-64s %s %s" % (cell_name, symbol, message))

if len(errors) != 0:
if cell_name not in known_bad_list:
exit_code = 65
for error in errors:
print("* %s" % error[0])
for line in error[1]:
Expand Down
55 changes: 55 additions & 0 deletions run-drc-for-cell-gds-using-magic/tests/action-local/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2020 SkyWater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

# WARNING! Don't modify this file, modify the base `action.yml` file and then
# run `make tests/action-local/action.yml`.

name: run-drc-for-cell-gds-using-magic
description: >-
This GitHub action runs Design Rule Checks on all GDS files inside the /cells
directory.
inputs:
top:
description: >-
What directory to run the check inside.
default: .
acceptable-errors-file:
description: >-
A file containing a list of newline-delimited acceptable DRC errors.
default: /dev/null
match-cell-directories:
description: >-
A regex that will match cell names to be checked.
default: ^.*$
known-bad:
description: >-
Common separated list of known bad cells that should be ignored.
default:


runs:
using: 'docker'
image: ../../Dockerfile
args:
- --top
- ${{ inputs.top }}
- --acceptable-errors-file
- ${{ inputs.acceptable-errors-file }}
- --match-cell-directories
- ${{ inputs.match-cell-directories }}
- --known-bad
- ${{ inputs.known-bad }}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
All nwells must contain metal-connected N+ taps (nwell.4)
P-diff distance to N-tap must be < 15.0um (LU.3)
N-diff distance to P-tap must be < 15.0um (LU.2)

0 comments on commit bd5ca87

Please sign in to comment.