Merge pull request #32 from xfenix/dependabot/pip/sentry-sdk-2.8.0 #279
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: Main pipeline | |
on: | |
push: | |
branches: | |
- "main" | |
- "feature/**" | |
- "hotfix/**" | |
- "bugfix/**" | |
tags: | |
- v* | |
jobs: | |
py-lint-and-test: | |
runs-on: ubuntu-latest | |
container: | |
image: docker:24.0.5 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
apk add make | |
make build | |
make lint-in-docker | |
make test-in-docker | |
docker-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: hadolint/[email protected] | |
with: | |
failure-threshold: error | |
submit-coverage: | |
runs-on: ubuntu-latest | |
container: | |
image: python:3.10.12-slim | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
apt-get update -y | |
apt-get install -y enchant-2 hunspell-ru hunspell-es hunspell-de-de hunspell-fr hunspell-pt-pt curl | |
pip install poetry | |
poetry install | |
poetry run pytest -n3 --cov-report=xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.xml | |
# build stage with auto-versioning based on git tags like vX.Y.Z (example: v3.1.2) | |
build-and-publish: | |
needs: [py-lint-and-test, docker-lint, submit-coverage] | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
pip3 install poetry | |
poetry version $(python -c "import os; print(os.getenv('GITHUB_REF').lstrip('/').replace('refs/tags/v', ''));") | |
python -c "import re, pathlib; _p = pathlib.Path('README.md'); _p.write_text(re.sub(r'\#\# Development.*', r'', _p.read_text(), flags=re.I | re.S).strip())" | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Add tags for image | |
uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: ${{ secrets.DOCKER_HUB_USERNAME }}/spellcheck-microservice | |
tags: | | |
type=semver,pattern={{version}} | |
type=raw,value=latest | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
update-dockerhub-readme: | |
needs: [build-and-publish] | |
runs-on: ubuntu-latest | |
container: | |
image: python:3.10.12-slim | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
apt-get update -y | |
apt-get install make | |
pip install poetry | |
poetry install | |
poetry run make update-readme | |
poetry run make update-dockerhub-readme | |
- uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
repository: ${{ secrets.DOCKER_HUB_USERNAME }}/spellcheck-microservice | |
readme-filepath: ./README.md |