fixed tests
Test CI Templates / validate-syntax (push) Successful in 11s
Test CI Templates / test-python-code-quality (3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.12) (push) Failing after 4s
Test CI Templates / test-web-formatting (true, false, 20) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.10) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.12) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, false, basic) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, true, skip-pyupgrade) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.12) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.11) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, false, 18) (push) Failing after 5s
Test CI Templates / test-monorepo (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 20) (push) Failing after 5s
Test CI Templates / test-results (push) Successful in 2s
Test CI Templates / test-python-code-quality (true, false, skip-mypy) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 18) (push) Failing after 5s
Test CI Templates / test-edge-cases (push) Failing after 5s
Test CI Templates / validate-syntax (push) Successful in 11s
Test CI Templates / test-python-code-quality (3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.12) (push) Failing after 4s
Test CI Templates / test-web-formatting (true, false, 20) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.10) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.12) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, false, basic) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, true, skip-pyupgrade) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.12) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.11) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, false, 18) (push) Failing after 5s
Test CI Templates / test-monorepo (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 20) (push) Failing after 5s
Test CI Templates / test-results (push) Successful in 2s
Test CI Templates / test-python-code-quality (true, false, skip-mypy) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 18) (push) Failing after 5s
Test CI Templates / test-edge-cases (push) Failing after 5s
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
---
|
||||||
name: Python Code Quality Pipeline
|
name: Python Code Quality Pipeline
|
||||||
|
|
||||||
on:
|
"on":
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
python-version:
|
python-version:
|
||||||
@@ -36,7 +37,7 @@ jobs:
|
|||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -71,4 +72,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Pyupgrade check
|
- name: Pyupgrade check
|
||||||
if: ${{ !inputs.skip-pyupgrade }}
|
if: ${{ !inputs.skip-pyupgrade }}
|
||||||
run: uv run pyupgrade --py312-plus $(git ls-files '*.py') && git diff --exit-code
|
run: |
|
||||||
|
echo "Running pyupgrade..."
|
||||||
|
uv run pyupgrade --py312-plus $(git ls-files '*.py')
|
||||||
|
echo "Checking for changes..."
|
||||||
|
git diff --exit-code
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
---
|
||||||
name: Python Test Pipeline
|
name: Python Test Pipeline
|
||||||
|
|
||||||
on:
|
"on":
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
python-version:
|
python-version:
|
||||||
@@ -49,7 +50,7 @@ jobs:
|
|||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -77,13 +78,20 @@ jobs:
|
|||||||
PYTHONPATH: .
|
PYTHONPATH: .
|
||||||
run: |
|
run: |
|
||||||
if [ -n "${{ inputs.coverage-package }}" ]; then
|
if [ -n "${{ inputs.coverage-package }}" ]; then
|
||||||
uv run pytest --cov=${{ inputs.coverage-package }} --cov-report=term-missing ${{ inputs.pytest-args }} > coverage.txt
|
uv run pytest --cov=${{ inputs.coverage-package }} \
|
||||||
|
--cov-report=term-missing ${{ inputs.pytest-args }} > coverage.txt
|
||||||
else
|
else
|
||||||
uv run pytest ${{ inputs.pytest-args }}
|
uv run pytest ${{ inputs.pytest-args }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Post coverage summary to PR
|
- name: Post coverage summary to PR
|
||||||
if: ${{ !inputs.skip-coverage-comment && inputs.coverage-package != '' && github.event_name == 'pull_request' && inputs.api-url != '' }}
|
if: >-
|
||||||
|
${{
|
||||||
|
!inputs.skip-coverage-comment &&
|
||||||
|
inputs.coverage-package != '' &&
|
||||||
|
github.event_name == 'pull_request' &&
|
||||||
|
inputs.api-url != ''
|
||||||
|
}}
|
||||||
env:
|
env:
|
||||||
API_URL: ${{ inputs.api-url }}
|
API_URL: ${{ inputs.api-url }}
|
||||||
REPO_OWNER: ${{ github.repository_owner }}
|
REPO_OWNER: ${{ github.repository_owner }}
|
||||||
@@ -94,7 +102,9 @@ jobs:
|
|||||||
if [ -f coverage.txt ]; then
|
if [ -f coverage.txt ]; then
|
||||||
COVERAGE=$(cat coverage.txt)
|
COVERAGE=$(cat coverage.txt)
|
||||||
COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`"
|
COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`"
|
||||||
curl -s -X POST "$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \
|
API_ENDPOINT="$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments"
|
||||||
|
curl -s -X POST \
|
||||||
|
"$API_ENDPOINT" \
|
||||||
-H "Authorization: token $CI_RUNNER_TOKEN" \
|
-H "Authorization: token $CI_RUNNER_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"body\": \"$COMMENT_BODY\"}"
|
-d "{\"body\": \"$COMMENT_BODY\"}"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
---
|
||||||
name: Test CI Templates
|
name: Test CI Templates
|
||||||
|
|
||||||
on:
|
"on":
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -14,24 +15,29 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
|
|
||||||
- name: Install yamllint
|
- name: Install yamllint
|
||||||
run: pip install yamllint
|
run: pip install yamllint
|
||||||
|
|
||||||
- name: Validate YAML syntax
|
- name: Validate YAML syntax
|
||||||
run: |
|
run: |
|
||||||
echo "Validating workflow YAML syntax..."
|
echo "Validating workflow YAML syntax..."
|
||||||
find .gitea/workflows -name "*.yml" -exec yamllint {} \;
|
find .gitea/workflows -name "*.yml" -exec yamllint {} \;
|
||||||
|
|
||||||
- name: Check workflow structure
|
- name: Check workflow structure
|
||||||
run: |
|
run: |
|
||||||
echo "Checking workflow structure..."
|
echo "Checking workflow structure..."
|
||||||
for file in .gitea/workflows/**/*.yml; do
|
for file in .gitea/workflows/**/*.yml; do
|
||||||
|
# Skip the test file itself
|
||||||
|
if [[ "$file" == *"test-templates.yml" ]]; then
|
||||||
|
echo "Skipping test file: $file"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
echo "Checking $file..."
|
echo "Checking $file..."
|
||||||
if ! grep -q "workflow_call" "$file"; then
|
if ! grep -q "workflow_call" "$file"; then
|
||||||
echo "Error: $file is missing workflow_call trigger"
|
echo "Error: $file is missing workflow_call trigger"
|
||||||
@@ -58,69 +64,69 @@ jobs:
|
|||||||
- test-type: "skip-pyupgrade"
|
- test-type: "skip-pyupgrade"
|
||||||
skip-mypy: false
|
skip-mypy: false
|
||||||
skip-pyupgrade: true
|
skip-pyupgrade: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create test Python project
|
- name: Create test Python project
|
||||||
run: |
|
run: |
|
||||||
mkdir -p test-project/src/test_package
|
mkdir -p test-project/src/test_package
|
||||||
cd test-project
|
cd test-project
|
||||||
|
|
||||||
# Create pyproject.toml
|
# Create pyproject.toml
|
||||||
cat > pyproject.toml << 'EOF'
|
cat > pyproject.toml << 'EOF'
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "test-package"
|
name = "test-package"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Test package for CI templates"
|
description = "Test package for CI templates"
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
dev = [
|
dev = [
|
||||||
"mypy>=1.0.0",
|
"mypy>=1.0.0",
|
||||||
"ruff>=0.1.0",
|
"ruff>=0.1.0",
|
||||||
"pyupgrade>=3.0.0",
|
"pyupgrade>=3.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 88
|
line-length = 88
|
||||||
target-version = "py310"
|
target-version = "py310"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.10"
|
python_version = "3.10"
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unused_configs = true
|
warn_unused_configs = true
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create source code
|
# Create source code
|
||||||
cat > src/test_package/__init__.py << 'EOF'
|
cat > src/test_package/__init__.py << 'EOF'
|
||||||
"""Test package for CI template validation."""
|
"""Test package for CI template validation."""
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
|
|
||||||
def hello_world() -> str:
|
def hello_world() -> str:
|
||||||
"""Return a greeting message."""
|
"""Return a greeting message."""
|
||||||
return "Hello, World!"
|
return "Hello, World!"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > src/test_package/main.py << 'EOF'
|
cat > src/test_package/main.py << 'EOF'
|
||||||
"""Main module for test package."""
|
"""Main module for test package."""
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
def process_items(items: List[str]) -> List[str]:
|
def process_items(items: List[str]) -> List[str]:
|
||||||
"""Process a list of items."""
|
"""Process a list of items."""
|
||||||
return [item.upper() for item in items]
|
return [item.upper() for item in items]
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_items = ["hello", "world"]
|
test_items = ["hello", "world"]
|
||||||
result = process_items(test_items)
|
result = process_items(test_items)
|
||||||
print(result)
|
print(result)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Test Python code quality workflow
|
- name: Test Python code quality workflow
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -137,89 +143,89 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.11", "3.12"]
|
python-version: ["3.11", "3.12"]
|
||||||
coverage: [true, false]
|
coverage: [true, false]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create test Python project with tests
|
- name: Create test Python project with tests
|
||||||
run: |
|
run: |
|
||||||
mkdir -p test-pytest-project/src/test_package tests
|
mkdir -p test-pytest-project/src/test_package tests
|
||||||
cd test-pytest-project
|
cd test-pytest-project
|
||||||
|
|
||||||
# Create pyproject.toml
|
# Create pyproject.toml
|
||||||
cat > pyproject.toml << 'EOF'
|
cat > pyproject.toml << 'EOF'
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "test-package"
|
name = "test-package"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Test package for pytest CI template"
|
description = "Test package for pytest CI template"
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
test = [
|
test = [
|
||||||
"pytest>=7.0.0",
|
"pytest>=7.0.0",
|
||||||
"pytest-cov>=4.0.0",
|
"pytest-cov>=4.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
testpaths = ["tests"]
|
testpaths = ["tests"]
|
||||||
python_files = ["test_*.py"]
|
python_files = ["test_*.py"]
|
||||||
addopts = ["--strict-markers", "--strict-config"]
|
addopts = ["--strict-markers", "--strict-config"]
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create source code
|
# Create source code
|
||||||
cat > src/test_package/__init__.py << 'EOF'
|
cat > src/test_package/__init__.py << 'EOF'
|
||||||
"""Test package for pytest template validation."""
|
"""Test package for pytest template validation."""
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > src/test_package/calculator.py << 'EOF'
|
cat > src/test_package/calculator.py << 'EOF'
|
||||||
"""Simple calculator for testing."""
|
"""Simple calculator for testing."""
|
||||||
|
|
||||||
def add(a: float, b: float) -> float:
|
def add(a: float, b: float) -> float:
|
||||||
"""Add two numbers."""
|
"""Add two numbers."""
|
||||||
return a + b
|
return a + b
|
||||||
|
|
||||||
def multiply(a: float, b: float) -> float:
|
def multiply(a: float, b: float) -> float:
|
||||||
"""Multiply two numbers."""
|
"""Multiply two numbers."""
|
||||||
return a * b
|
return a * b
|
||||||
|
|
||||||
def divide(a: float, b: float) -> float:
|
def divide(a: float, b: float) -> float:
|
||||||
"""Divide two numbers."""
|
"""Divide two numbers."""
|
||||||
if b == 0:
|
if b == 0:
|
||||||
raise ValueError("Cannot divide by zero")
|
raise ValueError("Cannot divide by zero")
|
||||||
return a / b
|
return a / b
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create tests
|
# Create tests
|
||||||
cat > tests/test_calculator.py << 'EOF'
|
cat > tests/test_calculator.py << 'EOF'
|
||||||
"""Tests for calculator module."""
|
"""Tests for calculator module."""
|
||||||
import pytest
|
import pytest
|
||||||
from test_package.calculator import add, multiply, divide
|
from test_package.calculator import add, multiply, divide
|
||||||
|
|
||||||
def test_add():
|
def test_add():
|
||||||
assert add(2, 3) == 5
|
assert add(2, 3) == 5
|
||||||
assert add(-1, 1) == 0
|
assert add(-1, 1) == 0
|
||||||
assert add(0.1, 0.2) == pytest.approx(0.3)
|
assert add(0.1, 0.2) == pytest.approx(0.3)
|
||||||
|
|
||||||
def test_multiply():
|
def test_multiply():
|
||||||
assert multiply(2, 3) == 6
|
assert multiply(2, 3) == 6
|
||||||
assert multiply(-2, 3) == -6
|
assert multiply(-2, 3) == -6
|
||||||
assert multiply(0, 5) == 0
|
assert multiply(0, 5) == 0
|
||||||
|
|
||||||
def test_divide():
|
def test_divide():
|
||||||
assert divide(6, 2) == 3
|
assert divide(6, 2) == 3
|
||||||
assert divide(5, 2) == 2.5
|
assert divide(5, 2) == 2.5
|
||||||
|
|
||||||
def test_divide_by_zero():
|
def test_divide_by_zero():
|
||||||
with pytest.raises(ValueError, match="Cannot divide by zero"):
|
with pytest.raises(ValueError, match="Cannot divide by zero"):
|
||||||
divide(5, 0)
|
divide(5, 0)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Test pytest workflow
|
- name: Test pytest workflow
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -237,16 +243,16 @@ jobs:
|
|||||||
node-version: ["18", "20"]
|
node-version: ["18", "20"]
|
||||||
check-yaml: [true, false]
|
check-yaml: [true, false]
|
||||||
check-json: [true, false]
|
check-json: [true, false]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create test web project
|
- name: Create test web project
|
||||||
run: |
|
run: |
|
||||||
mkdir -p test-web-project/src/components
|
mkdir -p test-web-project/src/components
|
||||||
cd test-web-project
|
cd test-web-project
|
||||||
|
|
||||||
# Create package.json
|
# Create package.json
|
||||||
cat > package.json << 'EOF'
|
cat > package.json << 'EOF'
|
||||||
{
|
{
|
||||||
@@ -255,19 +261,19 @@ jobs:
|
|||||||
"description": "Test project for web formatting template"
|
"description": "Test project for web formatting template"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create JavaScript files
|
# Create JavaScript files
|
||||||
cat > src/index.js << 'EOF'
|
cat > src/index.js << 'EOF'
|
||||||
// Test JavaScript file for formatting
|
// Test JavaScript file for formatting
|
||||||
const greeting = "Hello, World!";
|
const greeting = "Hello, World!";
|
||||||
|
|
||||||
function greet(name) {
|
function greet(name) {
|
||||||
return `Hello, ${name}!`;
|
return `Hello, ${name}!`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { greet };
|
export { greet };
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > src/components/Button.js << 'EOF'
|
cat > src/components/Button.js << 'EOF'
|
||||||
// Button component
|
// Button component
|
||||||
export default function Button({ children, onClick }) {
|
export default function Button({ children, onClick }) {
|
||||||
@@ -278,7 +284,7 @@ jobs:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create JSON file
|
# Create JSON file
|
||||||
cat > config.json << 'EOF'
|
cat > config.json << 'EOF'
|
||||||
{
|
{
|
||||||
@@ -290,7 +296,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create YAML file
|
# Create YAML file
|
||||||
cat > config.yml << 'EOF'
|
cat > config.yml << 'EOF'
|
||||||
name: test-config
|
name: test-config
|
||||||
@@ -302,7 +308,7 @@ jobs:
|
|||||||
- feature1
|
- feature1
|
||||||
- feature2
|
- feature2
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create Prettier config
|
# Create Prettier config
|
||||||
cat > .prettierrc.json << 'EOF'
|
cat > .prettierrc.json << 'EOF'
|
||||||
{
|
{
|
||||||
@@ -313,7 +319,7 @@ jobs:
|
|||||||
"tabWidth": 2
|
"tabWidth": 2
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Test web formatting workflow
|
- name: Test web formatting workflow
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -325,37 +331,37 @@ jobs:
|
|||||||
test-monorepo:
|
test-monorepo:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: validate-syntax
|
needs: validate-syntax
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create monorepo structure
|
- name: Create monorepo structure
|
||||||
run: |
|
run: |
|
||||||
mkdir -p monorepo-test/{backend,frontend}
|
mkdir -p monorepo-test/{backend,frontend}
|
||||||
|
|
||||||
# Backend Python project
|
# Backend Python project
|
||||||
cd monorepo-test/backend
|
cd monorepo-test/backend
|
||||||
cat > pyproject.toml << 'EOF'
|
cat > pyproject.toml << 'EOF'
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "backend-service"
|
name = "backend-service"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
dev = ["ruff>=0.1.0", "mypy>=1.0.0"]
|
dev = ["ruff>=0.1.0", "mypy>=1.0.0"]
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p src/backend_service
|
mkdir -p src/backend_service
|
||||||
cat > src/backend_service/__init__.py << 'EOF'
|
cat > src/backend_service/__init__.py << 'EOF'
|
||||||
"""Backend service package."""
|
"""Backend service package."""
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Frontend project
|
# Frontend project
|
||||||
cd ../frontend
|
cd ../frontend
|
||||||
cat > package.json << 'EOF'
|
cat > package.json << 'EOF'
|
||||||
@@ -364,20 +370,20 @@ jobs:
|
|||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p src
|
mkdir -p src
|
||||||
cat > src/App.js << 'EOF'
|
cat > src/App.js << 'EOF'
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return <div>Hello from frontend!</div>;
|
return <div>Hello from frontend!</div>;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Test backend code quality
|
- name: Test backend code quality
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
working-directory: "./monorepo-test/backend"
|
working-directory: "./monorepo-test/backend"
|
||||||
uv-extras: "dev"
|
uv-extras: "dev"
|
||||||
|
|
||||||
- name: Test frontend formatting
|
- name: Test frontend formatting
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -386,11 +392,11 @@ jobs:
|
|||||||
test-edge-cases:
|
test-edge-cases:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: validate-syntax
|
needs: validate-syntax
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test minimal Python project
|
- name: Test minimal Python project
|
||||||
run: |
|
run: |
|
||||||
mkdir minimal-python
|
mkdir minimal-python
|
||||||
@@ -399,18 +405,18 @@ jobs:
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "minimal"
|
name = "minimal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = []
|
dependencies = []
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p src/minimal
|
mkdir -p src/minimal
|
||||||
cat > src/minimal/__init__.py << 'EOF'
|
cat > src/minimal/__init__.py << 'EOF'
|
||||||
pass
|
pass
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Test with minimal configuration
|
- name: Test with minimal configuration
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -420,41 +426,47 @@ jobs:
|
|||||||
|
|
||||||
test-results:
|
test-results:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test-python-code-quality, test-python-pytest, test-web-formatting, test-monorepo, test-edge-cases]
|
needs:
|
||||||
|
- test-python-code-quality
|
||||||
|
- test-python-pytest
|
||||||
|
- test-web-formatting
|
||||||
|
- test-monorepo
|
||||||
|
- test-edge-cases
|
||||||
if: always()
|
if: always()
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Report test results
|
- name: Report test results
|
||||||
run: |
|
run: |
|
||||||
echo "## CI Template Test Results" >> $GITHUB_STEP_SUMMARY
|
echo "## CI Template Test Results" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
if [ "${{ needs.test-python-code-quality.result }}" == "success" ]; then
|
if [ "${{ needs.test-python-code-quality.result }}" == \
|
||||||
|
"success" ]; then
|
||||||
echo "✅ Python Code Quality: PASSED" >> $GITHUB_STEP_SUMMARY
|
echo "✅ Python Code Quality: PASSED" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "❌ Python Code Quality: FAILED" >> $GITHUB_STEP_SUMMARY
|
echo "❌ Python Code Quality: FAILED" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ needs.test-python-pytest.result }}" == "success" ]; then
|
if [ "${{ needs.test-python-pytest.result }}" == "success" ]; then
|
||||||
echo "✅ Python Pytest: PASSED" >> $GITHUB_STEP_SUMMARY
|
echo "✅ Python Pytest: PASSED" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "❌ Python Pytest: FAILED" >> $GITHUB_STEP_SUMMARY
|
echo "❌ Python Pytest: FAILED" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ needs.test-web-formatting.result }}" == "success" ]; then
|
if [ "${{ needs.test-web-formatting.result }}" == "success" ]; then
|
||||||
echo "✅ Web Formatting: PASSED" >> $GITHUB_STEP_SUMMARY
|
echo "✅ Web Formatting: PASSED" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "❌ Web Formatting: FAILED" >> $GITHUB_STEP_SUMMARY
|
echo "❌ Web Formatting: FAILED" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ needs.test-monorepo.result }}" == "success" ]; then
|
if [ "${{ needs.test-monorepo.result }}" == "success" ]; then
|
||||||
echo "✅ Monorepo Support: PASSED" >> $GITHUB_STEP_SUMMARY
|
echo "✅ Monorepo Support: PASSED" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "❌ Monorepo Support: FAILED" >> $GITHUB_STEP_SUMMARY
|
echo "❌ Monorepo Support: FAILED" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ needs.test-edge-cases.result }}" == "success" ]; then
|
if [ "${{ needs.test-edge-cases.result }}" == "success" ]; then
|
||||||
echo "✅ Edge Cases: PASSED" >> $GITHUB_STEP_SUMMARY
|
echo "✅ Edge Cases: PASSED" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "❌ Edge Cases: FAILED" >> $GITHUB_STEP_SUMMARY
|
echo "❌ Edge Cases: FAILED" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
---
|
||||||
name: Web/General Formatting Pipeline
|
name: Web/General Formatting Pipeline
|
||||||
|
|
||||||
on:
|
"on":
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
working-directory:
|
working-directory:
|
||||||
@@ -33,6 +34,11 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
python-version:
|
||||||
|
description: 'Python version to use for YAML linting (e.g., "3.12")'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: "3.12"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
formatting:
|
formatting:
|
||||||
@@ -40,7 +46,7 @@ jobs:
|
|||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -68,7 +74,7 @@ jobs:
|
|||||||
if: ${{ inputs.check-yaml }}
|
if: ${{ inputs.check-yaml }}
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: ${{ inputs.python-version }}
|
||||||
|
|
||||||
- name: Install yamllint
|
- name: Install yamllint
|
||||||
if: ${{ inputs.check-yaml }}
|
if: ${{ inputs.check-yaml }}
|
||||||
@@ -84,4 +90,4 @@ jobs:
|
|||||||
find . -name "*.json" -type f | while read -r file; do
|
find . -name "*.json" -type f | while read -r file; do
|
||||||
echo "Checking $file"
|
echo "Checking $file"
|
||||||
python -m json.tool "$file" > /dev/null
|
python -m json.tool "$file" > /dev/null
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ A formatting pipeline for web technologies and general file formats using Pretti
|
|||||||
|
|
||||||
📖 [Read the full documentation](README-web-formatting.md)
|
📖 [Read the full documentation](README-web-formatting.md)
|
||||||
|
|
||||||
## Quick Start
|
## Usage
|
||||||
|
|
||||||
### For Python Projects
|
### For Python Projects
|
||||||
|
|
||||||
|
|||||||
@@ -199,17 +199,26 @@ validate_workflow_file() {
|
|||||||
log_success "$filename is a reusable workflow"
|
log_success "$filename is a reusable workflow"
|
||||||
validate_workflow_inputs "$file"
|
validate_workflow_inputs "$file"
|
||||||
else
|
else
|
||||||
log_warning "$filename is not a reusable workflow (missing workflow_call trigger)"
|
# Skip warning for test files
|
||||||
|
if [[ "$filename" != *"test-"* ]]; then
|
||||||
|
log_warning "$filename is not a reusable workflow (missing workflow_call trigger)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for common issues
|
# Check for common issues
|
||||||
if grep -q "uses: \./\|uses: \.\\\\" "$file"; then
|
if grep -q "uses: \./\|uses: \.\\\\" "$file"; then
|
||||||
log_warning "Found relative path in 'uses' field in $file - this may cause issues"
|
# Skip warning for test files - they intentionally use relative paths to test local workflows
|
||||||
|
if [[ "$filename" != *"test-"* ]]; then
|
||||||
|
log_warning "Found relative path in 'uses' field in $file - this may cause issues"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for hardcoded values that should be inputs
|
# Check for hardcoded values that should be inputs
|
||||||
if grep -q "python-version: [\"']3\." "$file"; then
|
if grep -q "python-version: [\"']3\." "$file"; then
|
||||||
log_warning "Found hardcoded Python version in $file - consider making it an input"
|
# Skip warning for test files
|
||||||
|
if [[ "$filename" != *"test-"* ]]; then
|
||||||
|
log_warning "Found hardcoded Python version in $file - consider making it an input"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
((VALID_FILES++))
|
((VALID_FILES++))
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "test-validation-package"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Test package for CI template validation"
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
"mypy>=1.0.0",
|
||||||
|
"ruff>=0.1.0",
|
||||||
|
"pyupgrade>=3.0.0",
|
||||||
|
"pytest>=7.0.0",
|
||||||
|
"pytest-cov>=4.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 88
|
||||||
|
target-version = "py310"
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
python_version = "3.10"
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unused_configs = true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
"""Test package for validation."""
|
||||||
|
__version__ = "0.1.0"
|
||||||
|
|
||||||
|
def hello_world() -> str:
|
||||||
|
"""Return a greeting message."""
|
||||||
|
return "Hello, World!"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
"""Math utility functions."""
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
def add_numbers(numbers: List[float]) -> float:
|
||||||
|
"""Add a list of numbers."""
|
||||||
|
return sum(numbers)
|
||||||
|
|
||||||
|
def multiply_numbers(numbers: List[float]) -> float:
|
||||||
|
"""Multiply a list of numbers."""
|
||||||
|
result = 1.0
|
||||||
|
for num in numbers:
|
||||||
|
result *= num
|
||||||
|
return result
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
"""Tests for math utilities."""
|
||||||
|
import pytest
|
||||||
|
from test_package.math_utils import add_numbers, multiply_numbers
|
||||||
|
|
||||||
|
def test_add_numbers():
|
||||||
|
assert add_numbers([1, 2, 3]) == 6
|
||||||
|
assert add_numbers([]) == 0
|
||||||
|
assert add_numbers([5.5, 2.5]) == 8.0
|
||||||
|
|
||||||
|
def test_multiply_numbers():
|
||||||
|
assert multiply_numbers([2, 3, 4]) == 24
|
||||||
|
assert multiply_numbers([1]) == 1
|
||||||
|
assert multiply_numbers([2.5, 2]) == 5.0
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# CI Template Validation Report
|
||||||
|
|
||||||
|
Generated on: $(date)
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This report contains the validation results for the CI template workflows.
|
||||||
|
|
||||||
|
## Workflow Files
|
||||||
|
|
||||||
|
### .gitea/workflows/test-templates.yml
|
||||||
|
|
||||||
|
- **Size:** 13104 bytes
|
||||||
|
- **Lines:** 472 lines
|
||||||
|
- **Type:** Reusable workflow ✅
|
||||||
|
- **Input parameters:** 35
|
||||||
|
|
||||||
|
### .gitea/workflows/python/pytest.yml
|
||||||
|
|
||||||
|
- **Size:** 3311 bytes
|
||||||
|
- **Lines:** 111 lines
|
||||||
|
- **Type:** Reusable workflow ✅
|
||||||
|
- **Input parameters:** 20
|
||||||
|
|
||||||
|
### .gitea/workflows/python/code-quality.yml
|
||||||
|
|
||||||
|
- **Size:** 1954 bytes
|
||||||
|
- **Lines:** 79 lines
|
||||||
|
- **Type:** Reusable workflow ✅
|
||||||
|
- **Input parameters:** 14
|
||||||
|
|
||||||
|
### .gitea/workflows/web/formatting.yml
|
||||||
|
|
||||||
|
- **Size:** 2559 bytes
|
||||||
|
- **Lines:** 93 lines
|
||||||
|
- **Type:** Reusable workflow ✅
|
||||||
|
- **Input parameters:** 16
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
name: Web/General Formatting Pipeline
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
working-directory:
|
|
||||||
description: 'Working directory for the project'
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: "."
|
|
||||||
node-version:
|
|
||||||
description: 'Node.js version to use for prettier (e.g., "20")'
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: "20"
|
|
||||||
skip-prettier:
|
|
||||||
description: 'Skip prettier formatting check'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
prettier-config:
|
|
||||||
description: 'Path to prettier config file (optional)'
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: ""
|
|
||||||
check-yaml:
|
|
||||||
description: 'Check YAML files with yamllint'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
check-json:
|
|
||||||
description: 'Check JSON files for validity'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
formatting:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ${{ inputs.working-directory }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
if: ${{ !inputs.skip-prettier }}
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ inputs.node-version }}
|
|
||||||
|
|
||||||
- name: Install prettier
|
|
||||||
if: ${{ !inputs.skip-prettier }}
|
|
||||||
run: npm install --save-dev --save-exact prettier
|
|
||||||
|
|
||||||
- name: Run prettier check
|
|
||||||
if: ${{ !inputs.skip-prettier }}
|
|
||||||
run: |
|
|
||||||
if [ -n "${{ inputs.prettier-config }}" ]; then
|
|
||||||
npx prettier --check . --config ${{ inputs.prettier-config }}
|
|
||||||
else
|
|
||||||
npx prettier --check .
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Set up Python for YAML linting
|
|
||||||
if: ${{ inputs.check-yaml }}
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.12"
|
|
||||||
|
|
||||||
- name: Install yamllint
|
|
||||||
if: ${{ inputs.check-yaml }}
|
|
||||||
run: pip install yamllint
|
|
||||||
|
|
||||||
- name: Check YAML files
|
|
||||||
if: ${{ inputs.check-yaml }}
|
|
||||||
run: yamllint .
|
|
||||||
|
|
||||||
- name: Check JSON files
|
|
||||||
if: ${{ inputs.check-json }}
|
|
||||||
run: |
|
|
||||||
find . -name "*.json" -type f | while read -r file; do
|
|
||||||
echo "Checking $file"
|
|
||||||
python -m json.tool "$file" > /dev/null
|
|
||||||
done
|
|
||||||
Reference in New Issue
Block a user