From 4a63635e845ee9583135e079c15e5daa2a8b7650 Mon Sep 17 00:00:00 2001 From: BAK BYEONG JUN Date: Wed, 9 Apr 2025 07:22:43 +0000 Subject: [PATCH] init --- tasks/git-clone-checkout/task.yaml | 2 +- tasks/pytest/task.yaml | 34 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tasks/git-clone-checkout/task.yaml b/tasks/git-clone-checkout/task.yaml index 08fb099..dcdb03e 100644 --- a/tasks/git-clone-checkout/task.yaml +++ b/tasks/git-clone-checkout/task.yaml @@ -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 diff --git a/tasks/pytest/task.yaml b/tasks/pytest/task.yaml index 84b2b27..b6a7911 100644 --- a/tasks/pytest/task.yaml +++ b/tasks/pytest/task.yaml @@ -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