Skip to content

Commit

Permalink
twoliter: allow partial lockfile validation in some scenarios
Browse files Browse the repository at this point in the history
In some CI scenarios, it's useful to drop previously-built variant
images into a Twoliter project's build directory and use Twoliter to
publish those variant images.

In these cases, Kit dependencies are not necessary, and it can be useful
to avoid resolving them and comparing them against Twoliter.lock.

This change allows skipping Kit lockfile verification only when
executing certain `twoliter make` targets.
  • Loading branch information
cbgbt committed Sep 6, 2024
1 parent c451e4a commit 87624fe
Show file tree
Hide file tree
Showing 9 changed files with 718 additions and 163 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ sha2 = "0.10"
shell-words = "1"
simplelog = "0.12"
snafu = "0.8"
strum = "0.26"
tabled = "0.10"
tar = "0.4"
tempfile = "3"
Expand Down
1 change: 1 addition & 0 deletions twoliter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ semver = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
sha2.workspace = true
strum = { workspace = true, features = ["derive"] }
tar.workspace = true
tempfile.workspace = true
tokio = { workspace = true, features = ["fs", "macros", "process", "rt-multi-thread"] }
Expand Down
24 changes: 20 additions & 4 deletions twoliter/embedded/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ dependencies = ["setup-build"]
script_runner = "bash"
script = [
'''
if [ ! -s "${BUILDSYS_EXTERNAL_KITS_DIR}/.sdk-verified" ]; then
echo "Twoliter could not validate '${TLPRIVATE_SDK_IMAGE}', refusing to continue" >&2
exit 1
fi
if ! docker image inspect "${TLPRIVATE_SDK_IMAGE}" >/dev/null 2>&1 ; then
if ! docker pull "${TLPRIVATE_SDK_IMAGE}" ; then
echo "failed to pull '${TLPRIVATE_SDK_IMAGE}'" >&2
Expand Down Expand Up @@ -736,6 +740,18 @@ docker run --rm \
'''
]

[tasks.validate-kits]
dependencies = ["cargo-metadata"]
script_runner = "bash"
script = [
'''
if [ ! -s "${BUILDSYS_EXTERNAL_KITS_DIR}/.kits-verified" ]; then
echo "Twoliter could not validate external kits, refusing to continue" >&2
exit 1
fi
'''
]

# Reads the project's workspace Cargo dependency graph to a json file. Needed by buildsys when
# building packages, kits and variants.
[tasks.cargo-metadata]
Expand Down Expand Up @@ -772,7 +788,7 @@ cargo metadata \

# Builds a package including its build-time and runtime dependency packages.
[tasks.build-package]
dependencies = ["check-cargo-version", "fetch", "publish-setup", "cargo-metadata"]
dependencies = ["check-cargo-version", "fetch", "publish-setup", "validate-kits"]
script_runner = "bash"
script = [
'''
Expand Down Expand Up @@ -817,7 +833,7 @@ cargo build \

# Builds a kit including its dependency packages.
[tasks.build-kit]
dependencies = ["check-cargo-version", "fetch", "publish-setup", "cargo-metadata"]
dependencies = ["check-cargo-version", "fetch", "publish-setup", "validate-kits"]
script_runner = "bash"
script = [
'''
Expand All @@ -841,7 +857,7 @@ cargo build \
]

[tasks.build-variant]
dependencies = ["fetch", "build-sbkeys", "publish-setup", "cargo-metadata"]
dependencies = ["fetch", "build-sbkeys", "publish-setup", "validate-kits"]
script = [
'''
export PATH="${TWOLITER_TOOLS_DIR}:${PATH}"
Expand Down Expand Up @@ -892,7 +908,7 @@ ln -snf "${BUILDSYS_VERSION_FULL}" "${OUTPUT_LOGS_DIR}/latest"
]

[tasks.build-all]
dependencies = ["fetch", "build-sbkeys", "publish-setup", "cargo-metadata"]
dependencies = ["fetch", "build-sbkeys", "publish-setup", "validate-kits"]
script = [
'''
export PATH="${TWOLITER_TOOLS_DIR}:${PATH}"
Expand Down
Loading

0 comments on commit 87624fe

Please sign in to comment.