init
This commit is contained in:
parent
4da8758bd3
commit
e0b813a46a
@ -2,25 +2,7 @@ apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: git-clone-checkout
|
||||
# labels:
|
||||
# app.kubernetes.io/version: "0.9"
|
||||
# annotations:
|
||||
# tekton.dev/pipelines.minVersion: "0.38.0"
|
||||
# tekton.dev/categories: Git
|
||||
# tekton.dev/tags: git
|
||||
# tekton.dev/displayName: "git clone and checkout"
|
||||
# tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
|
||||
spec:
|
||||
description: >-
|
||||
These Tasks are Git tasks to work with repositories used by other tasks
|
||||
in your Pipeline.
|
||||
|
||||
The git-clone Task will clone a repo from the provided url into the
|
||||
output Workspace. By default the repo will be cloned into the root of
|
||||
your Workspace. You can clone into a subdirectory by setting this Task's
|
||||
subdirectory param. This Task also supports sparse checkouts. To perform
|
||||
a sparse checkout, pass a list of comma separated directory patterns to
|
||||
this Task's sparseCheckoutDirectories param.
|
||||
workspaces:
|
||||
- name: output
|
||||
description: The git repo will be cloned onto the volume backing this Workspace.
|
||||
|
@ -1,69 +0,0 @@
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: poetry
|
||||
namespace: gitops-ci
|
||||
labels:
|
||||
app.kubernetes.io/version: "0.4"
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.21.0"
|
||||
tekton.dev/categories: Poetry
|
||||
tekton.dev/tags: poetry
|
||||
tekton.dev/displayName: "poetry"
|
||||
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le"
|
||||
spec:
|
||||
description: >-
|
||||
This task can be used to perform python poetry operations.
|
||||
|
||||
python poetry command that needs to be run can be passed as a script to
|
||||
the task.
|
||||
|
||||
workspaces:
|
||||
- name: source
|
||||
description: A workspace that contains python source.
|
||||
|
||||
params:
|
||||
- name: BASE_IMAGE
|
||||
description: |
|
||||
The base image for the task.
|
||||
type: string
|
||||
default: python:3.13.2-bullseye
|
||||
|
||||
- name: POETRY_VERSION
|
||||
description: |
|
||||
The base version of the poetry.
|
||||
type: string
|
||||
default: 2.1.2
|
||||
|
||||
- name: POETRY_SCRIPT
|
||||
description: The poetry and python script to run.
|
||||
type: string
|
||||
default: |
|
||||
poetry help
|
||||
|
||||
- name: VERBOSE
|
||||
description: Log the commands that are executed during operation.
|
||||
type: string
|
||||
default: "true"
|
||||
|
||||
steps:
|
||||
- name: poetry
|
||||
image: $(params.BASE_IMAGE)
|
||||
workingDir: $(workspaces.source.path)
|
||||
env:
|
||||
- name: POETRY_VERSION
|
||||
value: $(params.POETRY_VERSION)
|
||||
- name: PARAM_VERBOSE
|
||||
value: $(params.VERBOSE)
|
||||
script: |
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
if [ "${PARAM_VERBOSE}" = "true" ] ; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
pipx install poetry==${POETRY_VERSION}
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
eval '$(params.POETRY_SCRIPT)'
|
82
tasks/pybuild/task.yaml
Normal file
82
tasks/pybuild/task.yaml
Normal file
@ -0,0 +1,82 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pybuild
|
||||
spec:
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
description: Subdirectory within the repo where the source code is located
|
||||
default: ""
|
||||
- name: python-version
|
||||
type: string
|
||||
description: Python version to use (e.g., 3.9, 3.11)
|
||||
default: "3.9"
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Workspace containing the cloned Git repository from git-clone-checkout
|
||||
results:
|
||||
- name: build-artifact-path
|
||||
description: Path to the built artifact directory (e.g., dist/)
|
||||
steps:
|
||||
- name: install-dependencies
|
||||
image: python:$(params.python-version)-slim
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
pip install --upgrade pip
|
||||
# Poetry가 있는 경우 설치 및 의존성 처리
|
||||
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 및 setup.py)
|
||||
elif [ -f requirements.txt ] && [ -f setup.py ]; then
|
||||
echo "Detected Pip project (requirements.txt and setup.py found)"
|
||||
pip install -r requirements.txt
|
||||
pip install 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
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
# Poetry가 사용된 경우
|
||||
if [ -f pyproject.toml ]; then
|
||||
poetry build
|
||||
echo "Built artifacts located in dist/"
|
||||
ls -l dist/
|
||||
# Pip 및 setup.py 사용
|
||||
elif [ -f setup.py ]; then
|
||||
python -m build
|
||||
echo "Built artifacts located in dist/"
|
||||
ls -l dist/
|
||||
else
|
||||
echo "Error: No build tool available"
|
||||
exit 1
|
||||
fi
|
||||
# 빌드 결과 경로를 결과로 저장
|
||||
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
|
||||
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 "Error: No build artifacts found in $DIST_PATH"
|
||||
exit 1
|
||||
fi
|
69
tasks/pylint/task.yaml
Normal file
69
tasks/pylint/task.yaml
Normal file
@ -0,0 +1,69 @@
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pylint
|
||||
spec:
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
description: Subdirectory within the repo where the source code is located
|
||||
default: ""
|
||||
- name: python-version
|
||||
type: string
|
||||
description: Python version to use (e.g., 3.9, 3.11)
|
||||
default: "3.9"
|
||||
- name: pylint-args
|
||||
type: string
|
||||
description: Additional arguments for pylint (e.g., --fail-under=8)
|
||||
default: ""
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Workspace containing the cloned Git repository from git-clone-checkout
|
||||
steps:
|
||||
- name: install-dependencies
|
||||
image: python:$(params.python-version)-slim
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
pip install --upgrade pip
|
||||
# Poetry가 있는 경우 설치 및 의존성 처리
|
||||
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
|
||||
poetry add pylint --group dev # Pylint를 개발 의존성으로 추가
|
||||
# Pip fallback (requirements.txt)
|
||||
elif [ -f requirements.txt ]; then
|
||||
echo "Detected Pip project (requirements.txt found)"
|
||||
pip install -r requirements.txt
|
||||
pip install pylint
|
||||
else
|
||||
echo "No dependency file found, installing pylint only"
|
||||
pip install pylint
|
||||
fi
|
||||
- name: run-lint
|
||||
image: python:$(params.python-version)-slim
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
# Poetry가 사용된 경우 가상환경에서 실행
|
||||
if [ -f pyproject.toml ]; then
|
||||
poetry run pylint $(params.pylint-args) .
|
||||
else
|
||||
pylint $(params.pylint-args) .
|
||||
fi
|
||||
onError: continue # 린트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
|
||||
- name: check-results
|
||||
image: ubuntu
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
echo "Pylint execution completed."
|
||||
# Pylint 결과를 별도 파일로 저장하려면 run-lint에서 --output 옵션 추가 필요
|
@ -2,90 +2,24 @@ apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pypi
|
||||
namespace: gitops-ci
|
||||
labels:
|
||||
app.kubernetes.io/version: "0.2"
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.12.1"
|
||||
tekton.dev/categories: Publishing
|
||||
tekton.dev/tags: build
|
||||
tekton.dev/displayName: "pypi"
|
||||
tekton.dev/platforms: "linux/amd64"
|
||||
spec:
|
||||
description: >-
|
||||
This Task publishes Python packages to PyPI index using Twine utility module.
|
||||
|
||||
It provides build system independent uploads of source and binary distribution
|
||||
artifacts for both new and existing projects.
|
||||
|
||||
params:
|
||||
- name: TWINE_REPOSITORY_URL
|
||||
description: The repository (package index) to upload the package to.
|
||||
default: "https://upload.pypi.org/legacy/"
|
||||
type: string
|
||||
- name: SECRET_NAME
|
||||
description: Name of the secret containing the username & password used to upload the package.
|
||||
default: "pypi-secret"
|
||||
type: string
|
||||
- name: SECRET_USERNAME_KEY
|
||||
description: Name of the secret key containing the username.
|
||||
default: "username"
|
||||
type: string
|
||||
- name: SECRET_PASSWORD_KEY
|
||||
description: Name of the secret key containing the password.
|
||||
default: "password"
|
||||
type: string
|
||||
- name: PREBUILD_SCRIPT
|
||||
description: Script to execute prior to running setup.py.
|
||||
type: string
|
||||
default: ''
|
||||
- name: BUILDER_IMAGE
|
||||
description: Image to use for building the package
|
||||
type: string
|
||||
default: 'python:3.9'
|
||||
|
||||
- name: build-artifact-path
|
||||
type: string
|
||||
description: Path to the built artifact directory from python-build
|
||||
workspaces:
|
||||
- name: source
|
||||
|
||||
- name: source
|
||||
description: Workspace containing the built artifacts
|
||||
steps:
|
||||
- name: build-package
|
||||
image: $(params.BUILDER_IMAGE)
|
||||
workingDir: $(workspaces.source.path)
|
||||
script: |
|
||||
$(params.PREBUILD_SCRIPT)
|
||||
|
||||
python setup.py sdist bdist_wheel
|
||||
- name: upload-package
|
||||
image: quay.io/thoth-station/twine:v0.0.2 #tag: v0.0.2
|
||||
workingDir: $(workspaces.source.path)
|
||||
env:
|
||||
- name: TWINE_REPOSITORY_URL
|
||||
value: $(params.TWINE_REPOSITORY_URL)
|
||||
- name: TWINE_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: $(params.SECRET_NAME)
|
||||
key: $(params.SECRET_USERNAME_KEY)
|
||||
- name: TWINE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: $(params.SECRET_NAME)
|
||||
key: $(params.SECRET_PASSWORD_KEY)
|
||||
script: |
|
||||
twine upload --disable-progress-bar dist/*
|
||||
# Now write out all our results, stripping newlines.
|
||||
# sdist files are .tar.gz's
|
||||
sha256sum dist/*.tar.gz | tr -d '\n' | tee $(results.sdist_sha.path)
|
||||
# bdist files are .whls's
|
||||
sha256sum dist/*.whl | tr -d '\n' | tee $(results.bdist_sha.path)
|
||||
python setup.py --name | tr -d '\n' | tee $(results.package_name.path)
|
||||
python setup.py --version | tr -d '\n' | tee $(results.package_version.path)
|
||||
results:
|
||||
- name: sdist_sha
|
||||
description: sha256 (and filename) of the sdist package
|
||||
- name: bdist_sha
|
||||
description: sha256 (and filename) of the bdist package
|
||||
- name: package_name
|
||||
description: name of the uploaded package
|
||||
- name: package_version
|
||||
description: version of the uploaded package
|
||||
- name: upload-to-pypi
|
||||
image: python:$(params.python-version)-slim
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
pip install twine
|
||||
twine upload --username "__token__" --password "$PYPI_TOKEN" $(params.build-artifact-path)/*
|
||||
env:
|
||||
- name: PYPI_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pypi-credentials
|
||||
key: token
|
||||
|
@ -1,50 +1,68 @@
|
||||
apiVersion: tekton.dev/v1
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pytest
|
||||
namespace: gitops-ci
|
||||
labels:
|
||||
app.kubernetes.io/version: "0.2"
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.56.1"
|
||||
tekton.dev/displayName: "pytest"
|
||||
tekton.dev/categories: Developer Tools
|
||||
tekton.dev/tags: pytest
|
||||
tekton.dev/platforms: "linux/amd64"
|
||||
spec:
|
||||
description: >-
|
||||
These tasks make it possible to use pytest within your Tekton pipelines
|
||||
|
||||
pytest is a tool for testing configuration files using Open Policy Agent.
|
||||
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
description: Subdirectory within the repo where the tests are located
|
||||
default: ""
|
||||
- name: python-version
|
||||
type: string
|
||||
description: Python version to use (e.g., 3.9, 3.11)
|
||||
default: "3.9"
|
||||
workspaces:
|
||||
- name: source
|
||||
params:
|
||||
- name: BASE_IMAGE
|
||||
description: |
|
||||
The base image for the task.
|
||||
type: string
|
||||
default: python:3.13.2-bullseye
|
||||
- name: VERBOSE
|
||||
description: Log the commands that are executed during operation.
|
||||
type: string
|
||||
default: "true"
|
||||
|
||||
description: Workspace containing the cloned Git repository from git-clone-checkout
|
||||
steps:
|
||||
- name: pytest
|
||||
image: $(params.BASE_IMAGE)
|
||||
workingDir: $(workspaces.source.path)
|
||||
env:
|
||||
- name: PARAM_VERBOSE
|
||||
value: $(params.VERBOSE)
|
||||
- name: install-dependencies
|
||||
image: python:$(params.python-version)-slim
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
if [ "${PARAM_VERBOSE}" = "true" ] ; then
|
||||
set -x
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
pytest
|
||||
pip install --upgrade pip
|
||||
# Poetry가 있는 경우 설치 및 의존성 처리
|
||||
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
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
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 # 테스트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
|
||||
- name: check-results
|
||||
image: ubuntu
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
if [ -f pytest-results.xml ]; then
|
||||
echo "Test results generated: pytest-results.xml"
|
||||
cat pytest-results.xml
|
||||
else
|
||||
echo "No test results found."
|
||||
exit 1
|
||||
fi
|
@ -1,10 +0,0 @@
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: tekst
|
||||
spec:
|
||||
steps:
|
||||
- name: echo
|
||||
image: "alpine/git:2.47.2"
|
||||
script: |
|
||||
echo "Hello from Gitea Task!"
|
Loading…
x
Reference in New Issue
Block a user