forked from PyLadiesCZ-Brno/python-knihovny
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (67 loc) · 2.04 KB
/
Copy pathpr-checks.yml
File metadata and controls
80 lines (67 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: PR Checks
on:
pull_request:
types: [opened, synchronize]
branches:
- main
jobs:
get-changed-files:
runs-on: ubuntu-latest
outputs:
tasks: ${{ steps.changed.outputs.tasks }}
tests: ${{ steps.changed.outputs.tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed Python files
id: changed
run: |
files=$(git diff --name-only HEAD~1)
echo "Changed files:"
echo "$files"
tasks=$(echo "$files" | grep '06/tasks/.*\.py$' | paste -sd " ")
echo "Changed tasks:"
echo "$tasks"
echo "tasks=$tasks" >> $GITHUB_OUTPUT
tests=$(echo "$files" | grep '06/tasks/.*\.py$' | sed 's|tasks/task|test|' | paste -sd " ")
echo "Corresponding tests:"
echo "$tests"
echo "tests=$tests" >> $GITHUB_OUTPUT
autopep8:
needs: get-changed-files
runs-on: ubuntu-latest
if: needs.get-changed-files.outputs.tasks != ''
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install autopep8
run: |
python -m pip install --upgrade pip
pip install autopep8
- name: Run autopep8 on changed files
run: |
autopep8 --max-line-length 120 --exit-code --diff ${{ needs.get-changed-files.outputs.tasks }}
pytest:
needs: get-changed-files
runs-on: ubuntu-latest
if: needs.get-changed-files.outputs.tests != ''
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Run pytest for changed files
run: |
pytest ${{ needs.get-changed-files.outputs.tests }}