Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ci/cd for github actions #1070

Merged
merged 34 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1f4422f
add ci/cd for github actions
joamatab Apr 28, 2022
f73e8fd
fix workflow and add workflow_dispatch
joamatab Apr 28, 2022
6b2b4ca
remove dist
joamatab Apr 28, 2022
575b769
fix
joamatab Apr 28, 2022
d215c8c
add gcc
joamatab Apr 28, 2022
4550504
sudo apt install build essential
joamatab Apr 28, 2022
dd0573b
add curl
joamatab May 1, 2022
9d70be0
install curl
joamatab May 1, 2022
e6d9a95
build essential
joamatab May 1, 2022
84f7789
update
joamatab May 1, 2022
69db193
test code on mac os
joamatab May 1, 2022
a39955d
release on tagged version
joamatab May 1, 2022
4171b6e
better names
joamatab May 1, 2022
eb5b252
fix numbers for 3.10
joamatab May 1, 2022
2412920
add cancel workflow for tests
joamatab May 1, 2022
36c36c0
fix test macOs
joamatab May 2, 2022
1708d88
Adding ccache to github action
thomaslima May 2, 2022
a3f37b4
creating dependency between jobs
thomaslima May 2, 2022
da67d8f
using cibuildwheel
thomaslima May 2, 2022
809e2a6
ccache path bug
thomaslima May 2, 2022
05d402b
Testing after building wheels
thomaslima May 2, 2022
7f8c27a
misunderstood cibuildwheel
thomaslima May 2, 2022
2aa74fa
fixing error in manylinux build
thomaslima May 2, 2022
30a39f4
fixing error in manylinux build (2)
thomaslima May 2, 2022
fd46957
disabling fail fast (temporary)
thomaslima May 2, 2022
de7d9f2
Don't repair macOS wheels
thomaslima May 2, 2022
67b0809
Not building pypy wheels
thomaslima May 3, 2022
6623c89
disabling 32-bit linux wheels
thomaslima May 3, 2022
37bde8e
macos-latest only (prevent duplicate)
thomaslima May 3, 2022
3223888
fixing musllinux
thomaslima May 3, 2022
54e89e9
fixing ccache
thomaslima May 3, 2022
b259465
fixing cache persistence
thomaslima May 4, 2022
597e7ee
adding deploy job
thomaslima May 5, 2022
0c324f7
last debug
thomaslima May 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
name: Build Python Wheels
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python

on:
pull_request:
push:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 12
matrix:
include:
- os: "macos-latest"
cibuild: "*macosx*"
- os: "ubuntu-latest"
cibuild: "*manylinux*"
- os: "ubuntu-latest"
cibuild: "*musllinux*"
steps:
- name: Cancel Workflow Action
uses: styfle/[email protected]
- uses: actions/checkout@v3
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.cibuild }} # Make cache specific to OS
max-size: "5G"
- name: Install dependencies
run: |
env
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
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/[email protected]
# to supply options, put them in 'env', like:
# env:
# CIBW_SOME_OPTION: value
env:
CIBW_BUILD: ${{ matrix.cibuild }}
- name: Download Cache from Docker (linux only)
if: ${{ runner.os == 'Linux' }}
# hack until https://github.com/pypa/cibuildwheel/issues/1030 is fixed
run: |
env
ccache -s
HOST_CCACHE_DIR="$(ccache -k cache_dir)"
rm -rf $HOST_CCACHE_DIR
mv ./wheelhouse/.ccache $HOST_CCACHE_DIR
ls -la $HOST_CCACHE_DIR
ccache -s
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

# 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

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_all:
needs: [build, make_sdist]
runs-on: ubuntu-latest
# Uncomment for real PyPi
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
# Test PyPI
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
# Uncomment for Real Pypi
# password: ${{ secrets.pypi_password }}
50 changes: 50 additions & 0 deletions ci-scripts/docker/docker_prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -xe

# manylinux prep
if [[ -f "/etc/centos-release" ]]; then
# sometimes the epel server is down. retry 5 times
for i in $(seq 1 5); do
yum install -y zlib-devel curl-devel expat-devel ccache && s=0 && break || s=$? && sleep 15;
done

[ $s -eq 0 ] || exit $s

if [[ -d "/usr/lib64/ccache" ]]; then
ln -s /usr/bin/ccache /usr/lib64/ccache/c++
ln -s /usr/bin/ccache /usr/lib64/ccache/cc
ln -s /usr/bin/ccache /usr/lib64/ccache/gcc
ln -s /usr/bin/ccache /usr/lib64/ccache/g++
export PATH="/usr/lib64/ccache:$PATH"
elif [[ -d "/usr/lib/ccache" ]]; then
ln -s /usr/bin/ccache /usr/lib/ccache/c++
ln -s /usr/bin/ccache /usr/lib/ccache/cc
ln -s /usr/bin/ccache /usr/lib/ccache/gcc
ln -s /usr/bin/ccache /usr/lib/ccache/g++
export PATH="/usr/lib/ccache:$PATH"
fi

elif [[ -f "/etc/alpine-release" ]]; then
# musllinux prep
# ccache already present
apk add curl-dev expat-dev zlib-dev ccache
export PATH="/usr/lib/ccache/bin:$PATH"
fi

# hack until https://github.com/pypa/cibuildwheel/issues/1030 is fixed
# Place ccache folder in /outputs
HOST_CCACHE_DIR="/host${HOST_CCACHE_DIR:-/home/runner/work/klayout/klayout/.ccache}"
if [ -d $HOST_CCACHE_DIR ]; then
mkdir -p /output
cp -R $HOST_CCACHE_DIR /output/.ccache
fi

ls -la /output/

ccache -o cache_dir="/output/.ccache"
# export CCACHE_DIR="/host/home/runner/work/klayout/klayout/.ccache"
ccache -M 5 G # set cache size to 5 G

# Show ccache stats
echo "Cache stats:"
ccache -s
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tool.cibuildwheel]
build-verbosity = "3"
test-command = [
"python {package}/testdata/pymod/import_db.py",
"python {package}/testdata/pymod/import_rdb.py",
"python {package}/testdata/pymod/import_tl.py",
"python {package}/testdata/pymod/import_lib.py",
"python {package}/testdata/pymod/pya_tests.py"
]
# Disable building PyPy wheels on all platforms
skip = "pp*"

[tool.cibuildwheel.linux]
# beware: the before-all script does not persist environment variables!
# No point in defining $PATH or $CCACHE_DIR
before-all = "source {project}/ci-scripts/docker/docker_prepare.sh"
archs = ["auto64"]
# Append a directory to the PATH variable (this is expanded in the build environment)
environment = { PATH="/usr/lib/ccache:/usr/lib64/ccache:/usr/lib/ccache/bin:$PATH" }
before-build = "ccache -s"
# Export a variable to docker
# CCACHE_DIR="/home/runner/work/klayout/klayout/.ccache"
environment-pass = ["HOST_CCACHE_DIR"]

[tool.cibuildwheel.macos]
# Don't repair macOS wheels
repair-wheel-command = ""