From 453938d4939a2487dff97111eb6f0ac552c1a260 Mon Sep 17 00:00:00 2001 From: BAK BYEONG JUN Date: Sat, 12 Apr 2025 08:18:06 +0000 Subject: [PATCH] init --- tasks/pytest-playwright/task.yaml | 107 ------------------------------ tasks/pytest/task.yaml | 6 +- 2 files changed, 3 insertions(+), 110 deletions(-) delete mode 100644 tasks/pytest-playwright/task.yaml diff --git a/tasks/pytest-playwright/task.yaml b/tasks/pytest-playwright/task.yaml deleted file mode 100644 index c1aefb4..0000000 --- a/tasks/pytest-playwright/task.yaml +++ /dev/null @@ -1,107 +0,0 @@ -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: pytest-playwright -spec: - params: - - name: subdirectory - type: string - description: Subdirectory within the workspace where the tests are located - default: "" - - - name: playwright-python-image - type: string - description: Playwright Python image - default: "mcr.microsoft.com/playwright/python:v1.42.0-jammy" - - - name: pypi-username - type: string - description: PyPI username (fallback) - default: "" - - - name: pypi-password - type: string - description: PyPI password or token (fallback) - default: "" - - workspaces: - - name: source - description: Workspace containing the cloned Git repository from git-clone-checkout - - - name: pypi-auth - optional: true - description: | - A workspace containing authentication credentials for a private PyPI repository. - Should include: - - username - - password - - steps: - - name: install-dependencies - image: $(params.playwright-python-image) - workingDir: /workspace/source - script: | - #!/usr/bin/env bash - set -e - - if [ -n "$(params.subdirectory)" ]; then - cd "$(params.subdirectory)" - fi - - PYPI_USER="$(params.pypi-username)" - PYPI_PASS="$(params.pypi-password)" - - if [ -f /workspace/pypi-auth/username ]; then - PYPI_USER=$(cat /workspace/pypi-auth/username) - fi - if [ -f /workspace/pypi-auth/password ]; then - PYPI_PASS=$(cat /workspace/pypi-auth/password) - fi - - - 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" - - poetry lock --no-cache --regenerate - poetry install - 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 - - 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 - TEST_EXIT_CODE=$? - set -e - - 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" - exit 1 - fi - - exit $TEST_EXIT_CODE - \ No newline at end of file diff --git a/tasks/pytest/task.yaml b/tasks/pytest/task.yaml index 1662bb6..79cc788 100644 --- a/tasks/pytest/task.yaml +++ b/tasks/pytest/task.yaml @@ -9,10 +9,10 @@ spec: description: Subdirectory within the workspace where the tests are located default: "" - - name: python-version + - name: imageName type: string description: Python version to use (e.g., 3.9, 3.11) - default: "3.9" + default: "python:3.11-slim" - name: pypi-username type: string @@ -38,7 +38,7 @@ spec: steps: - name: install-dependencies - image: python:$(params.python-version)-slim + image: $(params.imageName) workingDir: /workspace/source script: | #!/usr/bin/env bash