Skip to content

Commit 596970d

Browse files
Update action.yml
Co-authored-by: LeAndre <lcjunior1220@gmail.com>
1 parent 3fa64b8 commit 596970d

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

action.yml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,74 @@
1-
name: "Matrix Pytest Runner."
2-
description: "Run flake8 and pytest across matrix Python versions with optional requirements files."
1+
name: "Python Code Checker"
2+
description: "Run tox across matrix Python versions with optional requirements files."
33
author: "GitCodeCheckers"
44
branding:
55
icon: "check-circle"
66
color: "blue"
77

88
inputs:
9-
file:
10-
description: "Python file or test path to run with pytest."
11-
required: false
12-
default: ""
139
python-version:
1410
description: "Python version to use."
1511
required: true
12+
13+
file:
14+
description: "Optional file or directory passed to tox (if your tox.ini uses it)."
15+
required: false
16+
default: ""
17+
1618
requirements:
17-
description: "Optional requirements file to install from (overrides requirements.txt)"
19+
description: "Optional requirements file to install from (overrides requirements.txt)."
1820
required: false
1921
default: ""
2022

2123
runs:
2224
using: "composite"
2325
steps:
24-
- uses: actions/setup-python@v5
26+
- name: Set up Python
27+
uses: actions/setup-python@v6
2528
with:
2629
python-version: ${{ inputs.python-version }}
30+
allow-prereleases: true
2731

28-
- name: Install dependencies
32+
- name: Upgrade pip
2933
shell: bash
30-
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install flake8 pytest
34+
run: python -m pip install --upgrade pip
3335

36+
- name: Install tox + tox-gh-actions
37+
shell: bash
38+
run: pip install tox tox-gh-actions
39+
40+
- name: Install project dependencies
41+
shell: bash
42+
run: |
3443
# Priority 1: matrix-provided requirements file
3544
if [ -n "${{ inputs.requirements }}" ] && [ -f "${{ inputs.requirements }}" ]; then
3645
echo "Installing from matrix requirements file: ${{ inputs.requirements }}"
3746
pip install -r "${{ inputs.requirements }}"
3847
3948
# Priority 2: fallback to requirements.txt
4049
elif [ -f requirements.txt ]; then
41-
echo "Installing from requirements.txt"
50+
echo "Installing from default requirements.txt"
4251
pip install -r requirements.txt
4352
4453
# Priority 3: no requirements found
4554
else
4655
echo "No requirements file provided or found."
4756
fi
4857
49-
- name: Lint with flake8
58+
- name: Run tox
5059
shell: bash
5160
run: |
52-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
53-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
61+
echo "Running tox."
62+
tox || code=$?
5463
55-
- name: Run pytest
56-
shell: bash
57-
run: |
58-
if [ -z "${{ inputs.file }}" ]; then
59-
echo "Running pytest on entire project."
60-
pytest
61-
else
62-
echo "Running pytest on: ${{ inputs.file }}"
63-
pytest ${{ inputs.file }}
64+
# Exit code 5 = no tests collected → treat as success
65+
if [ "${code:-0}" = "5" ]; then
66+
echo "No tests collected — treating as success."
67+
exit 0
68+
fi
69+
70+
# Any other non-zero exit code = real failure
71+
if [ -n "${code:-}" ] && [ "$code" != "0" ]; then
72+
echo "Tox failed with exit code $code"
73+
exit "$code"
6474
fi

0 commit comments

Comments
 (0)