Skip to content

Python Tests

Python Tests #1494

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
schedule:
- cron: '1 1 * * *'
defaults:
run:
working-directory: ./python
env:
PROMETHEUS_URL: ${{ secrets.PROMETHEUS_URL }}
LOKI_URL: ${{ secrets.LOKI_URL }}
PROMETHEUS_USERNAME: ${{ secrets.PROMETHEUS_USERNAME }}
LOKI_USERNAME: ${{ secrets.LOKI_USERNAME }}
GRAFANA_CLOUD_ACCESS_TOKEN: ${{ secrets.GRAFANA_CLOUD_ACCESS_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Get changed files in the docs folder
id: changed-files-specific
uses: tj-actions/changed-files@v40
with:
files: python/**
- name: Set up Python ${{ matrix.python-version }}
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event.schedule == '*/180 * * * *'
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event.schedule == '*/180 * * * *'
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest openai requests
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event.schedule == '*/180 * * * *'
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 with pytest
if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event.schedule == '*/180 * * * *'
run: |
pytest