From 23b45e3fb52b3c399bd399bb5f977b300931fdc4 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Thu, 17 Oct 2024 14:13:25 -0700 Subject: [PATCH] update actions --- .github/workflows/build-docs.yml | 43 +++++++++ .github/workflows/publish-pypi.yml | 146 ++++++++++++++++++++++++++++ .github/workflows/pypi-test.yml | 148 ----------------------------- .github/workflows/run-tests.yml | 51 ++++++++++ 4 files changed, 240 insertions(+), 148 deletions(-) create mode 100644 .github/workflows/build-docs.yml create mode 100644 .github/workflows/publish-pypi.yml delete mode 100644 .github/workflows/pypi-test.yml create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000..1d39756 --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,43 @@ +name: Build documentation + +on: + push: + tags: + - "*" + +jobs: + test: + name: Build docs + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + cache: 'pip' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip setuptools + DEPENDENCIES=$(python -c 'from setuptools.config.setupcfg import read_configuration as c; a = c("setup.cfg"); print(" ".join(a["options"]["install_requires"][1:]))') + pip install ${DEPENDENCIES} + DOCDEPENDENCIES=$(python -c 'with open("docs/requirements.txt") as a: available = list(a); print(" ".join(map(lambda x : x.strip(), filter(lambda x : not x.startswith("#"), available))))') + pip install ${DOCDEPENDENCIES} + + - name: Build docs + run: | + touch src/dolomite_base/lib_dolomite_base.py + sphinx-build --color -b html -d docs/doctrees docs docs/_build/html + touch ./docs/_build/html/.nojekyll + + - name: GH Pages Deployment + uses: JamesIves/github-pages-deploy-action@4.1.3 + with: + branch: gh-pages # The branch the action should deploy to. + folder: ./docs/_build/html + clean: true # Automatically remove deleted files from the deploy branch diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..bdbb89c --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,146 @@ +name: Publish to PyPI + +on: + push: + tags: + - "*" + +jobs: + build_linux_x86_64: + name: Build wheels for linux x86_64 + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + env: + CIBW_ARCHS: x86_64 + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/artifactdb/prebuilt-hdf5/manylinux_x86_64:0.0.4 + CIBW_MUSLLINUX_X86_64_IMAGE: ghcr.io/artifactdb/prebuilt-hdf5/musllinux_x86_64:0.0.4 + CIBW_SKIP: pp* + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_macosx_x86_64: + name: Build wheels for macosx x86_64 + runs-on: macos-11 + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Grab prebuilt dependencies + run: | + curl -L https://github.com/ArtifactDB/prebuilt-hdf5/releases/download/0.0.4/macosx_x86_64.tar.gz > bundle.tar.gz + tar -xvf bundle.tar.gz + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + env: + CIBW_ARCHS: x86_64 + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=$(pwd)/installed -DCMAKE_OSX_ARCHITECTURES=x86_64\"" + CIBW_BUILD_VERBOSITY: 3 + CIBW_SKIP: pp* + MACOSX_DEPLOYMENT_TARGET: 11.7 + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_macosx_arm64: + name: Build wheels for macosx arm64 + runs-on: macos-13 + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Grab prebuilt dependencies + run: | + curl -L https://github.com/ArtifactDB/prebuilt-hdf5/releases/download/0.0.4-manual/macosx_arm64.tar.gz > bundle.tar.gz + tar -xvf bundle.tar.gz + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + env: + CIBW_ARCHS: arm64 + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=$(pwd)/installed -DCMAKE_OSX_ARCHITECTURES=arm64\"" + CIBW_BUILD_VERBOSITY: 3 + MACOSX_DEPLOYMENT_TARGET: 13.0 + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + +# build_windows_x86_64: +# name: Build wheels for windows x86_64 +# runs-on: windows-2019 +# steps: +# - name: Check out repository +# uses: actions/checkout@v3 +# +# - name: Grab prebuilt dependencies +# run: | +# curl -L https://github.com/ArtifactDB/prebuilt-hdf5/releases/download/0.0.4/windows_x86_64.tar.gz > bundle.tar.gz +# tar -xvf bundle.tar.gz +# shell: bash +# +# - name: Store path +# run: | +# $wd = pwd +# echo "INSTALL_DIR=$wd\\installed" >> $env:GITHUB_ENV +# shell: powershell +# +# - name: Build wheels +# uses: pypa/cibuildwheel@v2.16.2 +# env: +# CIBW_ARCHS: AMD64 +# CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" +# CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}\" VERBOSE=1" +# CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" +# CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" +# CIBW_TEST_EXTRAS: "testing" +# CIBW_TEST_COMMAND: "pytest {package}/tests" +# CIBW_BUILD_VERBOSITY: 3 + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + upload_pypi: + needs: [build_linux_x86_64, build_macosx_x86_64, build_macosx_arm64, build_sdist] + runs-on: ubuntu-latest + # upload to PyPI on every tag starting with 'v' + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/download-artifact@v3 + with: + # unpacks default artifact into dist/ + # if `name: artifact` is omitted, the action will create extra parent dir + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@v1.8.3 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/pypi-test.yml b/.github/workflows/pypi-test.yml deleted file mode 100644 index a91bd99..0000000 --- a/.github/workflows/pypi-test.yml +++ /dev/null @@ -1,148 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Test the library - -on: - push: - branches: - - master - tags: - - "*" - pull_request: - -jobs: - test: - name: Running tests - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: "Install system dependencies" - run: | - sudo apt-get install zlib1g-dev - - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - cache: 'pip' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools - DEPENDENCIES=$(python -c 'from setuptools.config.setupcfg import read_configuration as c; a = c("setup.cfg"); print(" ".join(a["options"]["install_requires"][1:] + a["options"]["extras_require"]["testing"][1:]))') - pip install ${DEPENDENCIES} - - - name: Download rds2cpp deps - run: | - cd extern/rds2cpp - cmake . - cd ../.. - - # We do proper tests if we're on the master branch, or if we're creating a new release. - - name: Test with tox - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: | - pip install tox - tox - - - name: Build docs - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: | - tox -e docs - touch ./docs/_build/html/.nojekyll - - # Otherwise we do some cached builds and tests for faster merging of PRs. - - name: Set up ccache - if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') - uses: hendrikmuhs/ccache-action@v1.2 - - - name: Quickly build and test - if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') - run: | - CC="ccache gcc" python setup.py install - pytest - - - name: GH Pages Deployment - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - uses: JamesIves/github-pages-deploy-action@4.1.3 - with: - branch: gh-pages # The branch the action should deploy to. - folder: ./docs/_build/html - clean: true # Automatically remove deleted files from the deploy branch - - build_wheels: - name: Build wheels on ${{ matrix.os }} - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04, macos-13] # at some point get this to work on windows-2019 - - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Download rds2cpp deps - run: | - cd extern/rds2cpp - cmake . - cd ../.. - - - name: Build wheels - uses: pypa/cibuildwheel@v2.12.1 - env: - CIBW_ARCHS_MACOS: x86_64 arm64 - CIBW_ARCHS_LINUX: x86_64 # remove this later so we build for all linux archs - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" - CIBW_SKIP: pp* # remove this later, but for some reason fails to generate pypy wheels - - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Download rds2cpp deps - run: | - cd extern/rds2cpp - cmake . - cd ../.. - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - - upload_pypi: - needs: [test, build_wheels, build_sdist] - runs-on: ubuntu-latest - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' - steps: - - uses: actions/download-artifact@v3 - with: - # unpacks default artifact into dist/ - # if `name: artifact` is omitted, the action will create extra parent dir - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@v1.8.3 - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..5c8d6b1 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,51 @@ +name: Run unit tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] + + name: Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip setuptools + DEPENDENCIES=$(python -c 'from setuptools.config.setupcfg import read_configuration as c; a = c("setup.cfg"); print(" ".join(a["options"]["install_requires"][1:] + a["options"]["extras_require"]["testing"][1:]))') + pip install ${DEPENDENCIES} pybind11 + + # We do proper tests if we're on the master branch, or if we're creating a new release. + - name: Test with tox + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + run: | + pip install tox + tox + + # Otherwise we do some cached builds and tests for faster merging of PRs. + - name: Set up ccache + if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') + uses: hendrikmuhs/ccache-action@v1.2 + + - name: Quickly build and test + if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') + run: | + CC="ccache gcc" python setup.py install + pytest