From 14e2a53a0749d9b46a46bcb2141cfc1edc05e896 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 28 Jul 2023 15:51:37 -0400 Subject: [PATCH] Add tox --- .github/workflows/ci.yml | 124 +++++++++++++++++++++++++++++++++++ .github/workflows/wheels.yml | 64 ------------------ tox.ini | 9 +++ 3 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d079ef006 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,124 @@ +name: Build + +on: + push: + # workflow_dispatch: + pull_request: + branches: + - master + release: + types: + - created + schedule: + - cron: "0 7 * * 1" + + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python: ["3.7", "3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: | + pip install --upgrade pip + pip install tox tox-gh-actions + - name: Run tox + env: + PYTEST_ADDOPTS: "--durations=0 -vv" + run: | + tox + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - uses: nikeee/setup-pandoc@v1 + - name: Install tox + run: | + pip install --upgrade pip + pip install tox + - name: Run tox for lint and docs + run: | + tox -e flake8,docs + - uses: actions/upload-artifact@v3 + with: + name: docs + path: ./docs/_build + # TODO: + # publish this if merged to master or a tag + build_wheels: + # needs: + # - test + # - lint + name: Build wheels on ${{ matrix.buildplat[0] }} / ${{ matrix.buildplat[1] }} for ${{ matrix.python }} + runs-on: ${{ matrix.buildplat[0] }} + strategy: + matrix: + buildplat: + - [ubuntu-22.04, manylinux_x86_64] + - [ubuntu-22.04, musllinux_x86_64] + - [macos-12, macosx_*] + - [windows-2019, win_amd64] + python: ["cp37", "cp38", "cp39", "cp310", "cp311"] + exclude: + - buildplat: + - [windows-2019, win32] + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: git status && git tag --list && pwd + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Build wheels + uses: pypa/cibuildwheel@v2.14.1 + env: + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} + path: ./wheelhouse/*.whl + +# # docs-deploy +# publish: +# runs-on: ubuntu-latest +# needs: +# - build_wheels +# - test +# - lint +# # - docker +# steps: +# - uses: actions/setup-python@v2 +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# pip install setuptools wheel twine +# - uses: actions/download-artifact@v2 +# with: +# path: artifacts +# - name: Publish artifacts +# env: +# TWINE_USERNAME: secrets.TWINE_USERNAME +# TWINE_PASSWORD: secrets.TWINE_PASSWORD +# TWINE_REPOSITORY_URL: secrets.TWINE_REPOSITORY_URL +# shell: bash +# working-directory: artifacts +# run: | +# ls -alR +# for i in $( ls ); do +# cat $i/$ARTIFACT +# done diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index 56d46105d..000000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build - -on: [workflow_dispatch] - -jobs: - # TODO: - # publish this if merged to master or a tag - build_wheels: - name: Build wheels on ${{ matrix.buildplat[0] }} / ${{ matrix.buildplat[1] }} for ${{ matrix.python }} - runs-on: ${{ matrix.buildplat[0] }} - strategy: - matrix: - buildplat: - - [ubuntu-20.04, manylinux_x86_64] - - [ubuntu-20.04, musllinux_x86_64] - - [macos-12, macosx_*] - - [windows-2019, win_amd64] - - [windows-2019, win32] - python: ["cp37", "cp38", "cp39", "cp310", "cp311"] - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - run: git status && git tag --list && pwd - - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - - name: Build wheels - uses: pypa/cibuildwheel@v2.12.0 - env: - CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} - - - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} - path: ./wheelhouse/*.whl - - publish: - runs-on: ubuntu-latest - needs: build_wheels - steps: - - uses: actions/setup-python@v2 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - uses: actions/download-artifact@v2 - with: - path: artifacts - - name: Publish artifacts - env: - TWINE_USERNAME: secrets.TWINE_USERNAME - TWINE_PASSWORD: secrets.TWINE_PASSWORD - TWINE_REPOSITORY_URL: secrets.TWINE_REPOSITORY_URL - shell: bash - working-directory: artifacts - run: | - ls -alR - for i in $( ls ); do - cat $i/$ARTIFACT - done diff --git a/tox.ini b/tox.ini index 0a0238e6e..7d62c8e75 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ toxworkdir = {toxinidir}/.tox passenv = DOCKER_* GENERATE_GROUNDTRUTH + PYTEST_* # This adds the tests directory to the python path so we can import the test # utilities as needed. setenv = @@ -138,3 +139,11 @@ parallel = True [coverage:xml] output = .tox/coverage/py_coverage.xml + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311