Skip to content

Commit

Permalink
Skip image building for docs changes
Browse files Browse the repository at this point in the history
Make `IMG_SFX` mandatory when manually building/debugging images

Also mark image-building tasks as 'stateful'.  Ref:
https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks

This avoids task-cancellation (due to new code push) interrupting
packer and possibly causing orphaned VMs, and disk images.

Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Sep 8, 2020
1 parent 6a38b72 commit 183abc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ timeout_in: 60m
task:
name: "Validate"
alias: "validate"
skip: "changesInclude('**.md', 'LICENSE')"
timeout_in: 5m
container: &ci_container
# Ref: https://cirrus-ci.org/guide/docker-builder-vm/#dockerfile-as-a-ci-environment
Expand All @@ -38,10 +39,12 @@ task:
task:
name: "Image-builder image"
alias: "image_builder"
skip: "changesInclude('**.md', 'LICENSE')"
depends_on:
- validate
# Packer needs time to clean up partially created VM images
auto_cancellation: $CI != "true"
stateful: true
timeout_in: 30m
container:
dockerfile: "image_builder/Containerfile"
Expand All @@ -55,6 +58,7 @@ task:

task:
alias: "podman_containers"
skip: "changesInclude('**.md', 'LICENSE')"
depends_on:
- image_builder
timeout_in: 30m
Expand Down Expand Up @@ -97,10 +101,12 @@ task:

task:
alias: "base_images"
skip: "changesInclude('**.md', 'LICENSE')"
depends_on:
- image_builder
# Packer needs time to clean up partially created VM images
auto_cancellation: $CI != "true"
stateful: true
timeout_in: 30m
# Cannot use a container for this task, virt required for fedora image conversion
gce_instance:
Expand Down Expand Up @@ -130,10 +136,12 @@ task:

task:
alias: "cache_images"
skip: "changesInclude('**.md', 'LICENSE')"
depends_on:
- base_images
# Packer needs time to clean up partially created VM images
auto_cancellation: $CI != "true"
stateful: true
timeout_in: 40m
container:
dockerfile: "image_builder/Containerfile"
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ image_builder/manifest.json: image_builder/gce.json image_builder/setup.sh lib.s
# from inside the debugging container.
.PHONY: image_builder_debug
image_builder_debug: $(_TEMPDIR)/image_builder_debug.tar ## Build and enter container for local development/debugging of targets requiring packer + virtualization
$(eval override _IMG_SFX := $(call err_if_empty,IMG_SFX))
$(eval override _GAC_FILEPATH := $(call err_if_empty,GAC_FILEPATH))
/usr/bin/podman run -it --rm \
--security-opt label=disable -v $$HOME:$$HOME -w $$PWD \
-v $(_TEMPDIR):$(_TEMPDIR):Z -v $(_GAC_FILEPATH):$(_GAC_FILEPATH):Z \
-v /dev/kvm:/dev/kvm \
-e PACKER_INSTALL_DIR=/usr/local/bin \
-e IMG_SFX=$(_IMG_SFX) \
-e GAC_FILEPATH=$(call err_if_empty,GAC_FILEPATH) \
-e TEMPDIR=$(_TEMPDIR) \
docker-archive:$<

$(_TEMPDIR)/image_builder_debug.tar: $(_TEMPDIR) $(_TEMPDIR)/var_cache_dnf image_builder/Containerfile image_builder/install_packages.txt ci/install_packages.sh lib.sh
Expand Down

0 comments on commit 183abc0

Please sign in to comment.