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