Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e99933

Browse files
authoredMay 28, 2024
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 😄
1 parent d8674bd commit 9e99933

File tree

190 files changed

+2088
-2173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+2088
-2173
lines changed
 

‎.github/workflows/python-lint.yml

+5-50
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,22 @@ on:
77
- 'python/**'
88

99
jobs:
10-
ruff:
10+
pre-commit:
1111
if: '!cancelled()'
1212
strategy:
1313
fail-fast: false
1414
matrix:
1515
python-version: ["3.10"]
1616
runs-on: ubuntu-latest
17-
timeout-minutes: 5
17+
continue-on-error: true
1818
steps:
19-
- run: echo "/root/.local/bin" >> $GITHUB_PATH
2019
- uses: actions/checkout@v4
2120
- name: Install poetry
2221
run: pipx install poetry
2322
- uses: actions/setup-python@v5
2423
with:
2524
python-version: ${{ matrix.python-version }}
2625
cache: "poetry"
27-
- name: Install Semantic Kernel
28-
run: cd python && poetry install --no-ansi
29-
- name: Run ruff
30-
run: cd python && poetry run ruff check .
31-
black:
32-
if: '!cancelled()'
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
python-version: ["3.10"]
37-
runs-on: ubuntu-latest
38-
timeout-minutes: 5
39-
steps:
40-
- run: echo "/root/.local/bin" >> $GITHUB_PATH
41-
- uses: actions/checkout@v4
42-
- name: Install poetry
43-
run: pipx install poetry
44-
- uses: actions/setup-python@v5
45-
with:
46-
python-version: ${{ matrix.python-version }}
47-
cache: "poetry"
48-
- name: Install Semantic Kernel
49-
run: cd python && poetry install --no-ansi
50-
- name: Run black
51-
run: cd python && poetry run black --check .
52-
mypy:
53-
if: '!cancelled()'
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
python-version: ["3.10"]
58-
runs-on: ubuntu-latest
59-
timeout-minutes: 5
60-
steps:
61-
- run: echo "/root/.local/bin" >> $GITHUB_PATH
62-
- uses: actions/checkout@v4
63-
- name: Install poetry
64-
run: pipx install poetry
65-
- uses: actions/setup-python@v5
66-
with:
67-
python-version: ${{ matrix.python-version }}
68-
cache: "poetry"
69-
- name: Install Semantic Kernel
70-
run: cd python && poetry install --no-ansi
71-
- name: Run mypy
72-
run: cd python && poetry run mypy -p semantic_kernel --config-file=mypy.ini
73-
26+
- name: Install dependencies
27+
run: cd python && poetry install
28+
- uses: pre-commit/action@v3.0.1

‎.github/workflows/python-test-coverage.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
python-tests-coverage:
1111
name: Create Test Coverage Messages
1212
runs-on: ${{ matrix.os }}
13-
continue-on-error: true
1413
permissions:
1514
pull-requests: write
1615
contents: read
@@ -21,14 +20,17 @@ jobs:
2120
os: [ubuntu-latest]
2221
steps:
2322
- name: Wait for unit tests to succeed
23+
continue-on-error: true
2424
uses: lewagon/wait-on-check-action@v1.3.4
2525
with:
2626
ref: ${{ github.event.pull_request.head.sha }}
2727
check-name: 'Python Unit Tests (${{ matrix.python-version}}, ${{ matrix.os }})'
2828
repo-token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
2929
wait-interval: 10
30+
allowed-conclusions: success
3031
- uses: actions/checkout@v4
3132
- name: Download coverage
33+
continue-on-error: true
3234
uses: dawidd6/action-download-artifact@v3
3335
with:
3436
name: python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt
@@ -37,6 +39,7 @@ jobs:
3739
search_artifacts: true
3840
if_no_artifact_found: warn
3941
- name: Download pytest
42+
continue-on-error: true
4043
uses: dawidd6/action-download-artifact@v3
4144
with:
4245
name: pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml
@@ -45,6 +48,7 @@ jobs:
4548
search_artifacts: true
4649
if_no_artifact_found: warn
4750
- name: Pytest coverage comment
51+
continue-on-error: true
4852
id: coverageComment
4953
uses: MishaKav/pytest-coverage-comment@main
5054
with:

0 commit comments

Comments
 (0)