Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Python CI

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint black

- name: Format with Black
run: black .

- name: Lint with pylint
run: |
pylint --rcfile=.pylintrc *.py

- name: Run tests with pytest
run: |
python -m pytest -v

docker:
needs: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./app_python
push: true
tags: eleanorpi/moscow-time-app:latest

security:
needs: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python

steps:
- uses: actions/checkout@v4

- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python-3.8@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: test
args: --severity-threshold=high --project-name=app_python --file=app_python/requirements.txt --skip-unresolved
Loading