Skip to content

fix: enhance badge generation process with improved error handling an… #32

fix: enhance badge generation process with improved error handling an…

fix: enhance badge generation process with improved error handling an… #32

Workflow file for this run

name: Test GitHub Action
# This workflow tests all features of the Python Linting GitHub Action
# It validates that all action inputs work correctly and that the action
# properly executes linting tools and badge generation
on:
pull_request:
branches: [ main ]
paths:
- 'action.yml'
- '.github/workflows/test-action.yml'
push:
branches: [ main ]
paths:
- 'action.yml'
- '.github/workflows/test-action.yml'
#Allow manual trigger
workflow_dispatch: {}
jobs:
# Test basic linting functionality
test-basic-linting:
name: Test Basic Linting
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Create test Python file
run: |
mkdir -p test_project
cat > test_project/sample.py << 'EOF'
"""Sample Python file for testing."""
def hello_world():
"""Print hello world."""
print("Hello, World!")
if __name__ == "__main__":
hello_world()
EOF
- name: Run Python Linting (Basic)
uses: ./
with:
python-version: '3.11'
# Test with custom options
test-custom-options:
name: Test Custom Linting Options
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Create test Python file
run: |
mkdir -p test_project
cat > test_project/sample.py << 'EOF'
"""Sample Python file for testing."""
def hello_world():
"""Print hello world."""
print("Hello, World!")
if __name__ == "__main__":
hello_world()
EOF
- name: Run Python Linting (Custom Options)
uses: ./
with:
python-version: '3.x'
pylint_options: '--max-line-length=100'
black_options: '--line-length=100'
mypy_options: '--ignore-missing-imports'
# Test with requirements file
test-requirements-file:
name: Test With Requirements File
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Create test files
run: |
mkdir -p test_project
cat > test_project/sample.py << 'EOF'
"""Sample Python file with imports."""
import sys
def main():
"""Main function."""
print(f"Python version: {sys.version}")
if __name__ == "__main__":
main()
EOF
cat > requirements.txt << 'EOF'
pytest>=7.0.0
EOF
- name: Run Python Linting (With Requirements)
uses: ./
with:
python-version: '3.10'
requirements-file: 'requirements.txt'
# Test with different Python versions
test-python-versions:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Create test Python file
run: |
mkdir -p test_project
cat > test_project/sample.py << 'EOF'
"""Sample Python file for testing."""
def hello_world():
"""Print hello world."""
print("Hello, World!")
if __name__ == "__main__":
hello_world()
EOF
- name: Run Python Linting (Python ${{ matrix.python-version }})
uses: ./
with:
python-version: ${{ matrix.python-version }}
# Final summary
test-summary:
name: Test Summary
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- test-basic-linting
- test-custom-options
- test-requirements-file
- test-python-versions
steps:
- name: All tests passed
run: |
echo "✅ All GitHub Action feature tests passed successfully!"
echo ""
echo "Tested features:"
echo " ✓ Basic linting functionality"
echo " ✓ Custom linting options"
echo " ✓ Requirements file handling"
echo " ✓ Multiple Python versions (3.9-3.12)"