# yaml-language-server: $schema=https://clew-resources.sbb-cloud.net/tekton-schema.json productName: esta-python pipelines: # This is the continuous build pipeline which runs on every commit on a feature branch or if triggered in the tekton-ui. - name: continuous triggerType: - GITEVENT - USER branchNamePrefixes: - feature - renovate build: {} tasks: - name: pre-commit-run # we are using a custom version of the esta-python build (see https://code.sbb.ch/projects/KD_ESTA/repos/esta-tekton-pipeline-templates/browse/tasks/esta-python-build.yaml) # here, because we can't, and don't want to build a package (using `poetry build`) from this repository. taskRef: esta-custom-exec params: RUN_IMAGE: esta.docker.bin.sbb.ch/esta/esta-tekton-pipeline-python-builderimage:latest SCRIPT: | apply-version python 3.12 eval "$(pyenv init -)" # Suppress fatal: detected dubious ownership in repository git config --global --add safe.directory $(workspaces.source.path) poetry config virtualenvs.in-project false --local poetry env use `pyenv version-name` poetry install # run code-quality check using pre-commit poetry run pre-commit run --all-files # This is the snapshot build pipeline which is triggered when pushing commits to main or if triggered in the tekton ui. - name: snapshot triggerType: - USER - GITEVENT branchNamePrefixes: - main build: {} tasks: - name: pre-commit-run # we are using a custom version of the esta-python build (see https://code.sbb.ch/projects/KD_ESTA/repos/esta-tekton-pipeline-templates/browse/tasks/esta-python-build.yaml) # here, because we can't, and don't want to build a package (using `poetry build`) from this repository. taskRef: esta-custom-exec params: RUN_IMAGE: esta.docker.bin.sbb.ch/esta/esta-tekton-pipeline-python-builderimage:latest SCRIPT: | apply-version python 3.12 eval "$(pyenv init -)" # Suppress fatal: detected dubious ownership in repository git config --global --add safe.directory $(workspaces.source.path) poetry config virtualenvs.in-project false --local poetry env use `pyenv version-name` poetry install # run code-quality check using pre-commit poetry run pre-commit run --all-files # The sync-to-esta-python task will render the copier template, create an automatic commit, # and force-push changes to esta-python's main branch. - name: sync-to-esta-python taskRef: esta-custom-exec params: RUN_IMAGE: esta.docker.bin.sbb.ch/esta/esta-tekton-pipeline-python-builderimage:latest SCRIPT: | poetry config virtualenvs.in-project false --local poetry env use `pyenv version-name` poetry install GIT_SSL_NO_VERIFY=true git clone https://code.sbb.ch/scm/kd_esta_blueprints/esta-python.git /tmp/esta-python # Suppress fatal: detected dubious ownership in repository git config --global --add safe.directory $(workspaces.source.path) (cd /tmp/esta-python && git rm -r --ignore-unmatch '*') poetry run copier copy --force \ --data project_name="ESTA Python" \ --data author_first_name="Your First Name" \ --data author_last_name="Your Last Name" \ --data bitbucket_organization=KD_ESTA_BLUEPRINTS \ --data pypi_repository="esta.pypi" \ --data docker_repository="esta.docker" \ --data helm_repository="esta.helm.local" \ . /tmp/esta-python/ cd /tmp/esta-python git add -A git config --global user.email "esta@sbb.ch" git config --global user.name "esta-build-clew" git commit --message "Automatic release commit." --allow-empty git push --force origin