|
8 | 8 | strategy: |
9 | 9 | matrix: |
10 | 10 | python-version: ["3.11", "3.12", "3.13"] |
| 11 | + |
11 | 12 | steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - - name: Set up Python ${{ matrix.python-version }} |
14 | | - uses: actions/setup-python@v3 |
15 | | - with: |
16 | | - python-version: ${{ matrix.python-version }} |
17 | | - - name: Install dependencies |
18 | | - run: | |
19 | | - python -m pip install --upgrade pip |
20 | | - pip install pylint |
21 | | - - name: Analysing the code with pylint |
22 | | - run: | |
23 | | - echo CI_COMMIT_SHA=${CI_COMMIT_SHA} |
24 | | - echo CI_MERGE_REQUEST_TARGET_BRANCH_NAME=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} |
25 | | - git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} |
26 | | - tmp_files=$(git diff --name-only ${CI_COMMIT_SHA} origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}) |
27 | | - echo "Changed files are $tmp_files" |
28 | | - if [ -z "$(echo "$tmp_files" | grep "\.py")" ]; then exit 0; else echo "Python files are found"; fi |
29 | | - tmp_pfiles=$(echo "$tmp_files" | grep "\.py") |
30 | | - echo "Python files are $tmp_pfiles" |
31 | | - mkdir ./pylint |
32 | | - pylint $tmp_pfiles | tee ./pylint/pylint.log || pylint-exit $? |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Set up Python ${{ matrix.python-version }} |
| 18 | + uses: actions/setup-python@v3 |
| 19 | + with: |
| 20 | + python-version: ${{ matrix.python-version }} |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: | |
| 24 | + python -m pip install --upgrade pip |
| 25 | + pip install pylint |
| 26 | +
|
| 27 | + - name: Get modified Python files |
| 28 | + id: changed-files |
| 29 | + run: | |
| 30 | + FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- '*.py' | tr '\n' ' ') |
| 31 | + echo "files=$FILES" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + - name: Analysing the code with pylint |
| 34 | + if: steps.changed-files.outputs.files != '' |
| 35 | + run: | |
| 36 | + pylint ${{ steps.changed-files.outputs.files }} |
0 commit comments