mirror of
https://github.com/containers/podman.git
synced 2025-07-25 09:05:00 +08:00
Cirrus: Combine build and code consistency tasks
It's conceivable for CI to spend a lot of time testing code which otherwise should be rejected due to quality problems. Previously this was validated in a dedicated task, however a failure would still fail the CI run. Simplify the number of CI tasks by combining the consistency check at the tail-end of the build task. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
63
.cirrus.yml
63
.cirrus.yml
@ -148,6 +148,8 @@ build_task:
|
|||||||
# all required external/3rd-party services are available and functional.
|
# all required external/3rd-party services are available and functional.
|
||||||
# Standard main execution stage call, used by nearly every task in CI.
|
# Standard main execution stage call, used by nearly every task in CI.
|
||||||
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
|
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
|
||||||
|
# Attempt to catch code-quality and vendoring problems early.
|
||||||
|
postbuild_script: &postbuild $SCRIPT_BASE/postbuild.sh
|
||||||
# Cirrus-CI is very slow uploading one file at time, and the repo contains
|
# Cirrus-CI is very slow uploading one file at time, and the repo contains
|
||||||
# thousands of files. Speed this up by archiving into tarball first.
|
# thousands of files. Speed this up by archiving into tarball first.
|
||||||
repo_prep_script: &repo_prep >-
|
repo_prep_script: &repo_prep >-
|
||||||
@ -160,7 +162,6 @@ build_task:
|
|||||||
path: ./*-${STATS_LOGFILE_SFX}
|
path: ./*-${STATS_LOGFILE_SFX}
|
||||||
type: text/plain
|
type: text/plain
|
||||||
|
|
||||||
|
|
||||||
build_aarch64_task:
|
build_aarch64_task:
|
||||||
alias: 'build_aarch64'
|
alias: 'build_aarch64'
|
||||||
name: 'Build for $DISTRO_NV'
|
name: 'Build for $DISTRO_NV'
|
||||||
@ -182,6 +183,7 @@ build_aarch64_task:
|
|||||||
clone_script: *full_clone
|
clone_script: *full_clone
|
||||||
prebuild_script: *prebuild
|
prebuild_script: *prebuild
|
||||||
setup_script: *setup
|
setup_script: *setup
|
||||||
|
postbuild_script: *postbuild
|
||||||
main_script: *main
|
main_script: *main
|
||||||
# Cirrus-CI is very slow uploading one file at time, and the repo contains
|
# Cirrus-CI is very slow uploading one file at time, and the repo contains
|
||||||
# thousands of files. Speed this up by archiving into tarball first.
|
# thousands of files. Speed this up by archiving into tarball first.
|
||||||
@ -325,56 +327,6 @@ swagger_task:
|
|||||||
type: text/plain
|
type: text/plain
|
||||||
|
|
||||||
|
|
||||||
# Check that all included go modules from other sources match
|
|
||||||
# what is expected in `vendor/modules.txt` vs `go.mod`. Also
|
|
||||||
# make sure that the generated bindings in pkg/bindings/...
|
|
||||||
# are in sync with the code.
|
|
||||||
consistency_task:
|
|
||||||
name: "Test Code Consistency"
|
|
||||||
alias: consistency
|
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
|
||||||
only_if: *is_pr
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
container: &smallcontainer
|
|
||||||
image: ${CTR_FQIN}
|
|
||||||
# Resources are limited across ALL currently executing tasks
|
|
||||||
# ref: https://cirrus-ci.org/guide/linux/#linux-containers
|
|
||||||
cpu: 2
|
|
||||||
memory: 2
|
|
||||||
env:
|
|
||||||
<<: *stdenvars
|
|
||||||
TEST_FLAVOR: consistency
|
|
||||||
TEST_ENVIRON: container
|
|
||||||
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
|
|
||||||
clone_script: *get_gosrc
|
|
||||||
setup_script: *setup
|
|
||||||
main_script: *main
|
|
||||||
always: *runner_stats
|
|
||||||
|
|
||||||
|
|
||||||
# Check that all included go modules from other sources match
|
|
||||||
# what is expected in `vendor/modules.txt` vs `go.mod`. Also
|
|
||||||
# make sure that the generated bindings in pkg/bindings/...
|
|
||||||
# are in sync with the code.
|
|
||||||
consistency_aarch64_task:
|
|
||||||
name: "Test Code Consistency (aarch64)"
|
|
||||||
alias: consistency_aarch64
|
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
|
||||||
only_if: *is_pr
|
|
||||||
depends_on:
|
|
||||||
- build_aarch64
|
|
||||||
ec2_instance: *standard_build_ec2_aarch64
|
|
||||||
env:
|
|
||||||
<<: *stdenvars_aarch64
|
|
||||||
TEST_FLAVOR: consistency
|
|
||||||
TEST_ENVIRON: container
|
|
||||||
clone_script: *get_gosrc_aarch64
|
|
||||||
setup_script: *setup
|
|
||||||
main_script: *main
|
|
||||||
always: *runner_stats
|
|
||||||
|
|
||||||
|
|
||||||
# There are several other important variations of podman which
|
# There are several other important variations of podman which
|
||||||
# must always build successfully. Most of them are handled in
|
# must always build successfully. Most of them are handled in
|
||||||
# this task, though a few need dedicated tasks which follow.
|
# this task, though a few need dedicated tasks which follow.
|
||||||
@ -978,8 +930,6 @@ success_task:
|
|||||||
- validate_aarch64
|
- validate_aarch64
|
||||||
- bindings
|
- bindings
|
||||||
- swagger
|
- swagger
|
||||||
- consistency
|
|
||||||
- consistency_aarch64
|
|
||||||
- alt_build
|
- alt_build
|
||||||
- osx_alt_build
|
- osx_alt_build
|
||||||
- win_installer
|
- win_installer
|
||||||
@ -1004,7 +954,12 @@ success_task:
|
|||||||
- upgrade_test
|
- upgrade_test
|
||||||
- image_build
|
- image_build
|
||||||
- meta
|
- meta
|
||||||
container: *smallcontainer
|
container: &smallcontainer
|
||||||
|
image: ${CTR_FQIN}
|
||||||
|
# Resources are limited across ALL currently executing tasks
|
||||||
|
# ref: https://cirrus-ci.org/guide/linux/#linux-containers
|
||||||
|
cpu: 2
|
||||||
|
memory: 2
|
||||||
env:
|
env:
|
||||||
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
|
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
|
||||||
TEST_ENVIRON: container
|
TEST_ENVIRON: container
|
||||||
|
@ -47,7 +47,6 @@ of this document, it's not possible to override the behavior of `$CIRRUS_PR`.
|
|||||||
+ validate
|
+ validate
|
||||||
+ bindings
|
+ bindings
|
||||||
+ swagger
|
+ swagger
|
||||||
+ consistency
|
|
||||||
+ *alt_build*
|
+ *alt_build*
|
||||||
+ osx_alt_build
|
+ osx_alt_build
|
||||||
+ docker-py_test
|
+ docker-py_test
|
||||||
@ -77,7 +76,6 @@ of this document, it's not possible to override the behavior of `$CIRRUS_PR`.
|
|||||||
+ *build*
|
+ *build*
|
||||||
+ validate
|
+ validate
|
||||||
+ swagger
|
+ swagger
|
||||||
+ consistency
|
|
||||||
+ meta
|
+ meta
|
||||||
+ success
|
+ success
|
||||||
|
|
||||||
@ -85,14 +83,12 @@ of this document, it's not possible to override the behavior of `$CIRRUS_PR`.
|
|||||||
+ *build*
|
+ *build*
|
||||||
+ validate
|
+ validate
|
||||||
+ swagger
|
+ swagger
|
||||||
+ consistency
|
|
||||||
+ meta
|
+ meta
|
||||||
+ success
|
+ success
|
||||||
|
|
||||||
### Intend `[CI:BUILD]` PR Tasks:
|
### Intend `[CI:BUILD]` PR Tasks:
|
||||||
+ *build*
|
+ *build*
|
||||||
+ validate
|
+ validate
|
||||||
+ consistency
|
|
||||||
+ *alt_build*
|
+ *alt_build*
|
||||||
+ osx_alt_build
|
+ osx_alt_build
|
||||||
+ test_image_build
|
+ test_image_build
|
||||||
@ -101,6 +97,7 @@ of this document, it's not possible to override the behavior of `$CIRRUS_PR`.
|
|||||||
+ artifacts
|
+ artifacts
|
||||||
|
|
||||||
### Intended Branch tasks (and Cirrus-cron jobs, except "multiarch"):
|
### Intended Branch tasks (and Cirrus-cron jobs, except "multiarch"):
|
||||||
|
+ *build*
|
||||||
+ swagger
|
+ swagger
|
||||||
+ *alt_build*
|
+ *alt_build*
|
||||||
+ osx_alt_build
|
+ osx_alt_build
|
||||||
|
@ -36,6 +36,8 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Defined by/in Cirrus-CI config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
base=$(git merge-base $DEST_BRANCH $CIRRUS_CHANGE_IN_REPO)
|
base=$(git merge-base $DEST_BRANCH $CIRRUS_CHANGE_IN_REPO)
|
||||||
diffs=$(git diff $base $CIRRUS_CHANGE_IN_REPO -- '*.go' ':^vendor/')
|
diffs=$(git diff $base $CIRRUS_CHANGE_IN_REPO -- '*.go' ':^vendor/')
|
||||||
|
|
||||||
|
30
contrib/cirrus/postbuild.sh
Executable file
30
contrib/cirrus/postbuild.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
# This script attempts to confirm all included go modules from
|
||||||
|
# other sources match what is expected in `vendor/modules.txt`
|
||||||
|
# vs `go.mod`. Also make sure that the generated bindings in
|
||||||
|
# `pkg/bindings/...` are in sync with the code. It's intended
|
||||||
|
# for use after successfully building podman, to prevent wasting
|
||||||
|
# time on tests that might otherwise succeed with bad/ugly/invalid
|
||||||
|
# code.
|
||||||
|
|
||||||
|
source /etc/automation_environment
|
||||||
|
source $AUTOMATION_LIB_PATH/common_lib.sh
|
||||||
|
|
||||||
|
# Defined by the CI system
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
cd $CIRRUS_WORKING_DIR
|
||||||
|
|
||||||
|
showrun make .install.goimports
|
||||||
|
showrun make vendor
|
||||||
|
SUGGESTION="run 'make vendor' and commit all changes" ./hack/tree_status.sh
|
||||||
|
showrun make generate-bindings
|
||||||
|
SUGGESTION="run 'make generate-bindings' and commit all changes" ./hack/tree_status.sh
|
||||||
|
showrun make completions
|
||||||
|
SUGGESTION="run 'make completions' and commit all changes" ./hack/tree_status.sh
|
||||||
|
|
||||||
|
# Defined in Cirrus-CI config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
$SCRIPT_BASE/check_go_changes.sh
|
@ -17,26 +17,27 @@ req_env_vars CI DEST_BRANCH IMAGE_SUFFIX TEST_FLAVOR TEST_ENVIRON \
|
|||||||
SCRIPT_BASE CIRRUS_WORKING_DIR FEDORA_NAME UBUNTU_NAME \
|
SCRIPT_BASE CIRRUS_WORKING_DIR FEDORA_NAME UBUNTU_NAME \
|
||||||
VM_IMAGE_NAME
|
VM_IMAGE_NAME
|
||||||
|
|
||||||
# There's no need to perform further checks on more than one
|
# Defined by the CI system
|
||||||
# CI platform. These variables are defined in .cirrus.yml
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [[ ! "${DISTRO_NV}" =~ ${FEDORA_NAME} ]]; then
|
cd $CIRRUS_WORKING_DIR
|
||||||
echo "Skipping additional checks on $DISTRO_NV"
|
|
||||||
exit 0
|
# Defined by CI config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
showrun $SCRIPT_BASE/cirrus_yaml_test.py
|
||||||
|
|
||||||
|
# Defined by CI config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
if [[ "${DISTRO_NV}" =~ fedora ]]; then
|
||||||
|
showrun ooe.sh dnf install -y ShellCheck # small/quick addition
|
||||||
|
showrun shellcheck --color=always --format=tty \
|
||||||
|
--shell=bash --external-sources \
|
||||||
|
--enable add-default-case,avoid-nullary-conditions,check-unassigned-uppercase \
|
||||||
|
--exclude SC2046,SC2034,SC2090,SC2064 \
|
||||||
|
--wiki-link-count=0 --severity=warning \
|
||||||
|
$SCRIPT_BASE/*.sh hack/get_ci_vm.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
msg "Checking 3rd party network service connectivity"
|
||||||
$SCRIPT_BASE/cirrus_yaml_test.py
|
|
||||||
|
|
||||||
ooe.sh dnf install -y ShellCheck # small/quick addition
|
|
||||||
|
|
||||||
shellcheck --color=always --format=tty \
|
|
||||||
--shell=bash --external-sources \
|
|
||||||
--enable add-default-case,avoid-nullary-conditions,check-unassigned-uppercase \
|
|
||||||
--exclude SC2046,SC2034,SC2090,SC2064 \
|
|
||||||
--wiki-link-count=0 --severity=warning \
|
|
||||||
$SCRIPT_BASE/*.sh hack/get_ci_vm.sh
|
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
cat ${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/required_host_ports.txt | \
|
cat ${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/required_host_ports.txt | \
|
||||||
while read host port
|
while read host port
|
||||||
@ -66,9 +67,11 @@ TEST_IMGS=(\
|
|||||||
cirros:latest
|
cirros:latest
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "Checking quay.io test image accessibility"
|
msg "Checking quay.io test image accessibility"
|
||||||
for testimg in "${TEST_IMGS[@]}"; do
|
for testimg in "${TEST_IMGS[@]}"; do
|
||||||
fqin="quay.io/libpod/$testimg"
|
fqin="quay.io/libpod/$testimg"
|
||||||
echo " $fqin"
|
echo " $fqin"
|
||||||
|
# Belt-and-suspenders: Catch skopeo (somehow) returning False or null
|
||||||
|
# in addition to "bad" (invalid) JSON.
|
||||||
skopeo inspect --retry-times 5 "docker://$fqin" | jq -e . > /dev/null
|
skopeo inspect --retry-times 5 "docker://$fqin" | jq -e . > /dev/null
|
||||||
done
|
done
|
||||||
|
@ -211,16 +211,6 @@ eof
|
|||||||
rm -f $envvarsfile
|
rm -f $envvarsfile
|
||||||
}
|
}
|
||||||
|
|
||||||
function _run_consistency() {
|
|
||||||
make vendor
|
|
||||||
SUGGESTION="run 'make vendor' and commit all changes" ./hack/tree_status.sh
|
|
||||||
make generate-bindings
|
|
||||||
SUGGESTION="run 'make generate-bindings' and commit all changes" ./hack/tree_status.sh
|
|
||||||
make completions
|
|
||||||
SUGGESTION="run 'make completions' and commit all changes" ./hack/tree_status.sh
|
|
||||||
$SCRIPT_BASE/check_go_changes.sh
|
|
||||||
}
|
|
||||||
|
|
||||||
function _run_build() {
|
function _run_build() {
|
||||||
# Ensure always start from clean-slate with all vendor modules downloaded
|
# Ensure always start from clean-slate with all vendor modules downloaded
|
||||||
make clean
|
make clean
|
||||||
|
@ -364,10 +364,6 @@ case "$TEST_FLAVOR" in
|
|||||||
docker.io/gitlab/gitlab-runner-helper:x86_64-latest-pwsh
|
docker.io/gitlab/gitlab-runner-helper:x86_64-latest-pwsh
|
||||||
;;
|
;;
|
||||||
swagger) ;& # use next item
|
swagger) ;& # use next item
|
||||||
consistency)
|
|
||||||
make clean
|
|
||||||
make .install.goimports
|
|
||||||
;;
|
|
||||||
release) ;;
|
release) ;;
|
||||||
*) die_unknown TEST_FLAVOR
|
*) die_unknown TEST_FLAVOR
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user