From e770c2092550c8aee73bc2883ace188ac1af4d39 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Wed, 21 Jan 2026 09:43:22 +0800 Subject: [PATCH] feat(ci): add github action pre-commit --- .github/PULL_REQUEST_TEMPLATE.md | 33 +++++++++++++++++++++++++++++ .github/workflows/pre-commit.yml | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..171c370 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,33 @@ +## Description +[Describe what this PR does and why] + +**Related Issue:** Fixes #[issue_number] or Relates to #[issue_number] + +**Security Considerations:** [Check if API keys or sensitive credentials are exposed in code/logs] + +## Type of Change +- [ ] Bug fix +- [ ] New feature +- [ ] Breaking change +- [ ] Documentation +- [ ] Refactoring + +## Component(s) Affected +- [ ] Model +- [ ] Application +- [ ] Common +- [ ] Documentation +- [ ] Tests +- [ ] CI/CD + +## Checklist +- [ ] Pre-commit hooks pass +- [ ] Tests pass locally +- [ ] Documentation updated (if needed) +- [ ] Ready for review + +## Testing +[How to test these changes] + +## Additional Notes +[Optional: any other context] \ No newline at end of file diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..dd872f7 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,36 @@ +name: Pre-commit Checks + +on: [push, pull_request] + +jobs: + run: + runs-on: ubuntu-latest + strategy: + fail-fast: true + env: + OS: ubuntu-latest + PYTHON: '3.8' + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + - name: Update setuptools and wheel + run: | + pip install setuptools==68.2.2 wheel==0.41.2 + - name: Install dashscope python sdk + run: | + pip install -r requirements.txt + - name: Install pre-commit hooks + run: | + pre-commit install + - name: Run pre-commit + run: | + pre-commit run --all-files > pre-commit.log 2>&1 || true + cat pre-commit.log + if grep -q Failed pre-commit.log; then + echo -e "\e[41m [**FAIL**] Please install pre-commit and format your code first. \e[0m" + exit 1 + fi + echo -e "\e[46m ********************************Passed******************************** \e[0m" \ No newline at end of file