API Documentation¶
bci_build
module¶
bci_build.package
module¶
- class bci_build.package.ApplicationStackContainer(name: 'str', os_version: 'OsVersion', pretty_name: 'str', package_name: 'str | None' = None, from_image: 'str | None' = '', from_target_image: 'str | None' = None, exclusive_arch: 'list[Arch] | None' = None, is_latest: 'bool' = False, is_singleton_image: 'bool' = False, entrypoint: 'list[str] | None' = None, entrypoint_user: 'str | None' = '', cmd: 'list[str] | None' = None, volumes: 'list[str] | None' = None, exposes_ports: 'list[NetworkPort] | None' = None, env: 'dict[str, str | int] | dict[str, str] | dict[str, int]' = <factory>, build_flavor: 'str | None' = None, crate: 'ContainerCrate' = None, replacements_via_service: 'list[Replacement]' = <factory>, extra_labels: 'dict[str, str]' = <factory>, package_list: 'list[str] | list[Package]' = <factory>, custom_end: 'str' = '', build_stage_custom_end: 'str | None' = None, buildcounter_synctag: 'str | None' = None, config_sh_script: 'str' = '', config_sh_interpreter: 'str' = '/bin/bash', oci_authors: 'str | None' = None, extra_files: 'dict[str, str | bytes] | dict[str, bytes] | dict[str, str]' = <factory>, additional_names: 'list[str]' = <factory>, custom_labelprefix_end: 'str' = '', custom_description: 'str' = '', build_recipe_type: 'BuildType | None' = None, kiwi_ignore_packages: 'list[str] | None' = None, license: 'str' = 'MIT', support_level: 'SupportLevel' = <SupportLevel.TECHPREVIEW: 'techpreview'>, supported_until: 'datetime.date | None' = None, no_recommends: 'bool' = True, logo_url: 'str' = '', _min_release_counter: 'int | None' = None, _publish_registry: 'Registry | None' = None, version: 'str | int' = '', tag_version: 'str | None' = None, stability_tag: 'str | None' = None, additional_versions: 'list[str]' = <factory>, version_in_uid: 'bool' = True)¶
-
- property image_type: ImageType¶
Define the value of the
com.suse.image-type
label.
- property title: str¶
The image title that is inserted into the
org.opencontainers.image.title
label.It is generated from
BaseContainerImage.pretty_name
as follows:"{distribution_base_name} BCI {self.pretty_name}"
, wheredistribution_base_name
is taken fromdistribution_base_name
.
- class bci_build.package.BaseContainerImage(name: str, os_version: ~bci_build.os_version.OsVersion, pretty_name: str, package_name: str | None = None, from_image: str | None = '', from_target_image: str | None = None, exclusive_arch: list[~bci_build.container_attributes.Arch] | None = None, is_latest: bool = False, is_singleton_image: bool = False, entrypoint: list[str] | None = None, entrypoint_user: str | None = '', cmd: list[str] | None = None, volumes: list[str] | None = None, exposes_ports: list[~bci_build.container_attributes.NetworkPort] | None = None, env: dict[str, str | int] | dict[str, str] | dict[str, int] = <factory>, build_flavor: str | None = None, crate: ~bci_build.containercrate.ContainerCrate = None, replacements_via_service: list[~bci_build.package.Replacement] = <factory>, extra_labels: dict[str, str] = <factory>, package_list: list[str] | list[~bci_build.package.Package] = <factory>, custom_end: str = '', build_stage_custom_end: str | None = None, buildcounter_synctag: str | None = None, config_sh_script: str = '', config_sh_interpreter: str = '/bin/bash', oci_authors: str | None = None, extra_files: dict[str, str | bytes] | dict[str, bytes] | dict[str, str] = <factory>, additional_names: list[str] = <factory>, custom_labelprefix_end: str = '', custom_description: str = '', build_recipe_type: ~bci_build.container_attributes.BuildType | None = None, kiwi_ignore_packages: list[str] | None = None, license: str = 'MIT', support_level: ~bci_build.container_attributes.SupportLevel = SupportLevel.TECHPREVIEW, supported_until: ~datetime.date | None = None, no_recommends: bool = True, logo_url: str = '', _min_release_counter: int | None = None, _publish_registry: ~bci_build.registry.Registry | None = None)¶
Base class for all Base Containers.
- additional_names: list[str]¶
Additional names under which this image should be published alongside
name
. These names are only inserted into thebuild_tags
- build_recipe_type: BuildType | None = None¶
Define whether this container image is built using docker or kiwi. If not set, then the build type will default to docker from SP4 onwards.
- build_stage_custom_end: str | None = None¶
This string is appended to the the build stage in a multistage build and can contain arbitrary instructions valid for a
Dockerfile
.
- abstract property build_tags: list[str]¶
All build tags that will be added to this image. Note that build tags are full paths on the registry and not just a tag.
- buildcounter_synctag: str | None = None¶
This string defines which build counter identifier should be used for this container. can be an arbitrary string is used to derive the checkin-counter. Defaults to the main package for packages with a flavor.
- config_sh_interpreter: str = '/bin/bash'¶
The interpreter of the
config.sh
script that is executed by kiwi during the image build. It defaults to/bin/bash
and has no effect forDockerfile
based builds. Warning: Using a different interpreter than/bin/bash
could lead to unpredictable results as kiwi’s internal functions are written for bash and not for a different shell.
- config_sh_script: str = ''¶
A script that is put into
config.sh
if a kiwi image is created. If aDockerfile
based build is used then this script is prependend with aDOCKERFILE_RUN
and added at the end of theDockerfile
. It must thus fit on a single line if you want to be able to build from a kiwi andDockerfile
at the same time!
- crate: ContainerCrate = None¶
create that this container is part of
- custom_description: str = ''¶
Provide a custom description instead of the automatically generated one
- custom_end: str = ''¶
This string is appended to the automatically generated dockerfile and can contain arbitrary instructions valid for a
Dockerfile
.Note
Setting both this property and
config_sh_script
is not possible and will result in an error.
- custom_labelprefix_end: str = ''¶
By default the containers get the labelprefix
{label_prefix}.bci.{self.name}
. If this value is not an empty string, then it is used instead of the name aftercom.suse.bci.
.
- property description: str¶
The description of this image which is inserted into the
org.opencontainers.image.description
label.If
BaseContainerImage.custom_description
is set, then that value is used. Custom descriptions can use str.format() substitution to expand the custom description with the following options:{pretty_name}
: the value of the pretty_name property{based_on_container}
: the standard “based on the $distro Base Container Image” suffix that descriptions have{podman_only}
: “This container is only supported with podman.”{privileged_only}
: “This container is only supported in privileged mode.”
Otherwise it reuses
BaseContainerImage.pretty_name
to generate a description.
- property dockerfile_custom_end: str¶
This part is appended at the end of the
Dockerfile
. It is either generated fromBaseContainerImage.custom_end
or by prependingRUN
in front ofBaseContainerImage.config_sh_script
. The later implies that the script in that variable fits on a single line or newlines are escaped, e.g. via ansi escapes.
- property dockerfile_from_target_ref: str¶
Provide the reference for the target image if multistage build is used, empty string otherwise.
- entrypoint: list[str] | None = None¶
An optional entrypoint for the image, it is omitted if empty or
None
If you provide a string, then it will be included in the container build recipe as is, i.e. it will be called via a shell as sh -c "MY_CMD". If your entrypoint must not be called through a shell, then pass the binary and its parameters as a list
- env: dict[str, str | int] | dict[str, str] | dict[str, int]¶
Extra environment variables to be set in the container
- property env_lines: str¶
Part of the
Dockerfile
that sets every environment variable defined inenv
.
- exclusive_arch: list[Arch] | None = None¶
Architectures of this image.
If supplied, then this image will be restricted to only build on the supplied architectures. By default, there is no restriction
- exposes_ports: list[NetworkPort] | None = None¶
An optional list of port exposes, it is omitted if empty or
None
.
- extra_files: dict[str, str | bytes] | dict[str, bytes] | dict[str, str]¶
Additional files that belong into this container-package. The key is the filename, the values are the file contents.
- property extra_label_lines: str¶
Lines for a
Dockerfile
to set the additional labels defined inBaseContainerImage.extra_labels
.
- property extra_label_xml_lines: str¶
XML Elements for a kiwi build description to set the additional labels defined in
BaseContainerImage.extra_labels
.
- from_image: str | None = ''¶
The container from which the build stage is running. On SLE15, this defaults to
suse/sle15:15.$SP
for Application Containers andbci/bci-base:15.$SP
for all other images. On openSUSE,opensuse/tumbleweed:latest
is used when an empty string is used.When from image is
None
, then this image will not be based on anything, i.e. theFROM
line is missing in theDockerfile
.
- from_target_image: str | None = None¶
The container that is used to install this image into. If this is not set, then only a single stage build is produced, otherwise a multistage build
- abstract property image_ref_name: str¶
The immutable reference for this target under which this image can be pulled. It is used to set the
org.opencontainers.image.ref.name
OCI annotation and defaults to{self.build_tags[0]}
.
- abstract property image_type: ImageType¶
Define the value of the
com.suse.image-type
label.
- property is_base_container_annotation_available: bool¶
return True if the obs-service-kiwi_metainfo_helper can provide base.name/digest annotations.
- is_singleton_image: bool = False¶
Determines whether only one version of this image will be published under the same registry path.
- property kiwi_additional_tags: str | None¶
Entry for the
additionaltags
attribute in the kiwi build description.This attribute is used by kiwi to add additional tags to the image under it’s primary name. This string contains a coma separated list of all build tags (except for the primary one) that have the same name as the image itself.
- kiwi_ignore_packages: list[str] | None = None¶
Define packages that should be ignored by kiwi in the creation of the final container image even if dependencies would otherwise pull them in.
- property kiwi_packages: str¶
The package list as xml elements that are inserted into a kiwi build description file.
- property labelprefix: str¶
The label prefix used to duplicate the labels. See https://en.opensuse.org/Building_derived_containers#Labels for further information.
This value is by default
com.suse.bci.{self.name}
for images of typeImageType.SLE_BCI
and`com.suse.application.{self.name}
for images of typeImageType.APPLICATION
unlessBaseContainerImage.custom_labelprefix_end
is set. In that caseself.name
is replaced bycustom_labelprefix_end
.
- license: str = 'MIT'¶
A license string to be placed in a comment at the top of the Dockerfile or kiwi build description file.
- logo_url: str = ''¶
URL to the logo of this container image. This value is added to the
io.artifacthub.package.logo-url
label if present
- name: str¶
Name of this image. It is used to generate the build tags, i.e. it defines under which name this image is published.
- no_recommends: bool = True¶
flag whether to not install recommended packages in the call to zypper in
Dockerfile
- oci_authors: str | None = None¶
The oci image author annotation for this image, defaults to SUSE/openSUSE
- abstract property oci_version: str¶
The “main” version label of this image.
It is added as the
org.opencontainers.image.version
label to the container image.
- os_version: OsVersion¶
The SLE service pack to which this package belongs
- property packages_to_delete: str¶
The list of packages joined that can be passed to zypper -n rm after an install`.
- abstract property pretty_reference: str¶
Returns the human readable registry URL to this image. It is intended to be used in the image documentation.
This url needn’t point to an exact version-release but can include just the major os version or the latest tag.
- property publish_registry: Registry¶
- abstract property reference: str¶
The primary URL via which this image can be pulled. It is used to set the
org.opensuse.reference
label and defaults to{self.registry}/{self.image_ref_name}
.
- property release_stage: ReleaseStage¶
This container images’ release stage.
It is
RELEASED
if the container images’ operating system version is in the listRELEASED_OS_VERSIONS
. Otherwise it isBETA
.
- replacements_via_service: list[Replacement]¶
Add any replacements via obs-service-replace_using_package_version that are used in this image into this list. See also
Replacement
- support_level: SupportLevel = 'techpreview'¶
The support level for this image, defaults to
SupportLevel.TECHPREVIEW
- property title: str¶
The image title that is inserted into the
org.opencontainers.image.title
label.It is generated from
BaseContainerImage.pretty_name
as follows:"{distribution_base_name} BCI {self.pretty_name}"
, wheredistribution_base_name
is taken fromdistribution_base_name
.
- bci_build.package.DOCKERFILE_RUN: str = 'RUN set -euo pipefail;'¶
a
RUN
command with a common set of bash flags applied to prevent errors from not being noticed
- class bci_build.package.DevelopmentContainer(name: 'str', os_version: 'OsVersion', pretty_name: 'str', package_name: 'str | None' = None, from_image: 'str | None' = '', from_target_image: 'str | None' = None, exclusive_arch: 'list[Arch] | None' = None, is_latest: 'bool' = False, is_singleton_image: 'bool' = False, entrypoint: 'list[str] | None' = None, entrypoint_user: 'str | None' = '', cmd: 'list[str] | None' = None, volumes: 'list[str] | None' = None, exposes_ports: 'list[NetworkPort] | None' = None, env: 'dict[str, str | int] | dict[str, str] | dict[str, int]' = <factory>, build_flavor: 'str | None' = None, crate: 'ContainerCrate' = None, replacements_via_service: 'list[Replacement]' = <factory>, extra_labels: 'dict[str, str]' = <factory>, package_list: 'list[str] | list[Package]' = <factory>, custom_end: 'str' = '', build_stage_custom_end: 'str | None' = None, buildcounter_synctag: 'str | None' = None, config_sh_script: 'str' = '', config_sh_interpreter: 'str' = '/bin/bash', oci_authors: 'str | None' = None, extra_files: 'dict[str, str | bytes] | dict[str, bytes] | dict[str, str]' = <factory>, additional_names: 'list[str]' = <factory>, custom_labelprefix_end: 'str' = '', custom_description: 'str' = '', build_recipe_type: 'BuildType | None' = None, kiwi_ignore_packages: 'list[str] | None' = None, license: 'str' = 'MIT', support_level: 'SupportLevel' = <SupportLevel.TECHPREVIEW: 'techpreview'>, supported_until: 'datetime.date | None' = None, no_recommends: 'bool' = True, logo_url: 'str' = '', _min_release_counter: 'int | None' = None, _publish_registry: 'Registry | None' = None, version: 'str | int' = '', tag_version: 'str | None' = None, stability_tag: 'str | None' = None, additional_versions: 'list[str]' = <factory>, version_in_uid: 'bool' = True)¶
-
- property build_name: str | None¶
Create a stable BuildName, either by using stability_tag or by falling back to _variant.
- property build_tags: list[str]¶
All build tags that will be added to this image. Note that build tags are full paths on the registry and not just a tag.
- property image_ref_name: str¶
The immutable reference for this target under which this image can be pulled. It is used to set the
org.opencontainers.image.ref.name
OCI annotation and defaults to{self.build_tags[0]}
.
- property image_type: ImageType¶
Define the value of the
com.suse.image-type
label.
- property oci_version: str¶
The “main” version label of this image.
It is added as the
org.opencontainers.image.version
label to the container image.
- property pretty_reference: str¶
Returns the human readable registry URL to this image. It is intended to be used in the image documentation.
This url needn’t point to an exact version-release but can include just the major os version or the latest tag.
- property reference: str¶
The primary URL via which this image can be pulled. It is used to set the
org.opensuse.reference
label and defaults to{self.registry}/{self.image_ref_name}
.
- tag_version: str | None = None¶
the floating tag version-$variant to add to the tags if set. used to determine a stable buildname
- bci_build.package.LOG_CLEAN: str = 'rm -rf {/target,}/var/log/{alternatives.log,lastlog,tallylog,zypper.log,zypp/history,YaST2}'¶
Remove various log files. While it is possible to just
rm -rf /var/log/*
, that would also remove some package owned directories (not %ghost)
- class bci_build.package.OsContainer(name: 'str', os_version: 'OsVersion', pretty_name: 'str', package_name: 'str | None' = None, from_image: 'str | None' = '', from_target_image: 'str | None' = None, exclusive_arch: 'list[Arch] | None' = None, is_latest: 'bool' = False, is_singleton_image: 'bool' = False, entrypoint: 'list[str] | None' = None, entrypoint_user: 'str | None' = '', cmd: 'list[str] | None' = None, volumes: 'list[str] | None' = None, exposes_ports: 'list[NetworkPort] | None' = None, env: 'dict[str, str | int] | dict[str, str] | dict[str, int]' = <factory>, build_flavor: 'str | None' = None, crate: 'ContainerCrate' = None, replacements_via_service: 'list[Replacement]' = <factory>, extra_labels: 'dict[str, str]' = <factory>, package_list: 'list[str] | list[Package]' = <factory>, custom_end: 'str' = '', build_stage_custom_end: 'str | None' = None, buildcounter_synctag: 'str | None' = None, config_sh_script: 'str' = '', config_sh_interpreter: 'str' = '/bin/bash', oci_authors: 'str | None' = None, extra_files: 'dict[str, str | bytes] | dict[str, bytes] | dict[str, str]' = <factory>, additional_names: 'list[str]' = <factory>, custom_labelprefix_end: 'str' = '', custom_description: 'str' = '', build_recipe_type: 'BuildType | None' = None, kiwi_ignore_packages: 'list[str] | None' = None, license: 'str' = 'MIT', support_level: 'SupportLevel' = <SupportLevel.TECHPREVIEW: 'techpreview'>, supported_until: 'datetime.date | None' = None, no_recommends: 'bool' = True, logo_url: 'str' = '', _min_release_counter: 'int | None' = None, _publish_registry: 'Registry | None' = None)¶
- property build_tags: list[str]¶
All build tags that will be added to this image. Note that build tags are full paths on the registry and not just a tag.
- property image_ref_name: str¶
The immutable reference for this target under which this image can be pulled. It is used to set the
org.opencontainers.image.ref.name
OCI annotation and defaults to{self.build_tags[0]}
.
- property image_type: ImageType¶
Define the value of the
com.suse.image-type
label.
- property oci_version: str¶
The “main” version label of this image.
It is added as the
org.opencontainers.image.version
label to the container image.
- property pretty_reference: str¶
Returns the human readable registry URL to this image. It is intended to be used in the image documentation.
This url needn’t point to an exact version-release but can include just the major os version or the latest tag.
- class bci_build.package.Package(name: str, pkg_type: PackageType = PackageType.IMAGE)¶
Representation of a package in a kiwi build, for Dockerfile based builds the
pkg_type
.- pkg_type: PackageType = 'image'¶
The package type. This parameter is only applicable for kiwi builds and defines into which
<packages>
element this package is inserted.
- class bci_build.package.ParseVersion(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
- MAJOR = 'major'¶
- MINOR = 'minor'¶
- OFFSET = 'offset'¶
- PATCH = 'patch'¶
- PATCH_UPDATE = 'patch_update'¶
- class bci_build.package.Replacement(regex_in_build_description: str, package_name: str, file_name: str | None = None, parse_version: None | ParseVersion = None)¶
Represents a replacement via the obs-service-replace_using_package_version.
- parse_version: None | ParseVersion = None¶
specify how the version should be formatted, see https://github.com/openSUSE/obs-service-replace_using_package_version#usage for further details
bci_build.package.versions
module¶
This module contains a simple mechanism to store the package versions for various code streams in a json file.
We need to know the version of certain packages in the distribution to be able to hardcode it in READMEs as we cannot let the build service create READMEs for us (this is a hard to work around limitation of OBS and the replace_using_package_version service).
Therefore we keep a single json file in the code with all packages and their version per code stream in the git repository of the following form:
{
"nginx": {
"Tumbleweed": "1.25.5",
"6": "1.21.5",
"5": "1.21.5"
}
}
The package versions are available via the function get_pkg_version()
.
The json file is updated via the function run_version_update()
. It can
also be called directly via poetry run update-versions and is also
run in the CI via .github/workflows/update-versions.yml
.
To add a new package to the versions json, add it’s package name and all code streams with a dummy version, e.g.:
{
"mariadb": {
"Tumbleweed": "",
"6": ""
}
}
Save the file and run the version update. update_versions()
will fetch
the current version for every code stream that is present in the dictionary.
For some packages we do not need to know the full version, to prevent pointless
automated churn. In such a case, add the additional key version_format
to a
package dictionary and set the value to the version format limit (e.g. major
or minor). The value must correspond to a enum value of
ParseVersion
. Applied to the above example, this
results in:
{
"nginx": {
"parse_version": "minor",
"Tumbleweed": "1.25",
"6": "1.21",
"5": "1.21"
}
}
- bci_build.package.versions.PACKAGE_VERSIONS_JSON_PATH = PosixPath('/__w/BCI-dockerfile-generator/BCI-dockerfile-generator/src/bci_build/package/package_versions.json')¶
Path to the json file where the package versions are stored
- bci_build.package.versions.format_version(ver: str, format: Literal[ParseVersion.MAJOR, ParseVersion.MINOR, ParseVersion.PATCH]) str ¶
- bci_build.package.versions.format_version(ver: str, format: Literal[ParseVersion.PATCH_UPDATE, ParseVersion.OFFSET]) NoReturn
Format the string ver to the supplied format, e.g.:
>>> format_version('1.2.3', ParseVersion.MAJOR) 1 >>> format_version('1.2.3', ParseVersion.MINOR) 1.2 >>> format_version('1.2', ParseVersion.PATCH) 1.2.0
- bci_build.package.versions.run_version_update() None ¶
Fetch the new package versions via
update_versions()
and write the result to the package versions json file.
bci_build.templates
module¶
This module contains the Jinja2 templates used to generate the build descriptions.
- bci_build.templates.DOCKERFILE_TEMPLATE = <Template memory:7fb55dd67380>¶
Jinja2 template used to generate
Dockerfile
- bci_build.templates.KIWI_TEMPLATE = <Template memory:7fb55db76ad0>¶
Jinja2 template used to generate
$pkg_name.kiwi
- bci_build.templates.SERVICE_TEMPLATE = <Template memory:7fb55db77110>¶
Jinja2 template used to generate
_service
.
dotnet
module¶
staging
module¶
staging.bot
module¶
- staging.bot.GIT_COMMITTER_EMAIL = 'bci-internal@suse.de'¶
email address of the bot account performing git actions
- staging.bot.GIT_COMMITTER_NAME = 'SUSE Update Bot'¶
full name of the bot account performing git actions
- staging.bot.OSC_PASSWORD_ENVVAR_NAME = 'OSC_PASSWORD'¶
environment variable from which the password of the bot’s user is taken
- staging.bot.OSC_USER_ENVVAR_NAME = 'OSC_USER'¶
environment variable name from which the osc username for the bot is read
- staging.bot.OS_VERSION_NEEDS_BASE_CONTAINER: tuple[OsVersion, ...] = ()¶
tuple of OsVersion that need the base container to be linked into the staging project this is usually only necessary during the early stages of a new SLE service pack when autobuild has not yet synced the binaries of the container images from IBS to OBS
- class staging.bot.ProjectConfig(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
- META = 'prj'¶
- PRJCONF = 'prjconf'¶
- class staging.bot.StagingBot(os_version: ~bci_build.os_version.OsVersion, branch_name: str = '', osc_username: str = '', repositories: list[str] = <factory>, _packages: list[str] | None = None, _osc_conf_file: str = '', _xdg_state_home_dir: ~tempfile.TemporaryDirectory | None = None, _run_cmd: ~obs_package_update.util.RunCommand = <factory>)¶
Bot that creates a staging project for the BCI images in the Open Build Service via the git scm bridge.
This bot creates a new worktree based on the “deployment branch” (see
deployment_branch_name
) and writes all build recipes into it. If this results in a change, then the changes are committed and pushed to github.A new staging project with the name
staging_project_name
is then created where all packages that were changed are inserted via the scm bridge.The bot needs to know the name of the user as whom it should act. The username has to be set via the attribute
osc_username
. This is unfortunately necessary, as osc does not provide a straightforward way how to get the default username…Additionally, the bot stores its current settings in an environment file (with the file name
DOTENV_FILE_NAME
), which can be either sourced directly in bash or used to create an instance of the bot viaStagingBot.from_env_file()
.The bot supports running all actions as a user that is not configured in osc’s configuration file. All you have to do is to set the environment variable
OSC_PASSWORD_ENVVAR_NAME
to the password of the user that is going to be used. Thesetup()
function will then create a temporary configuration file for osc and also setXDG_STATE_HOME
to a temporary directory so that your local osccookiejar
is not modified. Both files are cleaned up viateardown()
- DOTENV_FILE_NAME: ClassVar[str] = 'test-build.env'¶
filename of the environment file used to store the bot’s settings
- MAX_WAIT_TIME_SEC: ClassVar[int] = 21600¶
Maximum time to wait for a build to finish. github actions will run for 6h at most, no point in waiting longer
- property bcis: Generator[BaseContainerImage, None, None]¶
Generator for creating an iterable yielding all
BaseContainerImage
that are in the bot’s staging project.
- branch_name: str = ''¶
Name of the branch to which the changes are pushed. If none is provided, then
deployment_branch_name
is used with a few random ASCII characters appended.
- async configure_devel_bci_project() None ¶
Adjust to project meta of the devel project on OBS to match the template generated via
staging.project_setup.generate_meta()
. Additionally set the project meta from the file_config
in the deployment branch, set theOSRT:Config
attribute for pkglistgen to function as expected and set theOBS:RejectRequests
attribute to a warning that SRs do not work.
- container_urls_html() str ¶
Pretty print the output of
StagingBot.fetch_container_urls()
wrapped in a<details></details>
HTML element for GitHub.
- property deployment_branch_name: str¶
The name of the branch for this
os_version
where the build recipes are checked out by default.
- async fetch_build_results() list[RepositoryBuildResult] ¶
Retrieves the current build results of the staging project.
- fetch_container_urls() list[str] ¶
Fetch the full urls to all published containers in the staging project including their most relevant tag (either
latest
or the first tag). Querying a staging project without published images results in aRuntimeError
.
- async find_missing_packages_on_obs() list[str] ¶
Returns the name of all packages that are currently in a git deployment branch, but have not been setup on OBS.
- async force_rebuild() str ¶
Deletes all binaries of the project on OBS and force rebuilds everything.
- async static from_env_file() StagingBot ¶
Read the last saved settings from the environment file (
DOTENV_FILE_NAME
) in the current working directory and create aStagingBot
from them.
- static from_github_comment(comment_text: str, osc_username: str) StagingBot ¶
- get_packages_without_changelog_addition(base_ref: str, change_ref: str) list[str] ¶
Runs a simple heuristic whether a packages’ changelog has had an addition between
base_ref
andchange_ref
.- Returns:
The list of packages without a commit in the range
base_ref
andchange_ref
that added at least four lines (= minimum length of a one line osc vc entry).
- async link_base_container_to_staging() None ¶
Links the base container for this os into
StagingBot.staging_project_name
. This function does nothing if the currentos_version
is not in the listOS_VERSION_NEEDS_BASE_CONTAINER
.
- property obs_workflows_yml: str¶
The contents of
.obs/workflows.yml
for branching each package from the continuous rebuild project (continuous_rebuild_project_name
) to the staging sub-project.
- os_version: OsVersion¶
The operating system for which this instance has been created
- osc_username: str = ''¶
username of the user that will be used to perform the actions by the bot.
This value must be provided, otherwise the post initialization function raises an exception.
- property package_names: list[str] | None¶
Name of the packages in the staging project or
None
if the staging project has not been setup yet.
- async remote_cleanup(branches: bool = True, obs_project: bool = True) None ¶
Deletes the branch with the test commit locally and on the remote and removes the staging project.
All performed actions are permitted to fail without raising an exception to ensure that a partially setup test run is cleaned up as much as possible.
- Parameters:
branches – if
True
, removes the branch locally and on the remote (defaults toTrue
)obs_project – if
True
, removes the staging project on OBS (defaults toTrue
)
- property staging_project_name: str¶
The name of the staging project on OBS.
It is constructed as follows:
home:$OSC_USER:BCI:Staging:$OS_VER:$BRANCH
where:OSC_USER
:osc_username
OS_VER
:os_version
BRANCH
:branch_name
- async teardown() None ¶
Local cleanup after the bot (nothing on OBS is removed and the git repository itself is left untouched).
- async wait_for_build_to_finish(timeout_sec: int | None = None) list[RepositoryBuildResult] ¶
Blocks until all builds in the staging project have finished and the repositories are no longer dirty.
- Parameters:
timeout_sec – Total time in seconds to block. Defaults to
MAX_WAIT_TIME_SEC
- Raises:
asyncio.TimeoutError – when build takes longer than the specified timeout
RuntimeError – when the staging project has no build results (this is most likely an issue with OBS)
- Returns:
The last state of all packages in the staging project after the builds finished
- async write_all_build_recipes_to_branch(commit_msg: str = '') str | None ¶
Creates a worktree for the branch based on the deployment branch of this
os_version
, writes all image build recipes into it, commits and then pushes the changes. Afterwards the worktree is removed.- Returns:
The hash of the commit including all changes by the writing the build recipes into the worktree. If no changes were made, then
None
is returned.
- async write_all_image_build_recipes(destination_prj_folder: str) list[str] ¶
Writes all build recipes into the folder
destination_prj_folder
and returns a list of files that were written.- Returns:
A list of all files that were written to
destination_prj_folder
. The files are listed relative todestination_prj_folder
and don’t contain any leading path components.
- async write_cr_project_config() None ¶
Send the configuration of the continuous rebuild project to OBS.
This will create the project if it did not exist already. If it exists, then its configuration (=
meta
in OBS jargon) will be updated.
- async write_env_file()¶
- async write_pkg_configs(packages: Iterable[BaseContainerImage], git_branch_name: str, target_obs_project: str) None ¶
Write all package configurations (=
_meta
) for every package inpackages
to the project target_obs_project so that the package is fetched via the scm bridge from the branch git_branch_name.- Parameters:
packages – the BCI packages that should be added
git_branch_name – the name of the git branch from which the sources will be retrieved
target_obs_project – name of the project on OBS to which the packages will be added
staging.build_result
module¶
- class staging.build_result.PackageBuildResult(name: str, code: PackageStatusCode, detail_message: str | None = None)¶
The build result of a single package.
- code: PackageStatusCode¶
build status of the package
- class staging.build_result.PackageStatusCode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Possible package states
- BLOCKED = 'blocked'¶
- BROKEN = 'broken'¶
- BUILDING = 'building'¶
- DISABLED = 'disabled'¶
- EXCLUDED = 'excluded'¶
- FAILED = 'failed'¶
- FINISHED = 'finished'¶
- SCHEDULED = 'scheduled'¶
- SIGNING = 'signing'¶
- SUCCEEDED = 'succeeded'¶
- UNRESOLVABLE = 'unresolvable'¶
- pretty_print()¶
Returns the value of this enum with an emoji visualizing the status.
- class staging.build_result.RepositoryBuildResult(project: str, repository: str, arch: ~bci_build.container_attributes.Arch, code: str, state: str, packages: list[~staging.build_result.PackageBuildResult] = <factory>, dirty: bool = False)¶
The build results of a repository for a specific architecture.
- arch: Arch¶
repository architecture
- dirty: bool = False¶
if a repository is dirty, then it is still processing build jobs and has not been fully published yet
- static from_resultlist(obs_api_reply: str) list[RepositoryBuildResult] ¶
Creates a list of :py:class`RepositoryBuildResult` from the xml API reply received from OBS via osc results --xml.
- packages: list[PackageBuildResult]¶
state of all packages in this repository & arch
- staging.build_result.is_build_failed(build_results: list[RepositoryBuildResult]) bool ¶
Returns
True
if any package in the list of build results is either unresolvable or failed to build. The repositories must not be dirty, otherwise aValueError
is raised.
- staging.build_result.render_as_markdown(results: list[RepositoryBuildResult], base_url: str = 'https://build.opensuse.org/') str ¶
staging.project_setup
module¶
- class staging.project_setup.ProjectType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
- CR = 2¶
- DEVEL = 1¶
- STAGING = 3¶