70 lines
2.4 KiB
YAML
70 lines
2.4 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: python-version
|
|
type: string
|
|
description: Python version to use (e.g., 3.9, 3.11)
|
|
default: "3.9"
|
|
- name: pylint-args
|
|
type: string
|
|
description: Additional arguments for pylint (e.g., --fail-under=8)
|
|
default: ""
|
|
workspaces:
|
|
- name: source
|
|
description: Workspace containing the cloned Git repository from git-clone-checkout
|
|
steps:
|
|
- name: install-dependencies
|
|
image: python:$(params.python-version)-slim
|
|
workingDir: /workspace/source
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
if [ -n "$(params.subdirectory)" ]; then
|
|
cd $(params.subdirectory)
|
|
fi
|
|
pip install --upgrade pip
|
|
# Poetry가 있는 경우 설치 및 의존성 처리
|
|
if [ -f pyproject.toml ]; then
|
|
echo "Detected Poetry project (pyproject.toml found)"
|
|
pip install poetry
|
|
poetry config virtualenvs.in-project true
|
|
poetry install --no-root
|
|
poetry add pylint --group dev # Pylint를 개발 의존성으로 추가
|
|
# Pip fallback (requirements.txt)
|
|
elif [ -f requirements.txt ]; then
|
|
echo "Detected Pip project (requirements.txt found)"
|
|
pip install -r requirements.txt
|
|
pip install pylint
|
|
else
|
|
echo "No dependency file found, installing pylint only"
|
|
pip install pylint
|
|
fi
|
|
- name: run-lint
|
|
image: python:$(params.python-version)-slim
|
|
workingDir: /workspace/source
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
if [ -n "$(params.subdirectory)" ]; then
|
|
cd $(params.subdirectory)
|
|
fi
|
|
# Poetry가 사용된 경우 가상환경에서 실행
|
|
if [ -f pyproject.toml ]; then
|
|
poetry run pylint $(params.pylint-args) .
|
|
else
|
|
pylint $(params.pylint-args) .
|
|
fi
|
|
onError: continue # 린트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
|
|
- name: check-results
|
|
image: ubuntu
|
|
workingDir: /workspace/source
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
echo "Pylint execution completed."
|
|
# Pylint 결과를 별도 파일로 저장하려면 run-lint에서 --output 옵션 추가 필요
|