更新 main.yml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 鹰眼AI CI/CD | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- '**.md' | |
- 'docs/**' | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [created] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.7, 3.8, 3.9] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 tensorflow fastapi uvicorn python-multipart pillow icrawler pytest pytest-cov flake8 | |
- name: Lint with flake8 | |
run: | | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 . --count --exit-zero --max-complexity=10 --statistics | |
- name: Run tests with coverage | |
run: | | |
pytest --cov=src/ --cov-report=xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build wheel setuptools twine | |
- name: Build package | |
run: | | |
python -m build | |
- name: Check distribution | |
run: | | |
twine check dist/* | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./dist/yingyan_ai-*.whl | |
asset_name: yingyan_ai.whl | |
asset_content_type: application/x-wheel+zip | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |