Fix CI #54
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
jobs: | |
build-wheel: | |
name: "🏗️ Python wheel" | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 | |
- name: "🏗️ Build Python wheel" | |
run: python -m build | |
- name: "🧪 Check package bundles" | |
run: twine check dist/* | |
- name: "📤 Upload Python wheel" | |
uses: actions/upload-artifact@v3 | |
if: matrix.python == '3.11' && matrix.os == 'ubuntu-latest' | |
with: | |
name: wheel | |
path: dist/* | |
build-image: | |
name: "🚀 Build image" | |
needs: | |
- build-wheel | |
runs-on: ubuntu-latest | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- name: "🧰 Set up QEMU" | |
uses: docker/setup-qemu-action@v2 | |
- name: "🧰 Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v2 | |
- name: "🚀 Build image" | |
uses: docker/build-push-action@v1 | |
with: | |
context: . | |
push: false | |
code-format: | |
name: "🔍 Python code format" | |
needs: | |
- build-wheel | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 . | |
pip install .[test] | |
- name: "🔍 Check Python code format" | |
run: flake8 ir_axioms/ tests/ | |
lint: | |
name: "🔍 Python Lint" | |
needs: | |
- build-wheel | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 . | |
pip install .[test] | |
- name: "🔍 Lint Python code" | |
run: pylint -E ir_axioms tests.unit --ignore-paths=^ir_axioms.backend --ignore-paths=^ir_axioms.cli | |
lint-backend: | |
name: "🔍 Python Lint backend" | |
needs: | |
- build-wheel | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
backend: | |
- pyserini | |
- pyterrier | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 . | |
pip install .[test] | |
pip install .[${{ matrix.backend }}] | |
- name: "🧰 Install Java" | |
uses: actions/setup-java@v2 | |
with: | |
distribution: temurin | |
java-version: 11 | |
- name: "🔍 Lint Python code" | |
run: pylint -E ir_axioms.backend.${{ matrix.backend }} tests.integration.${{ matrix.backend }} ${{ matrix.backend == 'pyterrier' && 'ir_axioms.cli' }} | |
unit-tests: | |
name: "🧪 Python unit tests" | |
needs: | |
- build-wheel | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 . | |
pip install .[test] | |
- name: "🧪 Test Python code" | |
run: pytest --cov=./ --cov-report=xml ir_axioms/ tests/unit/ --ignore=ir_axioms/backend/ --ignore=ir_axioms/cli.py | |
- name: "📤 Upload coverage to Codecov" | |
uses: codecov/codecov-action@v2 | |
if: matrix.python == '3.11' && matrix.os == 'ubuntu-latest' | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
integration-tests: | |
name: "🧪 Python integration tests" | |
needs: | |
- build-wheel | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- 3.10 | |
- 3.11 | |
backend: | |
- pyserini | |
- pyterrier | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- 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 . | |
pip install .[test] | |
pip install .[${{ matrix.backend }}] | |
- name: "🧰 Install Java" | |
uses: actions/setup-java@v2 | |
with: | |
distribution: temurin | |
java-version: 11 | |
- name: "🧪 Test Python code" | |
run: pytest --cov=./ --cov-report=xml tests/integration/${{ matrix.backend }}/ ${{ matrix.backend == 'pyterrier' && 'ir_axioms/cli.py' }} | |
- name: "📤 Upload coverage to Codecov" | |
uses: codecov/codecov-action@v2 | |
if: matrix.python == '3.11' && matrix.os == 'ubuntu-latest' | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
publish-package: | |
name: "🚀 Publish Python package" | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
needs: | |
- build-wheel | |
- build-image | |
- code-format | |
- lint | |
- lint-backend | |
- unit-tests | |
- integration-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- name: "📥 Download Python wheel" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheel | |
path: dist/* | |
- name: "🚀 Publish Python package" | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
push-image: | |
name: "🚀 Push image" | |
needs: | |
- build-wheel | |
- build-image | |
- code-format | |
- lint | |
- lint-backend | |
- unit-tests | |
- integration-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- name: "🧰 Set up QEMU" | |
uses: docker/setup-qemu-action@v2 | |
- name: "🧰 Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v2 | |
- name: "🔑 Login to the GitHub Container registry" | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "ℹ️ Extract image metadata" | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
- name: "🚀 Build and push image" | |
uses: docker/build-push-action@v1 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
github-release: | |
name: "🚀 Create GitHub release" | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
needs: | |
- build-wheel | |
- build-image | |
- code-format | |
- lint | |
- lint-backend | |
- unit-tests | |
- integration-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: "📥 Check-out" | |
uses: actions/checkout@v3 | |
- name: "🏷️ Get version tag" | |
id: get-version | |
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//} | |
- name: "📥 Download Python wheel" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheel | |
path: dist/* | |
- 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 |