Skip to content

Commit

Permalink
Update python-app.yml
Browse files Browse the repository at this point in the history
only run pytests if relevant files change
  • Loading branch information
souzatharsis authored Oct 24, 2024
1 parent 997672b commit 1005e6e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
name: Pytest

on:
push:
branches: [ "main" ]
paths:
- '**.py' # Python files
- 'tests/**' # Test directory
- 'requirements.txt' # Dependencies
- 'setup.py' # Package setup
- '.github/workflows/**' # Workflow files
- 'pyproject.toml' # Python project config
paths-ignore:
- '**.md' # Markdown files
- 'docs/**' # Documentation
- 'README*' # README files
- 'LICENSE*' # License files
pull_request:
branches: [ "main" ]
paths:
- '**.py'
- 'tests/**'
- 'requirements.txt'
- 'setup.py'
- '.github/workflows/**'
- 'pyproject.toml'
paths-ignore:
- '**.md'
- 'docs/**'
- 'README*'
- 'LICENSE*'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

container:
image: ubuntu:24.04

steps:
- uses: actions/checkout@v4

- name: Set up environment
run: |
set -e
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-full python3-pip python3-venv ffmpeg
- name: Cache virtual environment
uses: actions/cache@v3
with:
path: /opt/venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-venv-
- name: Set up Python virtual environment
run: |
set -e
python3 -m venv /opt/venv
. /opt/venv/bin/activate
python3 -m pip install --upgrade pip
- name: Install dependencies
run: |
set -e
. /opt/venv/bin/activate
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Check versions and list packages
run: |
set -e
Expand All @@ -61,14 +77,12 @@ jobs:
pip --version
echo "Installed packages:"
pip list
- name: Lint with flake8
run: |
set -e
. /opt/venv/bin/activate
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
Expand All @@ -77,7 +91,6 @@ jobs:
set -e
. /opt/venv/bin/activate
pytest
- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 1005e6e

Please sign in to comment.