init
This commit is contained in:
parent
49208c624a
commit
c16b8fe06b
@ -52,8 +52,6 @@ spec:
|
|||||||
cd "$(params.subdirectory)"
|
cd "$(params.subdirectory)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip --root-user-action=ignore
|
|
||||||
|
|
||||||
PYPI_USER="$(params.pypi-username)"
|
PYPI_USER="$(params.pypi-username)"
|
||||||
PYPI_PASS="$(params.pypi-password)"
|
PYPI_PASS="$(params.pypi-password)"
|
||||||
|
|
||||||
@ -64,66 +62,48 @@ spec:
|
|||||||
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "🔧 Installing dependencies..."
|
||||||
|
pip install --upgrade pip --root-user-action=ignore
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
echo "[INFO] Poetry project detected"
|
echo "[INFO] Poetry project detected"
|
||||||
pip install poetry tomli --root-user-action=ignore
|
pip install poetry tomli --root-user-action=ignore
|
||||||
poetry config virtualenvs.in-project true
|
|
||||||
|
|
||||||
REPO_NAME=$(python3 -c 'import tomli; print(tomli.load(open("pyproject.toml", "rb"))["tool"]["poetry"]["source"][0]["name"])')
|
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"])')
|
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"
|
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
|
||||||
|
poetry config virtualenvs.in-project true
|
||||||
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
||||||
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
||||||
|
|
||||||
|
poetry lock --no-cache --regenerate
|
||||||
poetry install --no-root
|
poetry install --no-root
|
||||||
|
|
||||||
|
echo "📦 Building package with Poetry..."
|
||||||
|
poetry build
|
||||||
|
|
||||||
elif [ -f requirements.txt ] && [ -f setup.py ]; then
|
elif [ -f requirements.txt ] && [ -f setup.py ]; then
|
||||||
echo "[INFO] Pip + setup.py project detected"
|
echo "[INFO] setup.py project detected"
|
||||||
pip install -r requirements.txt --root-user-action=ignore
|
pip install -r requirements.txt --root-user-action=ignore
|
||||||
pip install build --root-user-action=ignore
|
pip install build --root-user-action=ignore
|
||||||
|
|
||||||
|
echo "📦 Building package with build module..."
|
||||||
|
python -m build
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "[ERROR] No valid build configuration found (pyproject.toml or setup.py required)"
|
echo "[ERROR] No valid build configuration found (pyproject.toml or setup.py required)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: build-package
|
echo "📂 Verifying built artifacts..."
|
||||||
image: python:$(params.python-version)-slim
|
BUILD_PATH="/workspace/source/$(params.subdirectory)/dist"
|
||||||
workingDir: /workspace/source
|
echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A $BUILD_PATH)" ]; then
|
||||||
cd "$(params.subdirectory)"
|
echo "✅ Build artifacts created in $BUILD_PATH:"
|
||||||
fi
|
ls -l "$BUILD_PATH"
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
|
||||||
poetry build
|
|
||||||
elif [ -f setup.py ]; then
|
|
||||||
python -m build
|
|
||||||
else
|
else
|
||||||
echo "[ERROR] No build tool available"
|
echo "❌ No build artifacts found in $BUILD_PATH"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Built artifacts located in dist/"
|
|
||||||
ls -l dist/
|
|
||||||
|
|
||||||
echo -n "/workspace/source/$(params.subdirectory)/dist" > /tekton/results/build-artifact-path
|
|
||||||
|
|
||||||
- name: verify-build
|
|
||||||
image: ubuntu
|
|
||||||
workingDir: /workspace/source
|
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DIST_PATH=$(cat /tekton/results/build-artifact-path)
|
|
||||||
if [ -d "$DIST_PATH" ] && [ -n "$(ls -A $DIST_PATH)" ]; then
|
|
||||||
echo "✅ Build artifacts successfully created in $DIST_PATH:"
|
|
||||||
ls -l $DIST_PATH
|
|
||||||
else
|
|
||||||
echo "❌ No build artifacts found in $DIST_PATH"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -53,8 +53,6 @@ spec:
|
|||||||
cd "$(params.subdirectory)"
|
cd "$(params.subdirectory)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip --root-user-action=ignore
|
|
||||||
|
|
||||||
PYPI_USER="$(params.pypi-username)"
|
PYPI_USER="$(params.pypi-username)"
|
||||||
PYPI_PASS="$(params.pypi-password)"
|
PYPI_PASS="$(params.pypi-password)"
|
||||||
|
|
||||||
@ -65,18 +63,22 @@ spec:
|
|||||||
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "🔧 Installing dependencies..."
|
||||||
|
pip install --upgrade pip --root-user-action=ignore
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
echo "[INFO] Poetry project detected"
|
echo "[INFO] Poetry project detected"
|
||||||
pip install poetry tomli --root-user-action=ignore
|
pip install poetry tomli --root-user-action=ignore
|
||||||
poetry config virtualenvs.in-project true
|
|
||||||
|
|
||||||
REPO_NAME=$(python3 -c 'import tomli; print(tomli.load(open("pyproject.toml", "rb"))["tool"]["poetry"]["source"][0]["name"])')
|
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"])')
|
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"
|
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
|
||||||
|
poetry config virtualenvs.in-project true
|
||||||
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
||||||
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
||||||
|
|
||||||
|
poetry lock --no-cache --regenerate
|
||||||
poetry install --no-root
|
poetry install --no-root
|
||||||
poetry add pylint --group dev
|
poetry add pylint --group dev
|
||||||
elif [ -f requirements.txt ]; then
|
elif [ -f requirements.txt ]; then
|
||||||
@ -88,27 +90,15 @@ spec:
|
|||||||
pip install pylint --root-user-action=ignore
|
pip install pylint --root-user-action=ignore
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: run-lint
|
echo "🧪 Running Pylint..."
|
||||||
image: python:$(params.python-version)-slim
|
set +e
|
||||||
workingDir: /workspace/source
|
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
|
||||||
cd "$(params.subdirectory)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
poetry run pylint $(params.pylint-args) .
|
poetry run pylint $(params.pylint-args) .
|
||||||
else
|
else
|
||||||
pylint $(params.pylint-args) .
|
pylint $(params.pylint-args) .
|
||||||
fi
|
fi
|
||||||
onError: continue # 린트 실패해도 파이프라인 중단하지 않음
|
PYLINT_EXIT_CODE=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
- name: check-results
|
echo "✅ Pylint execution completed with exit code: $PYLINT_EXIT_CODE"
|
||||||
image: ubuntu
|
exit 0 # 항상 성공 처리 (원래 onError: continue 효과)
|
||||||
workingDir: /workspace/source
|
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo "✅ Pylint execution completed."
|
|
||||||
|
@ -46,9 +46,6 @@ spec:
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
pip install --upgrade pip --root-user-action=ignore
|
|
||||||
pip install poetry twine tomli --root-user-action=ignore
|
|
||||||
|
|
||||||
TWINE_USERNAME="$(params.pypi-username)"
|
TWINE_USERNAME="$(params.pypi-username)"
|
||||||
TWINE_PASSWORD="$(params.pypi-password)"
|
TWINE_PASSWORD="$(params.pypi-password)"
|
||||||
HOSTED_URL="$(params.pypi-hosted-url)"
|
HOSTED_URL="$(params.pypi-hosted-url)"
|
||||||
@ -60,12 +57,19 @@ spec:
|
|||||||
TWINE_PASSWORD=$(cat /workspace/pypi-auth/password)
|
TWINE_PASSWORD=$(cat /workspace/pypi-auth/password)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pip install --upgrade pip --root-user-action=ignore
|
||||||
|
pip install poetry twine --root-user-action=ignore
|
||||||
|
|
||||||
# poetry 설정이 필요한 경우 pyproject.toml 분석
|
# poetry 설정이 필요한 경우 pyproject.toml 분석
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
|
echo "[INFO] Using Poetry to install dependencies"
|
||||||
|
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_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"])')
|
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"
|
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
|
||||||
|
poetry config virtualenvs.in-project true
|
||||||
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
||||||
poetry config http-basic."$REPO_NAME" "$TWINE_USERNAME" "$TWINE_PASSWORD"
|
poetry config http-basic."$REPO_NAME" "$TWINE_USERNAME" "$TWINE_PASSWORD"
|
||||||
fi
|
fi
|
||||||
|
@ -48,13 +48,6 @@ spec:
|
|||||||
cd "$(params.subdirectory)"
|
cd "$(params.subdirectory)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip --root-user-action=ignore
|
|
||||||
pip install pytest --root-user-action=ignore
|
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
|
||||||
echo "[INFO] Using Poetry to install dependencies"
|
|
||||||
pip install poetry tomli --root-user-action=ignore
|
|
||||||
|
|
||||||
PYPI_USER="$(params.pypi-username)"
|
PYPI_USER="$(params.pypi-username)"
|
||||||
PYPI_PASS="$(params.pypi-password)"
|
PYPI_PASS="$(params.pypi-password)"
|
||||||
|
|
||||||
@ -65,13 +58,19 @@ spec:
|
|||||||
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
PYPI_PASS=$(cat /workspace/pypi-auth/password)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[INFO] PYPI_PASS: $PYPI_PASS"
|
|
||||||
|
echo "🔧 Installing dependencies..."
|
||||||
|
pip install --upgrade pip --root-user-action=ignore
|
||||||
|
pip install pytest --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_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"])')
|
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"
|
echo "[INFO] Configuring poetry source '$REPO_NAME' → $REPO_URL"
|
||||||
|
|
||||||
poetry config virtualenvs.in-project true
|
poetry config virtualenvs.in-project true
|
||||||
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
poetry config repositories."$REPO_NAME" "$REPO_URL"
|
||||||
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
poetry config http-basic."$REPO_NAME" "$PYPI_USER" "$PYPI_PASS"
|
||||||
@ -81,37 +80,27 @@ spec:
|
|||||||
elif [ -f requirements.txt ]; then
|
elif [ -f requirements.txt ]; then
|
||||||
echo "[INFO] Using pip to install dependencies"
|
echo "[INFO] Using pip to install dependencies"
|
||||||
pip install -r requirements.txt --root-user-action=ignore
|
pip install -r requirements.txt --root-user-action=ignore
|
||||||
|
else
|
||||||
|
echo "[WARN] No dependency file found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: run-tests
|
echo "🧪 Running tests..."
|
||||||
image: python:$(params.python-version)-slim
|
set +e
|
||||||
workingDir: /workspace/source
|
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
|
||||||
cd "$(params.subdirectory)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
poetry run pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
poetry run pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
||||||
else
|
else
|
||||||
pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
||||||
fi
|
fi
|
||||||
onError: continue
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
- name: check-results
|
|
||||||
image: ubuntu
|
|
||||||
workingDir: /workspace/source
|
|
||||||
script: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -f pytest-results.xml ]; then
|
echo "📄 Checking test results..."
|
||||||
echo "Test results generated: pytest-results.xml"
|
if [ -f /workspace/source/pytest-results.xml ]; then
|
||||||
cat pytest-results.xml
|
echo "Test results:"
|
||||||
|
cat /workspace/source/pytest-results.xml
|
||||||
else
|
else
|
||||||
echo "No test results found."
|
echo "❌ No test results found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exit $TEST_EXIT_CODE
|
Loading…
x
Reference in New Issue
Block a user