curved-television-6568
12/15/2021, 5:23 PMcurved-television-6568
12/15/2021, 5:25 PMcurved-television-6568
12/15/2021, 5:26 PMBUILD
files…
def manual_release(
version: str,
*,
filename: str | None = None,
instructions: str | None = None,
append_build_number: bool = True,
append_build_number_sep: str | None = None,
**kwargs,
):
if append_build_number:
if append_build_number_sep is None:
append_build_number_sep = "-" if "-" not in version else "b_"
version += append_build_number_sep + "${BUILD_NUMBER}"
target(
tags=[
f"{tag}={value}"
for tag, value in [
("filename", filename),
("instructions", instructions),
("version", version),
]
if value is not None
],
**kwargs,
)
this simply turns it into a generic target
with some tags on it.curved-television-6568
12/15/2021, 5:27 PM<app name>/BUILD
files like:
manual_release(
"1.0.4",
filename="deliverable-file",
instructions=r"""
Some instructions here...
""",
)
curved-television-6568
12/15/2021, 5:28 PM./pants --changed-since
and linting and various checks, boils down to this part, fishing out the relevant tagged target data:
./pants --spec-files=releases.spec peek --exclude-defaults > release.json
echo -n "+ Release: "
jq -r 'include "utils"; .[]|publish_release' release.json | envsubst | tee releases_to_publish.txt
echo -n "+ Filename: "
jq -r 'include "utils"; .[]|translate_target|.attrs.filename' release.json | tee filename.txt
echo -n "+ Instructions: "
jq -r 'include "utils"; .[]|translate_target|.attrs.instructions' release.json | tee instructions.txt
echo filename.txt,instructions.txt > release_infos_to_publish.txt
Along with some jq
magic 😉curved-television-6568
12/15/2021, 5:29 PMcurved-television-6568
12/15/2021, 5:30 PM.txt
files are then picked up by later stages in the build pipeline for processing…)busy-vase-39202
12/15/2021, 5:30 PMhappy-kitchen-89482
12/15/2021, 6:02 PMhappy-kitchen-89482
12/15/2021, 6:03 PMcurved-television-6568
12/15/2021, 6:04 PMcurved-television-6568
12/15/2021, 6:06 PM./pants compile-metadata
into a bunch of .yaml
files in the project. This to eliminate the need for manually maintaining the yaml data in favour of putting the data in BUILD file targets with all the benefits that comes with that.curved-television-6568
12/15/2021, 6:08 PM$ cat svs_manifest.yaml _meta/build.yaml _meta/imports.yaml
# DO NOT EDIT: This file was generated by `./pants compile-metadata` at 2021-12-13T14:21:19.678170.
build: _meta/build.yaml
import.all: _meta/imports.yaml
app.svs-pants-plugin:
name: svs-pants-plugin
application_meta:
account: 0
name: svs-pants-plugin
release_type: library
language: python
# DO NOT EDIT: This file was generated by `./pants compile-metadata` at 2021-12-13T14:21:19.676371.
# Source: _meta/BUILD `svs_build` name='build'
name: pants-plugin
template: docker-lib
version: semantic
environment:
PYTHON_RELEASE: '3.8'
PYTHON_PATCH: '0'
# DO NOT EDIT: This file was generated by `./pants compile-metadata` at 2021-12-13T14:21:19.677324.
# Source: _meta/BUILD `svs_import_meta` name='imports'
repo: devops/meta-defaults
branch: fo_deployment
happy-kitchen-89482
12/15/2021, 8:16 PMcurved-television-6568
12/15/2021, 9:20 PMWhat are “all of the benefits”?Compared to untyped (no schema) yaml files, the benefits are: • Type validation • Required field/values • Online help (on the CLI) • DRY-ness (dependencies allow generating a single value in multiple places in the output data) • Stable syntax (yaml being indentation sensitive, it is a common source of error, getting nested structures at the wrong level) • Lint/Check locally (when authoring the yaml files, besides using a yaml linter, any mistakes wouldn’t be reported until after push, with poor feedback to the developer.) • As we now have a “spec”, generating to a target format, it allows us to move forward easier simply adjusting how we generate the end result. • I’m sure there’s more, but this concept is just a few days old, so haven’t had the time to see all of the fruitions yet.. but none if these bullets are a minor thing! 😄
happy-kitchen-89482
12/15/2021, 10:28 PM