From 89bbe9a3ff4be1b31304f6cc9a8a4560220fca55 Mon Sep 17 00:00:00 2001 From: tommyod Date: Sun, 1 Sep 2024 22:26:17 +0200 Subject: [PATCH] mre --- .github/workflows/build.yaml | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..a922d78 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,112 @@ +name: CI/CD + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + workflow_dispatch: + +jobs: + test_and_build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e .[dev,test,lint] + pip install cibuildwheel==2.15.0 + + - name: Run tests and linting + run: | + black KDEpy -l 120 --check + flake8 --show-source --ignore=F811,W293,W391,W292,W291,W504,W503,E231 --max-line-length=120 --exclude="*examples.py,testing.py,*kde.py" KDEpy + pytest KDEpy --doctest-modules --capture=sys + + - name: Build wheels + env: + CIBW_BUILD: cp${{ matrix.python-version == '3.10' && '310' || matrix.python-version == '3.11' && '311' || matrix.python-version == '3.12' && '312' || matrix.python-version }}* + CIBW_ARCHS_MACOS: x86_64 arm64 + CIBW_SKIP: pp* *-musllinux_* *-manylinux_i686 + run: | + python -m cibuildwheel --output-dir wheelhouse + + - name: Build source distribution + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' + run: | + pip install build + python -m build --sdist --outdir dist + + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: | + wheelhouse/*.whl + dist/*.tar.gz + + build_docs: + runs-on: ubuntu-latest + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Cache pip packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-docs-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-docs- + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e .[dev] + sudo apt install pandoc -y + - name: Build docs + run: sphinx-build docs/source _build/html -W + - name: Store documentation + uses: actions/upload-artifact@v3 + with: + name: documentation + path: _build/html + + publish: + needs: [test_and_build, build_docs] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + steps: + - uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06 + with: + skip-existing: true + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}