Skip to content

Commit

Permalink
Simplify CI
Browse files Browse the repository at this point in the history
  • Loading branch information
janheinrichmerker committed Aug 9, 2023
1 parent a39ff72 commit 5b6e2ff
Showing 1 changed file with 137 additions and 163 deletions.
300 changes: 137 additions & 163 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,190 +4,164 @@ on:
push:

jobs:
build-wheel:
name: "🏗️ Python wheel"
python-build:
name: "🏗️ Build Python wheels"
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
python:
- 3.7
- 3.9
runs-on: ${{ matrix.os }}
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip build twine
pip install -e .
- name: "🏗️ Build Python wheel"
run: python -m build
- name: "🧪 Check package bundles"
run: twine check dist/*
code-format:
name: "🔍 Python code format"
needs:
- build-wheel
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: pip install build twine
- name: "🏗️ Build Python wheels"
run: python -m build
- name: "🧪 Check package bundles"
run: twine check dist/*
- name: "📤 Upload Python wheels"
uses: actions/upload-artifact@v3
if: matrix.python == '3.11'
with:
name: wheels
path: dist
python-code-format:
name: "🔍 Check Python code format"
strategy:
matrix:
os:
- ubuntu-latest
python:
- 3.7
- 3.9
runs-on: ${{ matrix.os }}
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -e .[test]
- name: "🔍 Check Python code format"
run: flake8 chatnoir_api examples tests
lint:
name: "🔍 Python Lint"
needs:
- build-wheel
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: pip install .[test]
- name: "🔍 Check Python code format"
run: flake8 chatnoir_api tests examples
python-lint:
name: "🔍 Lint Python code"
strategy:
matrix:
os:
- ubuntu-latest
python:
- 3.7
- 3.9
runs-on: ${{ matrix.os }}
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -e .[test]
- name: "🔍 Lint Python code"
run: pylint -E chatnoir_api examples tests
unit-tests:
name: "🧪 Python unit tests"
needs:
- build-wheel
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: pip install .[test]
- name: "🔍 Lint Python code"
run: pylint -E chatnoir_api tests examples
python-test:
name: "🧪 Test Python code"
strategy:
matrix:
os:
- ubuntu-latest
python:
- 3.7
- 3.9
runs-on: ${{ matrix.os }}
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -e .[test]
- name: "🧪 Test Python code"
env:
CHATNOIR_API_KEY: ${{ secrets.CHATNOIR_API_KEY }}
CHATNOIR_API_KEY_STAGING: ${{ secrets.CHATNOIR_API_KEY_STAGING }}
CHATNOIR_API_KEY_CHAT: ${{ secrets.CHATNOIR_API_KEY_CHAT }}
run: pytest chatnoir_api examples tests --cov --cov-report=term --cov-report=xml
- name: "📤 Upload test coverage"
uses: actions/upload-artifact@v2
with:
path: coverage.xml
name: Python test coverage
- name: "📤 Publish test coverage"
uses: codecov/codecov-action@v1
publish:
name: "🚀 Publish Python package"
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: pip install .[test]
- name: "🧪 Test Python code"
env:
CHATNOIR_API_KEY: ${{ secrets.CHATNOIR_API_KEY }}
CHATNOIR_API_KEY_STAGING: ${{ secrets.CHATNOIR_API_KEY_STAGING }}
CHATNOIR_API_KEY_CHAT: ${{ secrets.CHATNOIR_API_KEY_CHAT }}
run: pytest --cov --cov-report=xml chatnoir_api tests examples
- name: "📤 Upload coverage to Codecov"
uses: codecov/codecov-action@v3
if: matrix.python == '3.9'
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
python-publish:
name: "🚀 Publish Python wheels"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- code-format
- lint
- unit-tests
- python-build
- python-code-format
- python-lint
- python-tests
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip build
pip install -e .
- name: "🏗️ Build Python wheel"
run: python -m build
- name: "🚀 Publish Python package"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
release:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "📥 Download Python wheels"
uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: "🚀 Publish Python wheels"
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: "🚀 Create GitHub release"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- code-format
- lint
- unit-tests
runs-on: ubuntu-20.04
- python-build
- python-code-format
- python-lint
- python-tests
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v2
- name: "🏷️ Get version tag"
id: get-version
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: "🧰 Install Python"
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip build
pip install -e .
- name: "🏗️ Build Python wheel"
run: python -m build
- name: "🚀 Create GitHub release"
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get-version.outputs.tag }}
files: dist/*
fail_on_unmatched_files: true
draft: false
prerelease: false
generate_release_notes: true
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "📥 Download Python wheels"
uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: "🚀 Create GitHub release"
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
files: dist/*
fail_on_unmatched_files: true
draft: false
prerelease: false
generate_release_notes: true

0 comments on commit 5b6e2ff

Please sign in to comment.