mirror of
https://github.com/containers/skopeo.git
synced 2025-07-06 19:29:18 +00:00
Cirrus: Improve test synchronization with c/image
The `test_skopeo_task` must be substantially duplicated between this repository and containers/image. Make this easier to maintain by implementing a runner script to contain any/all differences. This allows the `test_skopeo_task` definition to remain 100% identical across the two repositories. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
parent
146af8cd59
commit
88979a6a88
74
.cirrus.yml
74
.cirrus.yml
@ -12,9 +12,13 @@ env:
|
|||||||
GOBIN: "${GOPATH}/bin"
|
GOBIN: "${GOPATH}/bin"
|
||||||
GOCACHE: "${GOPATH}/cache"
|
GOCACHE: "${GOPATH}/cache"
|
||||||
GOSRC: &gosrc "/var/tmp/go/src/github.com/containers/skopeo"
|
GOSRC: &gosrc "/var/tmp/go/src/github.com/containers/skopeo"
|
||||||
|
# Required for consistency with containers/image CI
|
||||||
|
SKOPEO_PATH: *gosrc
|
||||||
CIRRUS_WORKING_DIR: *gosrc
|
CIRRUS_WORKING_DIR: *gosrc
|
||||||
# The default is 'sh' if unspecified
|
# The default is 'sh' if unspecified
|
||||||
CIRRUS_SHELL: "/bin/bash"
|
CIRRUS_SHELL: "/bin/bash"
|
||||||
|
# Save a little typing (path relative to $CIRRUS_WORKING_DIR)
|
||||||
|
SCRIPT_BASE: "./contrib/cirrus"
|
||||||
|
|
||||||
####
|
####
|
||||||
#### Cache-image names to test with (double-quotes around names are critical)
|
#### Cache-image names to test with (double-quotes around names are critical)
|
||||||
@ -60,17 +64,26 @@ validate_task:
|
|||||||
script: make validate-local
|
script: make validate-local
|
||||||
|
|
||||||
|
|
||||||
vendor_task:
|
cross_task:
|
||||||
only_if: $CIRRUS_PR != ''
|
# TODO: hack/travis_osx.sh doesn't work under cirrus-ci
|
||||||
container: *build_container
|
# for some unknown reason. Remove the next line when
|
||||||
script: make vendor && ./hack/tree_status.sh
|
# fixed (remember to remove from .travis.yml also).
|
||||||
|
allow_failures: $CI == $CI
|
||||||
|
macos_instance:
|
||||||
|
image: catalina-xcode-11.3.1
|
||||||
|
brew_script: brew install gpgme go go-md2man
|
||||||
|
test_script: hack/travis_osx.sh
|
||||||
|
|
||||||
|
|
||||||
test_task:
|
#####
|
||||||
alias: test
|
##### NOTE: This task is subtantially duplicated in the containers/image
|
||||||
|
##### repository's `.cirrus.yml`. Changes made here should be fully merged
|
||||||
|
##### prior to being manually duplicated and maintained in containers/image.
|
||||||
|
#####
|
||||||
|
test_skopeo_task:
|
||||||
|
alias: test_skopeo
|
||||||
depends_on:
|
depends_on:
|
||||||
- validate
|
- validate
|
||||||
- vendor
|
|
||||||
gce_instance:
|
gce_instance:
|
||||||
image_project: libpod-218412
|
image_project: libpod-218412
|
||||||
zone: "us-central1-f"
|
zone: "us-central1-f"
|
||||||
@ -87,35 +100,20 @@ test_task:
|
|||||||
- name: "Skopeo Test w/ opengpg"
|
- name: "Skopeo Test w/ opengpg"
|
||||||
env:
|
env:
|
||||||
BUILDTAGS: 'btrfs_noversion libdm_no_deferred_remove containers_image_openpgp'
|
BUILDTAGS: 'btrfs_noversion libdm_no_deferred_remove containers_image_openpgp'
|
||||||
env:
|
setup_script: >-
|
||||||
# TODO: Remove test technical-debt requiring integration tests to run
|
"${GOSRC}/${SCRIPT_BASE}/runner.sh" setup
|
||||||
# inside a container and with --privileged. This is hiding bugs!
|
vendor_script: >-
|
||||||
PODMANMAKE: >-
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" vendor
|
||||||
podman run -it --rm --privileged
|
build_script: >-
|
||||||
-e GOPATH=$GOPATH
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" build
|
||||||
-v $GOPATH:$GOPATH:Z
|
validate_script: >-
|
||||||
-w $GOSRC
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" validate
|
||||||
$SKOPEO_CI_CONTAINER_FQIN
|
unit_script: >-
|
||||||
make
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" unit
|
||||||
setup_script: |
|
integration_script: >-
|
||||||
# This is required as part of the standard Fedora VM setup
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" integration
|
||||||
growpart /dev/sda 1
|
system_script: >
|
||||||
resize2fs /dev/sda1
|
"${SKOPEO_PATH}/${SCRIPT_BASE}/runner.sh" system
|
||||||
|
|
||||||
# VM's come with the distro. skopeo pre-installed
|
|
||||||
dnf erase -y skopeo
|
|
||||||
|
|
||||||
# Ensure we start with a clean-slate
|
|
||||||
podman system reset --force
|
|
||||||
# Note: We _HAVE_ to spam BUILDTAGS in this way due to how Cirrus-CI
|
|
||||||
# mangles quoted strings when performing in-line 'env' substitution.
|
|
||||||
main_script: |
|
|
||||||
set -x
|
|
||||||
$PODMANMAKE bin/skopeo BUILDTAGS="$BUILDTAGS"
|
|
||||||
$PODMANMAKE test-unit-local BUILDTAGS="$BUILDTAGS"
|
|
||||||
$PODMANMAKE test-integration-local BUILDTAGS="$BUILDTAGS"
|
|
||||||
# Do not run inside podman, uses containers internally.
|
|
||||||
make test-system-local BUILDTAGS="$BUILDTAGS"
|
|
||||||
|
|
||||||
|
|
||||||
# This task is critical. It updates the "last-used by" timestamp stored
|
# This task is critical. It updates the "last-used by" timestamp stored
|
||||||
@ -153,8 +151,8 @@ success_task:
|
|||||||
# N/B: ALL tasks must be listed here, minus their '_task' suffix.
|
# N/B: ALL tasks must be listed here, minus their '_task' suffix.
|
||||||
depends_on:
|
depends_on:
|
||||||
- validate
|
- validate
|
||||||
- vendor
|
- cross
|
||||||
- test
|
- test_skopeo
|
||||||
- meta
|
- meta
|
||||||
container: *smallcontainer
|
container: *smallcontainer
|
||||||
env:
|
env:
|
||||||
|
91
contrib/cirrus/runner.sh
Executable file
91
contrib/cirrus/runner.sh
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script is intended to be executed by automation or humans
|
||||||
|
# under a hack/get_ci_vm.sh context. Use under any other circumstances
|
||||||
|
# is unlikely to function.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -r "/etc/automation_environment" ]]; then
|
||||||
|
source /etc/automation_environment
|
||||||
|
source $AUTOMATION_LIB_PATH/common_lib.sh
|
||||||
|
else
|
||||||
|
(
|
||||||
|
echo "WARNING: It does not appear that containers/automation was installed."
|
||||||
|
echo " Functionality of most of ${BASH_SOURCE[0]} will be negatively"
|
||||||
|
echo " impacted."
|
||||||
|
) > /dev/stderr
|
||||||
|
fi
|
||||||
|
|
||||||
|
OS_RELEASE_ID="$(source /etc/os-release; echo $ID)"
|
||||||
|
# GCE image-name compatible string representation of distribution _major_ version
|
||||||
|
OS_RELEASE_VER="$(source /etc/os-release; echo $VERSION_ID | tr -d '.')"
|
||||||
|
# Combined to ease some usage
|
||||||
|
OS_REL_VER="${OS_RELEASE_ID}-${OS_RELEASE_VER}"
|
||||||
|
|
||||||
|
export "PATH=$PATH:$GOPATH/bin"
|
||||||
|
|
||||||
|
podmanmake() {
|
||||||
|
req_env_vars GOPATH SKOPEO_PATH SKOPEO_CI_CONTAINER_FQIN
|
||||||
|
warn "Accumulated technical-debt requires execution inside a --privileged container. This is very likely hiding bugs!"
|
||||||
|
showrun podman run -it --rm --privileged \
|
||||||
|
-e GOPATH=$GOPATH \
|
||||||
|
-v $GOPATH:$GOPATH:Z \
|
||||||
|
-w $SKOPEO_PATH \
|
||||||
|
$SKOPEO_CI_CONTAINER_FQIN \
|
||||||
|
make "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_setup() {
|
||||||
|
if [[ "$OS_RELEASE_ID" == "fedora" ]]; then
|
||||||
|
# This is required as part of the standard Fedora VM setup
|
||||||
|
growpart /dev/sda 1
|
||||||
|
resize2fs /dev/sda1
|
||||||
|
|
||||||
|
# VM's come with the distro. skopeo pre-installed
|
||||||
|
dnf erase -y skopeo
|
||||||
|
else
|
||||||
|
die "Unknown/unsupported distro. $OS_REL_VER"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_vendor() {
|
||||||
|
podmanmake vendor BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_build() {
|
||||||
|
podmanmake bin/skopeo BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_validate() {
|
||||||
|
podmanmake validate-local BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_unit() {
|
||||||
|
podmanmake test-integration-local BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_integration() {
|
||||||
|
podmanmake test-integration-local BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_run_system() {
|
||||||
|
# Ensure we start with a clean-slate
|
||||||
|
podman system reset --force
|
||||||
|
# Executes with containers required for testing.
|
||||||
|
showrun make test-system-local BUILDTAGS="$BUILDTAGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
req_env_vars SKOPEO_PATH BUILDTAGS
|
||||||
|
|
||||||
|
handler="_run_${1}"
|
||||||
|
if [ "$(type -t $handler)" != "function" ]; then
|
||||||
|
die "Unknown/Unsupported command-line argument '$1'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "************************************************************"
|
||||||
|
msg "Runner executing $1 on $OS_REL_VER"
|
||||||
|
msg "************************************************************"
|
||||||
|
|
||||||
|
cd "$SKOPEO_PATH"
|
||||||
|
$handler
|
@ -43,12 +43,8 @@ elif [[ "$1" == "--setup" ]]; then
|
|||||||
in_get_ci_vm "$1"
|
in_get_ci_vm "$1"
|
||||||
# get_ci_vm container entrypoint calls us with this option on the
|
# get_ci_vm container entrypoint calls us with this option on the
|
||||||
# Cirrus-CI environment instance, to perform repo.-specific setup.
|
# Cirrus-CI environment instance, to perform repo.-specific setup.
|
||||||
cd $REPO_DIRPATH
|
echo "+ Executing setup" > /dev/stderr
|
||||||
echo "+ Growing root filesystem" > /dev/stderr
|
${GOSRC}/${SCRIPT_BASE}/runner.sh setup
|
||||||
growpart /dev/sda 1
|
|
||||||
resize2fs /dev/sda1
|
|
||||||
echo "+ Erasing pre-installed skopeo package" > /dev/stderr
|
|
||||||
dnf erase -y skopeo
|
|
||||||
else
|
else
|
||||||
# Create and access VM for specified Cirrus-CI task
|
# Create and access VM for specified Cirrus-CI task
|
||||||
mkdir -p $HOME/.config/gcloud/ssh
|
mkdir -p $HOME/.config/gcloud/ssh
|
||||||
|
Loading…
Reference in New Issue
Block a user