105 lines
3.3 KiB
YAML
105 lines
3.3 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: pylint
|
|
spec:
|
|
params:
|
|
- name: subdirectory
|
|
type: string
|
|
description: Subdirectory within the repo where the source code is located
|
|
default: ""
|
|
|
|
- name: imageName
|
|
type: string
|
|
description: Python version to use (e.g., 3.9, 3.11)
|
|
default: "python:3.11-slim"
|
|
|
|
- name: pylint-args
|
|
type: string
|
|
description: Additional arguments for pylint (e.g., --fail-under=8)
|
|
default: ""
|
|
|
|
- name: pypi-username
|
|
type: string
|
|
description: PyPI username (fallback)
|
|
default: ""
|
|
|
|
- name: pypi-password
|
|
type: string
|
|
description: PyPI password or token (fallback)
|
|
default: ""
|
|
|
|
workspaces:
|
|
- name: source
|
|
description: Workspace containing the cloned Git repository from git-clone-checkout
|
|
|
|
- name: pypi-auth
|
|
optional: true
|
|
description: |
|
|
A workspace containing authentication credentials for a private PyPI repository.
|
|
Should include:
|
|
- username
|
|
- password
|
|
|
|
steps:
|
|
- name: install-dependencies
|
|
image: $(params.imageName)
|
|
workingDir: /workspace/source
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
if [ -n "$(params.subdirectory)" ]; then
|
|
cd "$(params.subdirectory)"
|
|
fi
|
|
|
|
PYPI_USER="$(params.pypi-username)"
|
|
PYPI_PASS="$(params.pypi-password)"
|
|
|
|
if [ -f /workspace/pypi-auth/username ]; then
|
|
PYPI_USER=$(cat /workspace/pypi-auth/username)
|
|
fi
|
|
if [ -f /workspace/pypi-auth/password ]; then
|
|
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
|
fi
|
|
|
|
echo "🔧 Installing dependencies..."
|
|
pip install --upgrade pip --root-user-action=ignore
|
|
|
|
if [ -f pyproject.toml ]; then
|
|
echo "[INFO] Poetry project detected"
|
|
pip install poetry tomli --root-user-action=ignore
|
|
|
|
REPO_NAME=$(python3 -c 'import tomli; print(tomli.load(open("pyproject.toml", "rb"))["tool"]["poetry"]["source"][0]["name"])')
|
|
REPO_URL=$(python3 -c 'import tomli; print(tomli.load(open("pyproject.toml", "rb"))["tool"]["poetry"]["source"][0]["url"])')
|
|
|
|
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
|
|
poetry config virtualenvs.in-project true
|
|
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
|
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
|
|
|
poetry lock --no-cache --regenerate
|
|
poetry install
|
|
poetry add pylint --group dev
|
|
elif [ -f requirements.txt ]; then
|
|
echo "[INFO] Pip project detected"
|
|
pip install -r requirements.txt --root-user-action=ignore
|
|
pip install pylint --root-user-action=ignore
|
|
else
|
|
echo "[INFO] No dependency file found, installing pylint only"
|
|
pip install pylint --root-user-action=ignore
|
|
fi
|
|
|
|
echo "🧪 Running Pylint..."
|
|
set +e
|
|
if [ -f pyproject.toml ]; then
|
|
poetry run pylint $(params.pylint-args) .
|
|
else
|
|
pylint $(params.pylint-args) .
|
|
fi
|
|
PYLINT_EXIT_CODE=$?
|
|
set -e
|
|
|
|
echo "✅ Pylint execution completed with exit code: $PYLINT_EXIT_CODE"
|
|
exit 0 # 항상 성공 처리 (원래 onError: continue 효과)
|