This commit is contained in:
병준 박 2025-04-15 09:17:28 +00:00
parent c8977d5764
commit e892b891fb

View File

@ -19,53 +19,53 @@ spec:
description: Workspace containing the cloned Git repository from git-clone-checkout description: Workspace containing the cloned Git repository from git-clone-checkout
steps: steps:
- name: install-dependencies - name: install-dependencies
image: $(params.pythonImageName) image: $(params.pythonImageName)
workingDir: /workspace/source/$(params.subdirectory) workingDir: /workspace/source/$(params.subdirectory)
env: env:
- name: HOME - name: HOME
value: /workspace/shared/$(params.subdirectory)/___HOME___ value: /workspace/shared/$(params.subdirectory)/___HOME___
script: | script: |
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
echo "HOME=$HOME" echo "HOME=$HOME"
echo "🔧 Installing dependencies..." echo "🔧 Installing dependencies..."
pip install --upgrade pip --root-user-action=ignore pip install --upgrade pip --root-user-action=ignore
pip install pytest --root-user-action=ignore pip install pytest --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 --root-user-action=ignore pip install poetry --root-user-action=ignore
echo "[INFO] Using pre-configured poetry settings from $HOME/.config/pypoetry/" echo "[INFO] Using pre-configured poetry settings from $HOME/.config/pypoetry/"
poetry lock --no-cache --no-update poetry lock --no-cache --no-update
poetry install poetry install
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 else
echo "[WARN] No dependency file found" echo "[WARN] No dependency file found"
fi fi
echo "🧪 Running tests..." echo "🧪 Running tests..."
set +e set +e
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
TEST_EXIT_CODE=$? TEST_EXIT_CODE=$?
set -e set -e
echo "📄 Checking test results..." echo "📄 Checking test results..."
if [ -f /workspace/source/pytest-results.xml ]; then if [ -f /workspace/source/pytest-results.xml ]; then
echo "Test results:" echo "Test results:"
cat /workspace/source/pytest-results.xml 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 exit $TEST_EXIT_CODE