From a32a6eef8c0bffe397a90907bcd45bea53645180 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Mon, 29 May 2023 17:17:22 -0400 Subject: [PATCH 1/4] Update build.yml - enable builds on main branch pull requests should be able to access cache from main branch (caching is useless otherwise). --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c79fc93b85..8cb52eab22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,11 @@ name: Build Python Wheels on: pull_request: - # Running on PRs is enough - # push: + # Running on PRs and main branch only + # pull requests should be able to access cache from main branch + push: + branches: + - master release: types: [published] From c81c2d6eec3e6101080168a3514b94876e8b640c Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Mon, 29 May 2023 17:36:20 -0400 Subject: [PATCH 2/4] autodelete github Action caches after PR is merged Caches are very large and must be deleted to prioritize main branch's caches. --- .github/workflows/cache-maintenance.yml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/cache-maintenance.yml diff --git a/.github/workflows/cache-maintenance.yml b/.github/workflows/cache-maintenance.yml new file mode 100644 index 0000000000..ec933b1f1b --- /dev/null +++ b/.github/workflows/cache-maintenance.yml @@ -0,0 +1,35 @@ +name: cleanup caches by a branch +# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries +# Caches are very large and must be deleted to prioritize main branch's caches. +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 15614221cee578fb6541e264454adfa37b995130 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 31 May 2023 15:39:03 -0400 Subject: [PATCH 3/4] make_stubs now automatically detects installed klayout in python environment. --- .github/workflows/build.yml | 9 +++---- scripts/make_stubs.sh | 54 ++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c79fc93b85..c29e074230 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,15 +71,12 @@ jobs: with: path: ./wheelhouse/*.whl -# The following was taken from https://cibuildwheel.readthedocs.io/en/stable/deliver-to-pypi/ + # The following was taken from https://cibuildwheel.readthedocs.io/en/stable/deliver-to-pypi/ make_sdist: name: Make SDist runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Optional, use if you use setuptools_scm - submodules: true # Optional, use if you have submodules + - uses: actions/checkout@v3 - name: Build SDist run: pipx run build --sdist @@ -102,7 +99,7 @@ jobs: with: user: __token__ password: ${{ secrets.test_pypi_password }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ upload_to_pypi: needs: [build, make_sdist] diff --git a/scripts/make_stubs.sh b/scripts/make_stubs.sh index 1df806a28a..b5fc4a9f9e 100755 --- a/scripts/make_stubs.sh +++ b/scripts/make_stubs.sh @@ -1,29 +1,40 @@ #!/bin/bash -e -# Generates LVS and DRC documentation +# Generates pyi stubs # # Run this script from a valid build below the repository root, e.g. -# /build-debug. It needs to have a "pymod" installation in +# /build-debug. It needs to have a "pymod" installation in # current directory. inst=$(realpath $(dirname $0)) -scripts=${inst}/drc_lvs_doc -ld=$(realpath .) -pymod="$ld/pymod" +## Detect if klayout pymod libraries are installed +python= +for try_python in python python3; do + if $try_python -c "import klayout.tl" >/dev/null 2>&1; then + python=$try_python + fi +done -export LD_LIBRARY_PATH=$ld -export PYTHONPATH=$pymod +if [ "$python" = "" ]; then + echo "*** Searching for pymod..." -pymod_src=$ld/../src/pymod -if ! [ -e $pymod_src ]; then - echo "*** ERROR: missing pymod sources ($pymod_src) - did you run the script from the build folder below the source tree?" - exit 1 -fi + ld=$(realpath .) + pymod="$ld/pymod" -if ! [ -e $pymod ]; then - echo "*** ERROR: missing pymod folder ($pymod) - did you run the script from the build folder?" - exit 1 + export LD_LIBRARY_PATH=$ld + export PYTHONPATH=$pymod + + pymod_src=$ld/../src/pymod + if ! [ -e $pymod_src ]; then + echo "*** ERROR: missing pymod sources ($pymod_src) - did you run the script from the build folder below the source tree?" + exit 1 + fi + + if ! [ -e $pymod ]; then + echo "*** ERROR: missing pymod folder ($pymod) - did you run the script from the build folder?" + exit 1 + fi fi python= @@ -38,20 +49,21 @@ if [ "$python" = "" ]; then exit 1 fi +pyi_srcdir="$inst/../src/pymod/distutils_src/klayout" + echo "Generating stubs for tl .." -$python $inst/stubgen.py tl >$pymod_src/distutils_src/klayout/tlcore.pyi +$python $inst/stubgen.py tl >$pyi_srcdir/tlcore.pyi echo "Generating stubs for db .." -$python $inst/stubgen.py db tl >$pymod_src/distutils_src/klayout/dbcore.pyi +$python $inst/stubgen.py db tl >$pyi_srcdir/dbcore.pyi echo "Generating stubs for rdb .." -$python $inst/stubgen.py rdb tl,db >$pymod_src/distutils_src/klayout/rdbcore.pyi +$python $inst/stubgen.py rdb tl,db >$pyi_srcdir/rdbcore.pyi echo "Generating stubs for lay .." -$python $inst/stubgen.py lay tl,db,rdb >$pymod_src/distutils_src/klayout/laycore.pyi +$python $inst/stubgen.py lay tl,db,rdb >$pyi_srcdir/laycore.pyi echo "Generating stubs for lib .." -$python $inst/stubgen.py lib tl,db >$pymod_src/distutils_src/klayout/libcore.pyi +$python $inst/stubgen.py lib tl,db >$pyi_srcdir/libcore.pyi echo "Done." - From 9d9de0bca19dd326541a940156089a14a7e2acf3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:59:14 +0000 Subject: [PATCH 4/4] Bump pypa/cibuildwheel from 2.12.3 to 2.13.0 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.12.3 to 2.13.0. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.12.3...v2.13.0) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c79fc93b85..9bd3facdd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: HOST_CCACHE_DIR="$(ccache -k cache_dir)" mkdir -p $HOST_CCACHE_DIR - name: Build wheels # check https://cibuildwheel.readthedocs.io/en/stable/setup/#github-actions - uses: pypa/cibuildwheel@v2.12.3 + uses: pypa/cibuildwheel@v2.13.0 # to supply options, put them in 'env', like: # env: # CIBW_SOME_OPTION: value