Fix/use setup token #46
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: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
lint: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Run lint checks | |
id: lint | |
run: uv tool run nox -s lint | |
continue-on-error: true | |
- name: Comment on PR | |
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 | |
test-all: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Run tests on all Python versions | |
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 | |
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 |