fix workflow, only one file #47
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: 项目CI/CD | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- master | |
- develop | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python: ["3.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python }} on ${{ matrix.os }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Git LFS | |
shell: pwsh | |
run: | | |
if ($env:RUNNER_OS -eq "Linux") { | |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash | |
sudo apt-get install git-lfs | |
} elseif ($env:RUNNER_OS -eq "macOS") { | |
brew install git-lfs | |
} elseif ($env:RUNNER_OS -eq "Windows") { | |
choco install git-lfs | |
} | |
git lfs install | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
pip install dynaconf | |
pip install tox | |
- name: Download models | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
run: | | |
git config --global credential.helper store | |
echo "https://USER:[email protected]" > ~/.git-credentials | |
git clone https://huggingface.co/liferecords/Telos.git docr/models | |
- name: Run tests | |
run: | | |
tox -e py | |
linting: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox isort black pylint | |
- name: Run isort | |
run: isort . --check-only --diff | |
- name: Run black | |
run: black . | |
# - name: Run pylint | |
# run: pylint **/*.py --exit-zero --output-format=parseable --reports=y > pylint_report.txt | |
- name: Run linting | |
run: | | |
# tox -e isort | |
# tox -e pylint | |
# - name: Upload pylint report | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: pylint-report | |
# path: pylint_report.txt | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Apply automatic formatting changes" | |
file_pattern: "*.py" | |
build: | |
needs: [test, linting] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade poetry | |
- name: Build package | |
run: poetry build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 设置Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' # 根据您的Python版本调整 | |
- name: 安装依赖 | |
run: | | |
pip install poetry | |
poetry install | |
pip install mkdocs-material mkdocs | |
- name: 构建文档 | |
run: mkdocs build | |
- name: 部署到GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
publish_dir: ./site # MkDocs默认输出目录 | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false |