Skip to content

Commit

Permalink
temporarily disable linux aarch64 so i dont die of old age + fix metr…
Browse files Browse the repository at this point in the history
…ic upload, docs
  • Loading branch information
donn committed Nov 23, 2023
1 parent 014fa25 commit b56d8f9
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 87 deletions.
177 changes: 91 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,29 @@ jobs:
uses: ./.github/actions/derivation_to_cache
with:
key: derivation-amd64-${{ github.run_id }}
build-linux-aarch64:
needs: lint
runs-on: ubuntu-22.04
name: Build (Nix on Linux/aarch64)
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v1
- name: Initialize Step Unit Test Submodule
run: |
git submodule update --init test/steps/all
- name: Set up GITHUB_TOKEN
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Build with Nix
uses: ./.github/actions/build_nix
with:
cachix_cache: ${{ vars.CACHIX_CACHE || 'openlane' }}
cachix_token: "${{ secrets.CACHIX_TOKEN }}"
nix_build_args: --option system aarch64-linux --extra-platforms aarch64-linux
- name: Derivation to Cache
uses: ./.github/actions/derivation_to_cache
with:
key: derivation-aarch64-${{ github.run_id }}
# build-linux-aarch64:
# needs: lint
# runs-on: ubuntu-22.04
# name: Build (Nix on Linux/aarch64)
# steps:
# - uses: actions/checkout@v3
# - uses: docker/setup-qemu-action@v1
# - name: Initialize Step Unit Test Submodule
# run: |
# git submodule update --init test/steps/all
# - name: Set up GITHUB_TOKEN
# run: |
# echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
# - name: Build with Nix
# uses: ./.github/actions/build_nix
# with:
# cachix_cache: ${{ vars.CACHIX_CACHE || 'openlane' }}
# cachix_token: "${{ secrets.CACHIX_TOKEN }}"
# nix_build_args: --option system aarch64-linux --extra-platforms aarch64-linux
# - name: Derivation to Cache
# uses: ./.github/actions/derivation_to_cache
# with:
# key: derivation-aarch64-${{ github.run_id }}
build-mac-amd64:
needs: lint
runs-on: macos-12
Expand Down Expand Up @@ -141,54 +141,54 @@ jobs:
- name: Run Unit Tests
run: |
make test
build-docker:
runs-on: ubuntu-22.04
strategy:
matrix:
arch: ["amd64", "aarch64"]
needs: [build-linux-amd64, build-linux-aarch64]
name: Build Docker Image (${{ matrix.arch }})
steps:
- name: Check out repo
uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v1
- name: Setup Nix
uses: ./.github/actions/setup_nix
with:
cachix_cache: ${{ vars.CACHIX_CACHE || 'openlane' }}
- name: Derivation from Cache
uses: ./.github/actions/derivation_from_cache
with:
key: derivation-${{ matrix.arch }}-${{ github.run_id }}
other-substituters: "https://${{ vars.CACHIX_CACHE || 'openlane' }}.cachix.org"
- name: Build Docker Image
run: |
if [ "${{ matrix.arch }}" == "aarch64" ]; then
arch_flags="--option system aarch64-linux --extra-platforms aarch64-linux"
fi
IMAGE_PATH=$(nix-build --argstr name openlane --argstr tag-override tmp-${{ matrix.arch }} $arch_flags docker.nix)
echo "IMAGE_PATH=$IMAGE_PATH" >> $GITHUB_ENV
cat $IMAGE_PATH | docker load
- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Dependencies
run: make venv
- name: Smoke-Test Docker Image
run: |
mkdir -p $HOME/.volare
chmod -R 755 $HOME/.volare
OPENLANE_IMAGE_OVERRIDE=openlane:tmp-${{ matrix.arch }}\
./venv/bin/python3 -m openlane\
--docker-no-tty\
--dockerized\
--smoke-test
- name: Upload Docker Artifact
uses: actions/upload-artifact@v3
with:
name: docker-image-${{ matrix.arch }}
path: ${{ env.IMAGE_PATH }}
# build-docker:
# runs-on: ubuntu-22.04
# strategy:
# matrix:
# arch: ["amd64", "aarch64"]
# needs: [build-linux-amd64, build-linux-aarch64]
# name: Build Docker Image (${{ matrix.arch }})
# steps:
# - name: Check out repo
# uses: actions/checkout@v3
# - uses: docker/setup-qemu-action@v1
# - name: Setup Nix
# uses: ./.github/actions/setup_nix
# with:
# cachix_cache: ${{ vars.CACHIX_CACHE || 'openlane' }}
# - name: Derivation from Cache
# uses: ./.github/actions/derivation_from_cache
# with:
# key: derivation-${{ matrix.arch }}-${{ github.run_id }}
# other-substituters: "https://${{ vars.CACHIX_CACHE || 'openlane' }}.cachix.org"
# - name: Build Docker Image
# run: |
# if [ "${{ matrix.arch }}" == "aarch64" ]; then
# arch_flags="--option system aarch64-linux --extra-platforms aarch64-linux"
# fi
# IMAGE_PATH=$(nix-build --argstr name openlane --argstr tag-override tmp-${{ matrix.arch }} $arch_flags docker.nix)
# echo "IMAGE_PATH=$IMAGE_PATH" >> $GITHUB_ENV
# cat $IMAGE_PATH | docker load
# - name: Set Up Python
# uses: actions/setup-python@v4
# with:
# python-version: "3.8"
# - name: Install Dependencies
# run: make venv
# - name: Smoke-Test Docker Image
# run: |
# mkdir -p $HOME/.volare
# chmod -R 755 $HOME/.volare
# OPENLANE_IMAGE_OVERRIDE=openlane:tmp-${{ matrix.arch }}\
# ./venv/bin/python3 -m openlane\
# --docker-no-tty\
# --dockerized\
# --smoke-test
# - name: Upload Docker Artifact
# uses: actions/upload-artifact@v3
# with:
# name: docker-image-${{ matrix.arch }}
# path: ${{ env.IMAGE_PATH }}
test:
runs-on: ubuntu-22.04
needs: [build-linux-amd64, prepare-test-matrices]
Expand Down Expand Up @@ -244,10 +244,15 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: metrics
path: ${{ matrix.design.run_folder }}
path: ${{ matrix.design.name }}-${{ matrix.design.pdk }}-${{ matrix.design.scl }}.metrics.json
publish:
runs-on: ubuntu-22.04
needs: [build-linux-amd64, build-mac-amd64, build-docker, build-py]
needs: [
build-linux-amd64,
build-mac-amd64,
# build-docker,
build-py,
]
name: Publish (If Applicable)
steps:
- name: Check out repo
Expand All @@ -263,19 +268,19 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Download Image (Docker/amd64)
uses: actions/download-artifact@v3
with:
name: docker-image-amd64
path: /tmp/docker
- name: Download Image (Docker/aarch64)
uses: actions/download-artifact@v3
with:
name: docker-image-aarch64
path: /tmp/docker
- name: Load Image (Docker)
run: |
cat /tmp/docker/* | docker load
# - name: Download Image (Docker/amd64)
# uses: actions/download-artifact@v3
# with:
# name: docker-image-amd64
# path: /tmp/docker
# - name: Download Image (Docker/aarch64)
# uses: actions/download-artifact@v3
# with:
# name: docker-image-aarch64
# path: /tmp/docker
# - name: Load Image (Docker)
# run: |
# cat /tmp/docker/* | docker load
- name: Push (Docker)
if: ${{ env.PUBLISH == '1' }}
run: |
Expand Down
30 changes: 29 additions & 1 deletion openlane/common/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Generator,
Iterable,
Sequence,
SupportsFloat,
TypeVar,
)

Expand Down Expand Up @@ -205,7 +206,13 @@ def format_size(byte_count: int) -> str:
return f"{so_far}{units[tracker]}"


def format_elapsed_time(elapsed_seconds: float) -> str:
def format_elapsed_time(elapsed_seconds: SupportsFloat) -> str:
"""
:param elapsed_seconds: Total time elapsed in seconds
:returns: A string in the format ``{hours}:{minutes}:{seconds}:{milliseconds}``
"""
elapsed_seconds = float(elapsed_seconds)

hours = int(elapsed_seconds // 3600)
leftover = elapsed_seconds % 3600

Expand All @@ -219,6 +226,16 @@ def format_elapsed_time(elapsed_seconds: float) -> str:


class Filter(object):
"""
Encapsulates commonly used wildcard-based filtering functions into an object.
:param filters: A list of a wildcards supporting the
`fnmatch spec <https://docs.python.org/3.10/library/fnmatch.html>`_.
The wildcards will be split into an "allow" and "deny" list based on whether
the filter is prefixed with a ``!``.
"""

def __init__(self, filters: Iterable[str]):
self.allow = []
self.deny = []
Expand All @@ -229,6 +246,11 @@ def __init__(self, filters: Iterable[str]):
self.allow.append(filter)

def get_matching_wildcards(self, input: str) -> Generator[str, Any, None]:
"""
:param input: An input to match wildcards against.
:returns: An iterable object for *all* wildcards in the allow list accepting
``input``, and *all* wildcards in the deny list rejecting ``input``.
"""
for wildcard in self.allow:
if fnmatch.fnmatch(input, wildcard):
yield wildcard
Expand All @@ -240,6 +262,12 @@ def filter(
self,
inputs: Iterable[str],
) -> Generator[str, Any, None]:
"""
:param inputs: A series of inputs to filter according to the wildcards.
:returns: An iterable object of any values in ``inputs`` that:
* Have matched at least one wildcard in the allow list
* Have matched exactly 0 inputs in the deny list
"""
for input in inputs:
allowed = False
for wildcard in self.allow:
Expand Down
32 changes: 32 additions & 0 deletions test/common/test_misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,35 @@ def test_klayout_xml():
pytest.fail(f"Unexpected error while attempting to parse generated XML: {e}")

assert parsed.find(".//categories/category[1]/name").text == "LU.3"


def test_filter_filter():
from openlane.common import Filter

assert (
list(Filter([]).filter(["a", "b", "c"])) == []
), "filter with no wildcards matches nothing"

assert (
list(Filter(["*", "!b"]).filter(["b"])) == []
), "filter with deny wildcard did not work properly"

assert list(Filter(["*", "!b"]).filter(["b", "be"])) == [
"be"
], "filter with deny wildcard matched too many elements"

assert list(
Filter(["boing*", "!boinger", "boinge*"]).filter(["boingee", "boinger"])
) == ["boingee"], "filter with a mixture of wildcards failed"


def test_filter_all_matching():
from openlane.common import Filter

assert list(Filter(["k", "!b"]).get_matching_wildcards("c")) == [
"b"
], "filter did not accurately return rejecting wildcard"

assert list(Filter(["*", "!c"]).get_matching_wildcards("c")) == [
"*",
], "filter did not accurately return accepting wildcard"

0 comments on commit b56d8f9

Please sign in to comment.