-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the initial contribution to the Open-Source Open-Component-Model Delivery-Service project. The following SAP Developers contributed to this project until this initial contribution was published as open source: 535 Philipp Heil 189 Christian Cwienk 183 Jonas Brand 90 Johannes Krayl 34 Andreas Burger 7 Philipp Heil 1 Fynn Borrmeister 1 Tim Schrodi 1 Vladimir Nachev It is derived from the historical, SAP-internal delivery-service repository at commit 76b0af87963ec6c676d59307019a682b865dfe9a
- Loading branch information
0 parents
commit 023fe1d
Showing
131 changed files
with
34,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
repo_dir="$(readlink -f "$(dirname "$0")/..")" | ||
out_dir="$(readlink -f "${repo_dir}/../${PACKAGES_PATH:-}/dist")" | ||
mkdir "${out_dir}" | ||
|
||
cd $repo_dir | ||
|
||
# install build-only dependencies (no need to include in image) | ||
pip3 install --upgrade pip wheel setuptools semver | ||
|
||
# build into "${repo_dir}/dist" | ||
python3 "${repo_dir}/setup.utils.py" sdist bdist_wheel | ||
python3 "${repo_dir}/setup.service.py" sdist bdist_wheel | ||
python3 "${repo_dir}/setup.extensions.py" sdist bdist_wheel | ||
|
||
# keep for subsequent docker build | ||
cp dist/* ${out_dir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import dataclasses | ||
import os | ||
import yaml | ||
|
||
import ci.util | ||
import gci.componentmodel | ||
|
||
|
||
component_descriptor_base_path = os.path.abspath(ci.util.check_env('BASE_DEFINITION_PATH')) | ||
component_descriptor_path = os.path.abspath(ci.util.check_env('COMPONENT_DESCRIPTOR_PATH')) | ||
|
||
own_dir = os.path.abspath(os.path.dirname(__file__)) | ||
repo_dir = os.path.abspath(os.path.join(own_dir, os.pardir)) | ||
CC_UTILS_VERSIONFILE = os.path.join(repo_dir, 'CC_UTILS_VERSION') | ||
|
||
|
||
def parse_component_descriptor(): | ||
component_descriptor = gci.componentmodel.ComponentDescriptor.from_dict( | ||
ci.util.parse_yaml_file(component_descriptor_base_path) | ||
) | ||
return component_descriptor | ||
|
||
|
||
def cc_utils_version(): | ||
with open(CC_UTILS_VERSIONFILE) as version_file: | ||
cc_utils_version = version_file.read().strip() | ||
return cc_utils_version | ||
|
||
|
||
def add_dependency_to_cc_utils(component: gci.componentmodel.Component): | ||
component.componentReferences.append( | ||
gci.componentmodel.ComponentReference( | ||
name='cc-utils', | ||
componentName='github.com/gardener/cc-utils', | ||
version=cc_utils_version(), | ||
labels=[], | ||
) | ||
) | ||
|
||
|
||
def main(): | ||
component_descriptor = parse_component_descriptor() | ||
component = component_descriptor.component | ||
|
||
add_dependency_to_cc_utils(component) | ||
|
||
with open(component_descriptor_path, 'w') as f: | ||
yaml.dump( | ||
data=dataclasses.asdict(component_descriptor), | ||
Dumper=gci.componentmodel.EnumValueYamlDumper, | ||
stream=f, | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# usage: $1: <src-dir> | ||
|
||
src_dir="${1:-"$(readlink -f "$(dirname "${0}")/..")"}" | ||
|
||
echo 'Running flake8 for all python modules..' | ||
error=0 | ||
|
||
export PYTHONPATH="${src_dir}" | ||
|
||
echo 'running pylama for all modules (errors only)' | ||
( | ||
pushd "${src_dir}" | ||
echo "using pylama cfg at ${src_dir}/pylama.ini" | ||
set -x | ||
if pylama -iW,R,C -lpylint --options "${src_dir}/pylama.ini" "${src_dir}"; then | ||
echo 'pylama succeeded' | ||
else | ||
((error|=1)) | ||
fi | ||
|
||
if "${src_dir}/.ci/lint-flake8"; then | ||
echo 'pyflake8 succeeded' | ||
else | ||
((error|=1)) | ||
fi | ||
|
||
if [ $error -eq 0 ]; then | ||
exit 0 | ||
elif [ $error -gt 0 ]; then | ||
exit 1 | ||
fi | ||
popd | ||
) | ||
|
||
exit $? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# usage: $1: <src-dir> | ||
|
||
src_dir="${1:-"$(readlink -f "$(dirname "${0}")/..")"}" | ||
|
||
error=0 | ||
|
||
# flake8 / the linter it instruments cannot handle our special type-hints (CliHint) | ||
if flake8 --max-line-length=101 --select=E101,E117,E201,E202,E203,E225,E251,E3,E4,E5,E703,E9,W1,W2,W3,W6,F --count --format=pylint --ignore=F722,F821 ${src_dir}; then | ||
echo 'flake8 succeeded' | ||
else | ||
echo 'flake8 found errors (see above)' | ||
((error|=1)) | ||
fi | ||
|
||
if [ $error -eq 0 ]; then | ||
exit 0 | ||
elif [ $error -gt 0 ]; then | ||
exit 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
# usage: $1: <src-dir> | ||
|
||
src_dir="${1:-"$(readlink -f "$(dirname "${0}")/..")"}" | ||
|
||
touched_files=$(\ | ||
GIT_DIR="${src_dir}/.git" \ | ||
git show --name-only --oneline | tail -n-1 | grep -q -e '.*\.py$' | ||
) | ||
set -e | ||
|
||
if [ -z "${touched_files}" ]; then | ||
echo 'no python files were touched - early-exiting' | ||
exit 0 | ||
fi | ||
|
||
echo 'Running pylint for touched files from head-commit:' | ||
echo '' | ||
echo "${touched_files}" | ||
|
||
( | ||
pushd "${src_dir}" | ||
set -e | ||
pylint \ | ||
--errors-only \ | ||
${touched_files} | ||
popd | ||
) | ||
|
||
exit $? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
delivery-service: | ||
inherit: | ||
check-steps: &check-steps | ||
steps: &steps | ||
smoke_test: | ||
image: europe-docker.pkg.dev/gardener-project/releases/delivery-gear/delivery-service:latest | ||
execute: ../smoke_test.py | ||
lint: | ||
image: europe-docker.pkg.dev/gardener-project/releases/delivery-gear/delivery-service:latest | ||
execute: lint | ||
test: | ||
image: europe-docker.pkg.dev/gardener-project/releases/delivery-gear/delivery-service:latest | ||
execute: test | ||
|
||
base_definition: | ||
repo: | ||
disable_ci_skip: True | ||
traits: | ||
version: ~ | ||
component_descriptor: | ||
component_name: ocm.software/delivery-gear/delivery-service | ||
ocm_repository: europe-docker.pkg.dev/gardener-project/releases | ||
ocm_repository_mappings: | ||
- repository: europe-docker.pkg.dev/gardener-project/releases | ||
prefix: '' | ||
options: | ||
public_build_logs: true | ||
|
||
jobs: | ||
pull-request: | ||
<<: *check-steps | ||
traits: | ||
pull-request: ~ | ||
component_descriptor: | ||
ocm_repository: europe-docker.pkg.dev/gardener-project/snapshots | ||
|
||
upon-cicd-outbound-release: | ||
traits: | ||
update_component_deps: | ||
merge_policy: manual | ||
cronjob: | ||
interval: 5m | ||
component_descriptor: | ||
ocm_repository: europe-docker.pkg.dev/gardener-project/snapshots | ||
|
||
automatic-release: | ||
steps: | ||
trigger-release: | ||
execute: trigger_release.py | ||
inputs: | ||
component_descriptor_dir: component_descriptor_dir | ||
vars: | ||
RELEASE_JOB_NAME: pipeline.variant("manual-release").job_name() | ||
PIPELINE_NAME: pipeline_descriptor.get("name") | ||
depends: | ||
- component_descriptor | ||
traits: | ||
notifications: | ||
cicd-team: | ||
on_error: | ||
triggering_policy: only_first | ||
recipients: | ||
- email_addresses: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
|
||
manual-release: | ||
steps: | ||
<<: *steps | ||
build_python_packages: | ||
output_dir: packages | ||
traits: | ||
version: | ||
preprocess: finalize | ||
inject_effective_version: True | ||
publish: | ||
dockerimages: | ||
delivery-service: | ||
image: europe-docker.pkg.dev/gardener-project/releases/delivery-gear/delivery-service | ||
dockerfile: Dockerfile.service | ||
tag_as_latest: True | ||
inputs: | ||
steps: | ||
build_python_packages: ~ | ||
delivery-gear-extensions: | ||
image: europe-docker.pkg.dev/gardener-project/releases/delivery-gear/delivery-gear-extensions | ||
dockerfile: Dockerfile.extensions | ||
tag_as_latest: True | ||
inputs: | ||
steps: | ||
build_python_packages: ~ | ||
release: | ||
nextversion: bump_minor | ||
release_notes_policy: disabled | ||
release_commit_publishing_policy: tag_and_merge_back | ||
|
||
head-update: | ||
<<: *check-steps | ||
traits: | ||
version: ~ | ||
notifications: | ||
default: | ||
on_error: | ||
triggering_policy: only_first | ||
component_descriptor: | ||
ocm_repository: europe-docker.pkg.dev/gardener-project/snapshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
|
||
import ci.util | ||
|
||
|
||
repo_dir = os.path.abspath(ci.util.check_env('MAIN_REPO_DIR')) | ||
CC_UTILS_VERSIONFILE = os.path.join(repo_dir, 'CC_UTILS_VERSION') | ||
REQUIREMENTS_FILE = os.path.join(repo_dir, 'requirements.utils.txt') | ||
|
||
dependency_name = ci.util.check_env('DEPENDENCY_NAME') | ||
dependency_version = ci.util.check_env('DEPENDENCY_VERSION') | ||
|
||
|
||
def write_component_version_to_file(file_path: str): | ||
with open(file_path, 'w') as version_file: | ||
version_file.write(dependency_version.strip()) | ||
|
||
|
||
def add_package_version( | ||
package_name: str, | ||
package_version: str, | ||
packages: list[str], | ||
): | ||
return [ | ||
f'{package_name}=={package_version}\n' if package.startswith(package_name) else package | ||
for package in packages | ||
] | ||
|
||
|
||
def write_package_version_to_requirements_file(package_name: str, file_path: str): | ||
with open(file_path, 'r') as requirements_file: | ||
lines = requirements_file.readlines() | ||
|
||
lines = add_package_version( | ||
package_name=package_name, | ||
package_version=dependency_version, | ||
packages=lines, | ||
) | ||
|
||
with open(file_path, 'w') as requirements_file: | ||
requirements_file.writelines(lines) | ||
|
||
|
||
def main(): | ||
if dependency_name == 'github.com/gardener/cc-utils': | ||
package_name = 'gardener-cicd-dso' | ||
|
||
write_component_version_to_file(CC_UTILS_VERSIONFILE) | ||
write_package_version_to_requirements_file(package_name, REQUIREMENTS_FILE) | ||
else: | ||
raise RuntimeError(f"Don't know how to upgrade dependency: {dependency_name}") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash -e | ||
|
||
set -e | ||
|
||
if ! which pytest &>/dev/null; then | ||
echo "pytest is required (install with pip(3) install pytest)" | ||
exit 1 | ||
fi | ||
|
||
if ! which pip3 &> /dev/null; then | ||
echo "pip3 is required" | ||
exit 1 | ||
fi | ||
|
||
src_dir="${1:-"$(readlink -f "$(dirname "${0}")/..")"}" | ||
|
||
pip3 install pytest==8.0.0 # pytest 8.1.0 uses a deprecated function which raises an error | ||
pip3 install -r "${src_dir}/requirements.utils.txt" | ||
pip3 install -r "${src_dir}/requirements.service.txt" | ||
pip3 install -r "${src_dir}/requirements.extensions.txt" | ||
|
||
|
||
if PYTHONPATH="${src_dir}:${PYTHONPATH:-}" pytest "${src_dir}" "${@}"; then | ||
echo 'Unittest executions succeeded' | ||
exit 0 | ||
else | ||
echo 'Errors were found whilst executing unittests (see above)' | ||
exit 1 | ||
fi |
Oops, something went wrong.