Ci/optimize workflows #56
Workflow file for this run
This file contains hidden or 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: lint_and_unittest | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pull-requests: write # 用于在 PR 中添加评论 | |
jobs: | |
setup: | |
uses: ./.github/workflows/setup.yaml | |
with: | |
install-deps: dev | |
python-version: "3.12" | |
secrets: inherit | |
check: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run lint checks | |
id: lint | |
run: uv tool run nox -s lint | |
continue-on-error: true | |
- name: Comment on PR (Lint) | |
if: github.event_name == 'pull_request' && steps.lint.outcome == 'failure' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const output = `#### 🔍 Lint Check Failed | |
Please fix the linting issues before merging. | |
You can run \`nox -s lint\` locally to check and fix issues.`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
- name: Check lint result | |
if: steps.lint.outcome == 'failure' | |
run: exit 1 | |
- name: Run tests | |
id: test | |
run: uv tool run nox -s test_all | |
continue-on-error: true | |
- name: Upload coverage reports | |
if: success() | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.xml | |
flags: unittests | |
- name: Comment on PR (Tests) | |
if: github.event_name == 'pull_request' && steps.test.outcome == 'failure' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const output = `#### ❌ Tests Failed | |
Please fix the test failures before merging. | |
You can run \`nox -s test_all\` locally to debug the failures.`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
- name: Check test result | |
if: steps.test.outcome == 'failure' | |
run: exit 1 |