Skip to content

Update dependencies for v1.2 release #894

Update dependencies for v1.2 release

Update dependencies for v1.2 release #894

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
tags:
- '*'
pull_request:
workflow_dispatch:
env:
PIPX_HOME: "/home/runner/.cache/pipx"
PIPX_BIN_DIR: "/home/runner/.local/bin"
POETRY_VERSION: "1.8.2"
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-22.04
name: lint with isort, Black & flake8
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: "Prepare: restore caches, install Poetry, set up Python"
uses: ./.github/actions/prepare
with:
python-version: "3.11"
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install Python dev dependencies
run: |
poetry install --only dev
- name: Lint with isort
run: |
poetry run isort . --check-only --diff
- name: Lint with Black
run: |
poetry run black . --check --diff
- name: Lint with flake8
run: |
poetry run flake8
time-startup:
runs-on: ubuntu-22.04
name: check CLI startup time
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: "Prepare: restore caches, install Poetry, set up Python"
id: prepare
uses: ./.github/actions/prepare
with:
python-version: "3.10"
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install Python dependencies
run: |
poetry install
- name: Check startup time
run: |
poetry run tests/time-startup.sh
test:
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: test on Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Install system packages
run: |
sudo apt-get install \
libvoikko1 \
voikko-fi
- name: "Prepare: restore caches, install Poetry, set up Python"
id: prepare
uses: ./.github/actions/prepare
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install Python dependencies
run: |
# Selectively install the optional dependencies for some Python versions
# For Python 3.9:
if [[ ${{ matrix.python-version }} == '3.9' ]]; then
poetry install -E "nn omikuji yake voikko stwfsa";
fi
# For Python 3.10:
if [[ ${{ matrix.python-version }} == '3.10' ]]; then
poetry install -E "fasttext spacy";
# download the small English pretrained spaCy model needed by spacy analyzer
poetry run python -m spacy download en_core_web_sm --upgrade-strategy only-if-needed
fi
# For Python 3.11:
if [[ ${{ matrix.python-version }} == '3.11' ]]; then
poetry install -E "nn fasttext yake stwfsa voikko spacy";
# download the small English pretrained spaCy model needed by spacy analyzer
poetry run python -m spacy download en_core_web_sm --upgrade-strategy only-if-needed
fi
# For Python 3.12:
if [[ ${{ matrix.python-version }} == '3.12' ]]; then
poetry install -E "fasttext yake voikko spacy";
# download the small English pretrained spaCy model needed by spacy analyzer
poetry run python -m spacy download en_core_web_sm --upgrade-strategy only-if-needed
fi
poetry run python -m nltk.downloader punkt_tab
- name: Test with pytest
run: |
poetry run pytest --cov=./ --cov-report xml
if [[ ${{ matrix.python-version }} == '3.10' ]]; then
poetry run pytest --cov=./ --cov-report xml --cov-append -m slow
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Save cache
if: steps.prepare.outputs.cache-matched-key != format('poetry-installation-and-cache-{0}-{1}-{2}', matrix.python-version, env.POETRY_VERSION, hashFiles('**/poetry.lock'))
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
~/.cache/pipx/venvs
~/.local/bin
~/.cache/pypoetry/
# A new key is created to update the cache if some dependency has been updated
key: poetry-installation-and-cache-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
test-docker-image:
name: "test Docker image"
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: "Build image for testing"
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
push: false
tags: test-image
- name: "Test with pytest"
run: |
docker run --rm --workdir /Annif test-image pytest -p no:cacheprovider
publish-docker-latest:
name: publish latest Docker image
needs: [lint, test, test-docker-image]
runs-on: ubuntu-22.04
timeout-minutes: 15
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Login to Quay.io
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: quay.io
username: ${{ secrets.YHTEENTOIMIVUUSPALVELUT_QUAY_IO_USERNAME }}
password: ${{ secrets.YHTEENTOIMIVUUSPALVELUT_QUAY_IO_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: quay.io/natlibfi/annif
tags: |
latest
- name: Build and push to Quay.io
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-release:
name: publish release
needs: [lint, test, test-docker-image]
runs-on: ubuntu-22.04
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: "Prepare: restore caches, install Poetry, set up Python"
uses: ./.github/actions/prepare
with:
python-version: '3.10'
poetry-version: ${{ env.POETRY_VERSION }}
- name: Build and publish distribution to PyPI
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: __token__
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry publish --build
- name: Login to Quay.io
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: quay.io
username: ${{ secrets.YHTEENTOIMIVUUSPALVELUT_QUAY_IO_USERNAME }}
password: ${{ secrets.YHTEENTOIMIVUUSPALVELUT_QUAY_IO_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: quay.io/natlibfi/annif
tags: |
type=semver,pattern={{version}},suffix=-{{date 'YYYYMMDD'}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push to Quay.io
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}