This commit is contained in:
병준 박 2025-04-10 14:26:42 +00:00
parent 935addf001
commit a4ff1ba822
4 changed files with 42 additions and 70 deletions

View File

@ -24,14 +24,10 @@ spec:
description: PyPI password or token (fallback)
default: ""
- name: pypi-group-url
type: string
description: PyPI repository URL (install endpoint)
default: https://upload.pypi.org/legacy/
workspaces:
- name: source
description: Workspace containing the cloned Git repository from git-clone-checkout
- name: pypi-auth
optional: true
description: |
@ -60,7 +56,6 @@ spec:
PYPI_USER="$(params.pypi-username)"
PYPI_PASS="$(params.pypi-password)"
PYPI_URL="$(params.pypi-group-url)"
if [ -f /workspace/pypi-auth/username ]; then
PYPI_USER=$(cat /workspace/pypi-auth/username)
@ -71,22 +66,22 @@ spec:
if [ -f pyproject.toml ]; then
echo "[INFO] Poetry project detected"
pip install poetry --root-user-action=ignore
pip install poetry tomli --root-user-action=ignore
poetry config virtualenvs.in-project true
if [ -n "$PYPI_URL" ]; then
REPO_NAME=$(echo "$PYPI_URL" | sed -E 's#https?://([^/]+)/repository/([^/]+)/?.*#\1_\2#' | tr -cd '[:alnum:]_')
echo "[INFO] Configuring poetry source '$REPO_NAME' → $PYPI_URL"
poetry config repositories."$REPO_NAME" "$PYPI_URL"
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 repositories."$REPO_NAME" "$REPO_URL"
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
fi
poetry install --no-root
elif [ -f requirements.txt ] && [ -f setup.py ]; then
echo "[INFO] Pip + setup.py project detected"
pip install -r requirements.txt
pip install build
pip install -r requirements.txt --root-user-action=ignore
pip install build --root-user-action=ignore
else
echo "[ERROR] No valid build configuration found (pyproject.toml or setup.py required)"
exit 1
@ -115,7 +110,6 @@ spec:
echo "Built artifacts located in dist/"
ls -l dist/
# Save result path
echo -n "/workspace/source/$(params.subdirectory)/dist" > /tekton/results/build-artifact-path
- name: verify-build

View File

@ -1,4 +1,4 @@
apiVersion: tekton.dev/v1
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: pylint
@ -29,11 +29,6 @@ spec:
description: PyPI password or token (fallback)
default: ""
- name: pypi-group-url
type: string
description: PyPI repository URL (install endpoint)
default: https://upload.pypi.org/legacy/
workspaces:
- name: source
description: Workspace containing the cloned Git repository from git-clone-checkout
@ -62,7 +57,6 @@ spec:
PYPI_USER="$(params.pypi-username)"
PYPI_PASS="$(params.pypi-password)"
PYPI_URL="$(params.pypi-group-url)"
if [ -f /workspace/pypi-auth/username ]; then
PYPI_USER=$(cat /workspace/pypi-auth/username)
@ -73,26 +67,25 @@ spec:
if [ -f pyproject.toml ]; then
echo "[INFO] Poetry project detected"
pip install poetry --root-user-action=ignore
pip install poetry tomli --root-user-action=ignore
poetry config virtualenvs.in-project true
if [ -n "$PYPI_URL" ]; then
REPO_NAME=$(echo "$PYPI_URL" | sed -E 's#https?://([^/]+)/repository/([^/]+)/?.*#\1_\2#' | tr -cd '[:alnum:]_')
echo "[INFO] Configuring poetry source '$REPO_NAME' with URL: $PYPI_URL"
poetry config repositories."$REPO_NAME" "$PYPI_URL"
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 repositories."$REPO_NAME" "$REPO_URL"
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
fi
poetry install --no-root
poetry add pylint --group dev
elif [ -f requirements.txt ]; then
echo "[INFO] Pip project detected"
pip install -r requirements.txt
pip install pylint
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
pip install pylint --root-user-action=ignore
fi
- name: run-lint
@ -111,11 +104,11 @@ spec:
else
pylint $(params.pylint-args) .
fi
onError: continue # 린트 실패해도 실패로 간주하지 않음
onError: continue # 린트 실패해도 파이프라인 중단하지 않음
- name: check-results
image: ubuntu
workingDir: /workspace/source
script: |
#!/usr/bin/env bash
echo "Pylint execution completed."
echo "Pylint execution completed."

