Skip to content

Commit

Permalink
Static checks now rebuilds container if run.sh is modified
Browse files Browse the repository at this point in the history
Ticket: ENT-10993
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
  • Loading branch information
larsewi committed Dec 3, 2024
1 parent 8295274 commit ffc7800
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/static-check/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,30 @@ function create_image() {

set -x

# TODO: check how old the image is and recreate if it's too old
# Get the version of CFEngine from configure
VERSION=`./configure --version | head -n1 | grep -Eo '[0-9]+\.[0-9]+'`
VERSION="${VERSION}.x"

# Check if we can find this file upstream
STATUS=`curl -o /dev/null --silent -Iw '%{http_code}' "https://raw.githubusercontent.com/cfengine/core/refs/heads/${VERSION}/tests/static-check/run.sh"`
if [[ $STATUS = "404" ]]
then
# If a branch with that version does not exist, then it's probably master
VERSION="master"
STATUS=`curl -o /dev/null --silent -Iw '%{http_code}' "https://raw.githubusercontent.com/cfengine/core/refs/heads/${VERSION}/tests/static-check/run.sh"`
fi

# Compare digest of this file with upstream. If it has changed, then we rebuild the container
if [[ $STATUS = "200" ]]
then
SUM_A=`curl "https://raw.githubusercontent.com/cfengine/core/refs/heads/${VERSION}/tests/static-check/run.sh" | sha256sum | awk '{print $1}'`
SUM_B=`sha256sum "$0" | awk '{print $1}'`
if [[ $SUM_A != $SUM_B ]]
then
c=$(create_image)
fi
fi

if buildah inspect cfengine-static-checker-f$STATIC_CHECKS_FEDORA_VERSION >/dev/null 2>&1; then
c=$(buildah from cfengine-static-checker-f$STATIC_CHECKS_FEDORA_VERSION)
else
Expand Down

0 comments on commit ffc7800

Please sign in to comment.