This commit is contained in:
병준 박 2025-04-09 07:22:43 +00:00
parent 9fdc393cd4
commit 4a63635e84
2 changed files with 21 additions and 15 deletions

View File

@ -213,7 +213,7 @@ spec:
-depth="${PARAM_DEPTH}" \
-sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}"
cd "${CHECKOUT_DIR}"
ls -al
RESULT_SHA="$(git rev-parse HEAD)"
EXIT_CODE="$?"
if [ "${EXIT_CODE}" != 0 ] ; then

View File

@ -6,8 +6,8 @@ spec:
params:
- name: subdirectory
type: string
description: Subdirectory within the repo where the tests are located
default: ""
description: Subdirectory within the workspace where the tests are located
default: "" # 기본값을 빈 문자열로 설정, 필요 시 repo로 변경
- name: python-version
type: string
description: Python version to use (e.g., 3.9, 3.11)
@ -16,32 +16,39 @@ spec:
- name: source
description: Workspace containing the cloned Git repository from git-clone-checkout
steps:
- name: debug-workspace
image: ubuntu
workingDir: /workspace/source
script: |
#!/usr/bin/env bash
echo "Listing contents of /workspace/source:"
ls -la
if [ -n "$(params.subdirectory)" ]; then
if [ -d "$(params.subdirectory)" ]; then
echo "Subdirectory $(params.subdirectory) exists:"
ls -la $(params.subdirectory)
else
echo "Subdirectory $(params.subdirectory) not found!"
exit 1
fi
fi
- name: install-dependencies
image: python:$(params.python-version)-slim
workingDir: /workspace/source
script: |
#!/usr/bin/env bash
ls -al /workspace/source
if [ -n "$(params.subdirectory)" ]; then
cd $(params.subdirectory)
fi
pip install --upgrade pip
# Poetry가 있는 경우 설치 및 의존성 처리
pip install pytest
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
# Pip fallback (requirements.txt)
elif [ -f requirements.txt ]; then
echo "Detected Pip project (requirements.txt found)"
pip install -r requirements.txt
else
echo "No dependency file found, installing pytest only"
fi
pip install pytest # pytest는 항상 설치
- name: run-tests
image: python:$(params.python-version)-slim
workingDir: /workspace/source
@ -50,13 +57,12 @@ spec:
if [ -n "$(params.subdirectory)" ]; then
cd $(params.subdirectory)
fi
# Poetry가 사용된 경우 가상환경에서 실행
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 # 테스트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
onError: continue
- name: check-results
image: ubuntu
workingDir: /workspace/source