Skip to content

Bump docker/build-push-action from 5.0.0 to 5.1.0 #740

Bump docker/build-push-action from 5.0.0 to 5.1.0

Bump docker/build-push-action from 5.0.0 to 5.1.0 #740

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.5.1"
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-22.04
name: lint with isort, Black & flake8
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Prepare: restore caches, install Poetry, set up Python"
uses: ./.github/actions/prepare
with:
python-version: "3.10"
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Prepare: restore caches, install Poetry, set up Python"
id: prepare
uses: ./.github/actions/prepare
with:
python-version: "3.9"
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.8", "3.9", "3.10", "3.11"]
name: test on Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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.8:
if [[ ${{ matrix.python-version }} == '3.8' ]]; then
poetry install -E "nn omikuji yake voikko stwfsa";
fi
# For Python 3.9:
if [[ ${{ matrix.python-version }} == '3.9' ]]; 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.10:
if [[ ${{ matrix.python-version }} == '3.10' ]]; then
poetry install -E "nn omikuji yake stwfsa";
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
poetry run python -m nltk.downloader punkt
- name: Test with pytest
run: |
poetry run pytest --cov=./ --cov-report xml
if [[ ${{ matrix.python-version }} == '3.9' ]]; then
poetry run pytest --cov=./ --cov-report xml --cov-append -m slow
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
- 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@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.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@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.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@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.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@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: quay.io/natlibfi/annif
tags: |
latest
- name: Build and push to Quay.io
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.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@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
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@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}