style: remove duplicate code #13
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: test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Fetch base branch | |
run: git fetch origin ${{ github.base_ref }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
architecture: x64 | |
- name: Get pip cache dir | |
id: pip-cache | |
run: | | |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: pip/pre-commit cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ steps.pip-cache.outputs.dir }} | |
~/.cache/pre-commit | |
key: ${{ runner.os }}-pip-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pip-pre-commit | |
- name: pre-commit # 只需要安装 pre-commit,不需要安装 requirements.txt | |
run: | | |
pip install -U pre-commit | |
pre-commit install --install-hooks | |
pre-commit run --all-files | |
test: | |
needs: pre-commit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Run test.py | |
run: python test/test.py |