Skip to content

build(deps): bump python from 3.12-alpine to 3.13-alpine (#106) #272

build(deps): bump python from 3.12-alpine to 3.13-alpine (#106)

build(deps): bump python from 3.12-alpine to 3.13-alpine (#106) #272

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ main ]
tags:
- v*
pull_request:
branches: [ main ]
env:
IMAGE_NAME: berv-flask
jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:alpine
# Provide the password for postgres
env:
POSTGRES_PASSWORD: devpassword
POSTGRES_DB: bookdb
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test & Coverage
run: |
coverage run -m pytest
coverage report -m
coverage xml
- name: Upload Coverage
uses: codecov/codecov-action@v4
docker-build:
needs: build
if: github.event_name == 'pull_request'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Run build
run: docker build . --file Dockerfile
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
docker-push:
# Ensure test job passes before pushing image.
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
bervproject/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}