forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: new pre-commit actions and pre-commit as GHA (microsoft#6376)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> - Added static code checking to pre-commit (check-ast and nbqa-check-ast) - Added Bandit security checking to pre-commit - Added pre-commit step to python-lint workflow, if it works, can delete seperate mypy, ruff and black tests ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
- Loading branch information
1 parent
d8674bd
commit 9e99933
Showing
190 changed files
with
2,088 additions
and
2,173 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,67 +7,22 @@ on: | |
- 'python/**' | ||
|
||
jobs: | ||
ruff: | ||
pre-commit: | ||
if: '!cancelled()' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10"] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
continue-on-error: true | ||
steps: | ||
- run: echo "/root/.local/bin" >> $GITHUB_PATH | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "poetry" | ||
- name: Install Semantic Kernel | ||
run: cd python && poetry install --no-ansi | ||
- name: Run ruff | ||
run: cd python && poetry run ruff check . | ||
black: | ||
if: '!cancelled()' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10"] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- run: echo "/root/.local/bin" >> $GITHUB_PATH | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "poetry" | ||
- name: Install Semantic Kernel | ||
run: cd python && poetry install --no-ansi | ||
- name: Run black | ||
run: cd python && poetry run black --check . | ||
mypy: | ||
if: '!cancelled()' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10"] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- run: echo "/root/.local/bin" >> $GITHUB_PATH | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "poetry" | ||
- name: Install Semantic Kernel | ||
run: cd python && poetry install --no-ansi | ||
- name: Run mypy | ||
run: cd python && poetry run mypy -p semantic_kernel --config-file=mypy.ini | ||
|
||
- name: Install dependencies | ||
run: cd python && poetry install | ||
- uses: pre-commit/[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ jobs: | |
python-tests-coverage: | ||
name: Create Test Coverage Messages | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: true | ||
permissions: | ||
pull-requests: write | ||
contents: read | ||
|
@@ -21,14 +20,17 @@ jobs: | |
os: [ubuntu-latest] | ||
steps: | ||
- name: Wait for unit tests to succeed | ||
continue-on-error: true | ||
uses: lewagon/[email protected] | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
check-name: 'Python Unit Tests (${{ matrix.python-version}}, ${{ matrix.os }})' | ||
repo-token: ${{ secrets.GH_ACTIONS_PR_WRITE }} | ||
wait-interval: 10 | ||
allowed-conclusions: success | ||
- uses: actions/checkout@v4 | ||
- name: Download coverage | ||
continue-on-error: true | ||
uses: dawidd6/action-download-artifact@v3 | ||
with: | ||
name: python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt | ||
|
@@ -37,6 +39,7 @@ jobs: | |
search_artifacts: true | ||
if_no_artifact_found: warn | ||
- name: Download pytest | ||
continue-on-error: true | ||
uses: dawidd6/action-download-artifact@v3 | ||
with: | ||
name: pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml | ||
|
@@ -45,6 +48,7 @@ jobs: | |
search_artifacts: true | ||
if_no_artifact_found: warn | ||
- name: Pytest coverage comment | ||
continue-on-error: true | ||
id: coverageComment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
|
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
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
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
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
Oops, something went wrong.