-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (90 loc) · 3.01 KB
/
python_package.yml
File metadata and controls
90 lines (90 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release Build and Deploy
on:
release:
types: [published, created, edited]
push:
branches: [ "main" ]
tags: [ "*" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
run_security:
description: 'Run security check'
type: boolean
default: false
run_deploy:
description: 'Run deploy step'
type: boolean
default: false
required: true
jobs:
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-asyncio setuptools wheel
- name: Build package
run: |
python setup.py bdist_wheel sdist
python -m pip install -e .
- name: Lint with flake8
run: |
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
run: pytest tests --ignore=tests/agents --ignore=tests/mcp/tools
- name: Install package with agents requirements
run: |
python -m pip install -r requirements-agents.txt
- name: Test agents with pytest
run: pytest tests/agents tests/mcp/tools
security:
name: Security Check
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || inputs.run_security
steps:
- uses: actions/checkout@main
- name: Run Safety CLI to check for vulnerabilities
uses: pyupio/safety-action@v1
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
deploy:
name: Deploy Package to PyPI
runs-on: ubuntu-latest
needs: [build_and_test, security]
if: (github.event_name == 'release' && github.event.action == 'published' && needs.build_and_test.result == 'success' && needs.security.result == 'success') || inputs.run_deploy
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
# - name: Verify PYPI_API_TOKEN is set
# run: |
# if [ -z "${{ secrets.PYPI_API_TOKEN }}" ]; then
# echo "PYPI_API_TOKEN is not set";
# exit 1;
# fi
- name: Upgrade pip and install build
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package for deployment
run: python setup.py bdist_wheel sdist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# password: ${{ secrets.PYPI_API_TOKEN }}