Skip to content

Commit

Permalink
Merge pull request #136 from perftool-incubator/dev-kmr
Browse files Browse the repository at this point in the history
add bypass-controller-build option to check-controller-build action
  • Loading branch information
k-rister authored Aug 16, 2024
2 parents f2d634f + a8405c5 commit 85e89ea
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 60 deletions.
8 changes: 5 additions & 3 deletions .github/actions/check-controller-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: "crucible-ci check controller build"
description: "Determine if the crucible changes require a controller rebuild for testing"
inputs:
bypass-controller-build:
description: "Should this action return 'no' no matter what"
required: true
crucible-directory:
description: "Where is the crucible repository to check for controller image related changes"
required: true
Expand All @@ -16,9 +19,8 @@ runs:
steps:
- name: "Validate crucible-directory"
shell: bash
run: ${{ github.action_path }}/validate-inputs.sh ${{ inputs.crucible-directory }} ${{ inputs.workshop-directory }}
run: ${{ github.action_path }}/validate-inputs.sh ${{ inputs.bypass-controller-build }} ${{ inputs.crucible-directory }} ${{ inputs.workshop-directory }}
- name: "Check for controller build status"
id: check-controller-build
shell: bash
run: ${{ github.action_path }}/check-controller-build.sh ${{ inputs.crucible-directory}} ${{ inputs.workshop-directory }}

run: ${{ github.action_path }}/check-controller-build.sh ${{ inputs.bypass-controller-build }} ${{ inputs.crucible-directory}} ${{ inputs.workshop-directory }}
111 changes: 58 additions & 53 deletions .github/actions/check-controller-build/check-controller-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash

crucible_directory=${1}
workshop_directory=${2}
bypass_controller_build=${1}
crucible_directory=${2}
workshop_directory=${3}

function error() {
echo "ERROR: ${1}"
Expand All @@ -26,66 +27,70 @@ diff_cmd="git diff --name-only HEAD^1 HEAD"

build_controller="no"

echo "Crucible workshop change analysis:"
if pushd ${crucible_directory}; then
if ${diff_cmd_validate} > /dev/null 2>&1; then
# history available

echo "Files changed:"
${diff_cmd}
if [ $? != 0 ]; then
error "could not obtain git-diff output"
if [ "${bypass_controller_build}" == "yes" ]; then
echo "Bypassing controller build"
else
echo "Crucible workshop change analysis:"
if pushd ${crucible_directory}; then
if ${diff_cmd_validate} > /dev/null 2>&1; then
# history available

echo "Files changed:"
${diff_cmd}
if [ $? != 0 ]; then
error "could not obtain git-diff output"
fi
echo

workshop_files_changed=$(${diff_cmd} | grep "^workshop/" | wc -l)
echo "workshop_files_changed=${workshop_files_changed}"
echo

if [ ${workshop_files_changed} -gt 0 ]; then
echo "INFO: controller build is required"
build_controller="yes"
fi
else
# history not available

echo "WARNING: Required history not available, assuming no controller build is required"
fi
echo

workshop_files_changed=$(${diff_cmd} | grep "^workshop/" | wc -l)
echo "workshop_files_changed=${workshop_files_changed}"
echo

if [ ${workshop_files_changed} -gt 0 ]; then
echo "INFO: controller build is required"
build_controller="yes"
fi
popd
else
# history not available

echo "WARNING: Required history not available, assuming no controller build is required"
error "Failed to pushd to crucible directory '${crucible_directory}'"
fi

popd
else
error "Failed to pushd to crucible directory '${crucible_directory}'"
fi

echo "Workshop change analysis:"
if pushd ${workshop_directory}; then
if ${diff_cmd_validate} > /dev/null 2>&1; then
# history available

echo "Files changed:"
${diff_cmd}
if [ $? != 0 ]; then
error "could not obtian git-diff output"
echo "Workshop change analysis:"
if pushd ${workshop_directory}; then
if ${diff_cmd_validate} > /dev/null 2>&1; then
# history available

echo "Files changed:"
${diff_cmd}
if [ $? != 0 ]; then
error "could not obtian git-diff output"
fi
echo

workshop_files_changed=$(${diff_cmd} | grep "^workshop.pl\|^schema.json" | wc -l)
echo "workshop_files_changed=${workshop_files_changed}"
echo

if [ ${workshop_files_changed} -gt 0 ]; then
echo "INFO: controller build is required"
build_controller="yes"
fi
else
# history not available

echo "WARNING: Required history not available, assuming no controller build is required"
fi
echo

workshop_files_changed=$(${diff_cmd} | grep "^workshop.pl\|^schema.json" | wc -l)
echo "workshop_files_changed=${workshop_files_changed}"
echo

if [ ${workshop_files_changed} -gt 0 ]; then
echo "INFO: controller build is required"
build_controller="yes"
fi
popd
else
# history not available

echo "WARNING: Required history not available, assuming no controller build is required"
error "Failed to pushd to workshop directory '${workshop_directory}'"
fi

popd
else
error "Failed to pushd to workshop directory '${workshop_directory}'"
fi

echo "Setting build-controller to '${build_controller}'"
Expand Down
22 changes: 18 additions & 4 deletions .github/actions/check-controller-build/validate-inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,42 @@
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash

crucible_directory=${1}
workshop_directory=${2}
bypass_controller_build=${1}
crucible_directory=${2}
workshop_directory=${3}

function error() {
echo "ERROR: ${1}"
exit 1
}

function usage() {
echo "Usage: ${0} <crucible> <workshop>"
echo "Usage: ${0} <bypass-controller-build> <crucible> <workshop>"
echo
echo "<bypass-controller-build> is a yes|no value"
echo "<crucible> is a directory where the crucible repository exists."
echo "<workshop> is a directory where the workshop repoistory exists."
echo
echo "If <bypass-controller-build> is 'yes' then the action short circuits and returns 'no'"
echo
echo "Both repositories are examined to determine if their changes require"
echo "the building of a new controller image for testing"
exit 1
}

if [ -z "${crucible_directory}" -o -z "${workshop_directory}" ]; then
if [ -z "${bypass_controller_build}" -o -z "${crucible_directory}" -o -z "${workshop_directory}" ]; then
usage
else
# handle <bypass-controller-build>
case "${bypass_controller_build}" in
"yes"|"no")
echo "bypass_controller_build has a valid value of '${bypass_controller_build}'"
;;
*)
error "bypass_controller_build has an invalid value of '${bypass_controller_build}'"
;;
esac

# handle <crucible>
if [ ! -e "${crucible_directory}" ]; then
error "The crucible directory '${crucible_directory}' does not exist"
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/core-crucible-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ on:
required: false
type: string
default: "all"
bypass_controller_build:
required: false
type: string
default: "no"
secrets:
registry_auth:
required: false
Expand Down Expand Up @@ -147,6 +151,7 @@ jobs:
id: check-controller-build
uses: ./crucible-ci/.github/actions/check-controller-build
with:
bypass-controller-build: "${{ inputs.bypass_controller_build }}"
crucible-directory: "./crucible"
workshop-directory: "./workshop"
- name: run get-repo-name
Expand Down

0 comments on commit 85e89ea

Please sign in to comment.