fix: fix lint jinja2 error #108
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: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Install dependencies | |
run: uv sync --extra=dev | |
- name: Run lint checks | |
id: lint | |
run: uvx 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: uvx 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 |