diff --git a/.github/actions/check-controller-build/action.yml b/.github/actions/check-controller-build/action.yml index 5b0d4d2..6745a62 100644 --- a/.github/actions/check-controller-build/action.yml +++ b/.github/actions/check-controller-build/action.yml @@ -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 @@ -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 }} diff --git a/.github/actions/check-controller-build/check-controller-build.sh b/.github/actions/check-controller-build/check-controller-build.sh index 3f96d8e..280a2fb 100755 --- a/.github/actions/check-controller-build/check-controller-build.sh +++ b/.github/actions/check-controller-build/check-controller-build.sh @@ -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}" @@ -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}'" diff --git a/.github/actions/check-controller-build/validate-inputs.sh b/.github/actions/check-controller-build/validate-inputs.sh index dd9edd2..cd672ed 100755 --- a/.github/actions/check-controller-build/validate-inputs.sh +++ b/.github/actions/check-controller-build/validate-inputs.sh @@ -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}" @@ -11,19 +12,32 @@ function error() { } function usage() { - echo "Usage: ${0} " + echo "Usage: ${0} " echo + echo " is a yes|no value" echo " is a directory where the crucible repository exists." echo " is a directory where the workshop repoistory exists." echo + echo "If 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 + 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 if [ ! -e "${crucible_directory}" ]; then error "The crucible directory '${crucible_directory}' does not exist" diff --git a/.github/workflows/core-crucible-ci.yaml b/.github/workflows/core-crucible-ci.yaml index f1e1f96..63a8766 100644 --- a/.github/workflows/core-crucible-ci.yaml +++ b/.github/workflows/core-crucible-ci.yaml @@ -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 @@ -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