View File

@ -25,12 +25,7 @@ spec:
- name: pypi-hosted-url
type: string
description: PyPI repository URL (upload endpoint)
default: https://upload.pypi.org/legacy/
- name: pypi-group-url
type: string
description: PyPI repository URL (install endpoint)
description: PyPI repository URL for upload
default: https://upload.pypi.org/legacy/
workspaces:
@ -39,7 +34,7 @@ spec:
- name: pypi-auth
optional: true
description: |
Optional workspace containing:
A workspace containing:
- username
- password
@ -52,15 +47,12 @@ spec:
set -e
pip install --upgrade pip --root-user-action=ignore
pip install poetry twine --root-user-action=ignore
pip install poetry twine tomli --root-user-action=ignore
# 기본값 (params)
TWINE_USERNAME="$(params.pypi-username)"
TWINE_PASSWORD="$(params.pypi-password)"
HOSTED_URL="$(params.pypi-hosted-url)"
GROUP_URL="$(params.pypi-group-url)"
# pypi-auth workspace에 있으면 override
if [ -f /workspace/pypi-auth/username ]; then
TWINE_USERNAME=$(cat /workspace/pypi-auth/username)
fi
@ -68,22 +60,21 @@ spec:
TWINE_PASSWORD=$(cat /workspace/pypi-auth/password)
fi
echo "[INFO] Twine Upload URL: $HOSTED_URL"
# poetry config (install용 group-url 사용)
# poetry 설정이 필요한 경우 pyproject.toml 분석
if [ -f pyproject.toml ]; then
REPO_NAME=$(echo "$GROUP_URL" | sed -E 's#https?://([^/]+)/repository/([^/]+)/?.*#\1_\2#' | tr -cd '[:alnum:]_')
echo "[INFO] Configuring poetry install repo: $REPO_NAME -> $GROUP_URL"
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"])')
poetry config repositories."$REPO_NAME" "$GROUP_URL"
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
poetry config repositories."$REPO_NAME" "$REPO_URL"
poetry config http-basic."$REPO_NAME" "$TWINE_USERNAME" "$TWINE_PASSWORD"
fi
echo "[INFO] Uploading artifacts with Twine..."
echo "[INFO] Uploading artifacts to $HOSTED_URL"
twine upload \
--repository-url "$HOSTED_URL" \
--username "$TWINE_USERNAME" \
--password "$TWINE_PASSWORD" \
"$(params.build-artifact-path)"/*
echo "[INFO] Successfully uploaded to PyPI"
echo "[INFO] ✅ Upload to PyPI complete"

View File

@ -24,11 +24,6 @@ spec:
description: PyPI password or token (fallback)
default: ""
- name: pypi-group-url
type: string
description: PyPI repository URL (install endpoint)
default: https://upload.pypi.org/legacy/
workspaces:
- name: source
description: Workspace containing the cloned Git repository from git-clone-checkout
@ -54,17 +49,16 @@ spec:
fi
pip install --upgrade pip --root-user-action=ignore
pip install pytest
pip install pytest --root-user-action=ignore
if [ -f pyproject.toml ]; then
echo "[INFO] Using Poetry to install dependencies"
pip install poetry --root-user-action=ignore
pip install poetry tomli --root-user-action=ignore
poetry config virtualenvs.in-project true
poetry lock --no-cache --regenerate
PYPI_USER="$(params.pypi-username)"
PYPI_PASS="$(params.pypi-password)"
PYPI_URL="$(params.pypi-group-url)"
if [ -f /workspace/pypi-auth/username ]; then
PYPI_USER=$(cat /workspace/pypi-auth/username)
@ -73,17 +67,17 @@ spec:
PYPI_PASS=$(cat /workspace/pypi-auth/password)
fi
if [ -n "$PYPI_URL" ]; then
REPO_NAME=$(echo "$PYPI_URL" | sed -E 's#https?://([^/]+)/repository/([^/]+)/?.*#\1_\2#' | tr -cd '[:alnum:]_')
echo "[INFO] Configuring poetry source '$REPO_NAME': $PYPI_URL"
poetry config repositories."$REPO_NAME" "$PYPI_URL"
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 repositories."$REPO_NAME" "$REPO_URL"
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
fi
poetry install --no-root
elif [ -f requirements.txt ]; then
echo "[INFO] Using pip to install dependencies"
pip install -r requirements.txt
pip install -r requirements.txt --root-user-action=ignore
fi
- name: run-tests