mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-21 20:22:11 -05:00
Add debug info for multi status api calls (#1287)
* Add debug info for multi status api calls * Add test for clean action * Add more verbose * Test in action context * Test use local build as action * Improve debug for raw file array * Fix shallow fetch * Fix error messages on diff cmd * Changed repeated code to function * Fix quotes
This commit is contained in:
parent
a636deac61
commit
46df94844c
3 changed files with 70 additions and 87 deletions
23
.github/workflows/deploy-DEV.yml
vendored
23
.github/workflows/deploy-DEV.yml
vendored
|
@ -42,6 +42,9 @@ jobs:
|
|||
##########################
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.4
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
|
||||
########################
|
||||
# Get the current date #
|
||||
|
@ -76,6 +79,26 @@ jobs:
|
|||
shell: bash
|
||||
run: .automation/validate-docker-labels.sh
|
||||
|
||||
########################################
|
||||
# Edit action.yml for test local build #
|
||||
########################################
|
||||
- name: Edit an action.yml file for test local build
|
||||
run: |
|
||||
sed -i "s/super-linter:.*/super-linter:${GITHUB_SHA}'/g" action.yml
|
||||
|
||||
##########################
|
||||
# Test in action context #
|
||||
##########################
|
||||
# Test the built image in the actions context.
|
||||
# Not the container directly, and not using RUN_LOCAL=true
|
||||
- name: Test the local action
|
||||
uses: ./
|
||||
env:
|
||||
ACTIONS_RUNNER_DEBUG: true
|
||||
ERROR_ON_MISSING_EXEC_BIT: true
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
#####################################
|
||||
# Run Linter against Test code base #
|
||||
#####################################
|
||||
|
|
|
@ -7,6 +7,44 @@
|
|||
################################################################################
|
||||
########################## FUNCTION CALLS BELOW ################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
#### Function GenerateFileDiff #################################################
|
||||
function GenerateFileDiff() {
|
||||
CMD="${1}"
|
||||
################
|
||||
# print header #
|
||||
################
|
||||
debug "----------------------------------------------"
|
||||
debug "Generating Diff with:[$CMD]"
|
||||
|
||||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
CMD_OUTPUT=$($CMD)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
info "Failed to get Diff with:[$CMD]"
|
||||
info "Check that you have the full git history, the checkout is not shallow, etc"
|
||||
info "See https://github.com/github/super-linter#example-connecting-github-action-workflow"
|
||||
fatal "[${CMD_OUTPUT}]"
|
||||
fi
|
||||
|
||||
###################################################
|
||||
# Map command output to an array to proper handle #
|
||||
###################################################
|
||||
mapfile -t RAW_FILE_ARRAY < <(echo "$DIFF_TREE_CMD_OUTPUT")
|
||||
debug "RAW_FILE_ARRAY contents: ${RAW_FILE_ARRAY[*]}"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
#### Function BuildFileList ####################################################
|
||||
function BuildFileList() {
|
||||
|
@ -63,38 +101,7 @@ function BuildFileList() {
|
|||
# push event #
|
||||
################
|
||||
DIFF_TREE_CMD="git diff-tree --no-commit-id --name-only -r ${GITHUB_SHA}"
|
||||
|
||||
################
|
||||
# print header #
|
||||
################
|
||||
debug "----------------------------------------------"
|
||||
debug "Generating Diff with:[$DIFF_TREE_CMD]"
|
||||
|
||||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
DIFF_TREE_CMD_OUTPUT=$($DIFF_TREE_CMD)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
info "Failed to get Diff with:[$DIFF_TREE_CMD]"
|
||||
info "Check that you have the full git history, the checkout is not shallow, etc"
|
||||
info "See https://github.com/github/super-linter#example-connecting-github-action-workflow"
|
||||
fatal "[${DIFF_TREE_CMD}]"
|
||||
fi
|
||||
|
||||
###################################################
|
||||
# Map command output to an array to proper handle #
|
||||
###################################################
|
||||
mapfile -t RAW_FILE_ARRAY < <(echo "$DIFF_TREE_CMD_OUTPUT")
|
||||
GenerateFileDiff "$DIFF_TREE_CMD"
|
||||
|
||||
###############################################################
|
||||
# Need to see if the array is empty, if so, try the other way #
|
||||
|
@ -108,35 +115,8 @@ function BuildFileList() {
|
|||
debug "WARN: Generation of File array with diff-tree produced [0] items, trying with git diff..."
|
||||
|
||||
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d"
|
||||
GenerateFileDiff "$DIFF_CMD"
|
||||
|
||||
debug "----------------------------------------------"
|
||||
debug "Generating Diff with:[$DIFF_CMD]"
|
||||
|
||||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
DIFF_CMD_OUTPUT=$($DIFF_CMD)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
info "Failed to get Diff with:[$DIFF_CMD]"
|
||||
info "Check that you have the full git history, the checkout is not shallow, etc"
|
||||
info "See https://github.com/github/super-linter#example-connecting-github-action-workflow"
|
||||
fatal "[${DIFF_CMD}]"
|
||||
fi
|
||||
|
||||
###################################################
|
||||
# Map command output to an array to proper handle #
|
||||
###################################################
|
||||
mapfile -t RAW_FILE_ARRAY < <(echo "$DIFF_CMD_OUTPUT")
|
||||
fi
|
||||
else
|
||||
################
|
||||
|
@ -146,33 +126,7 @@ function BuildFileList() {
|
|||
# print header #
|
||||
################
|
||||
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d"
|
||||
|
||||
debug "----------------------------------------------"
|
||||
debug "Generating Diff with:[$DIFF_CMD]"
|
||||
|
||||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
DIFF_CMD_OUTPUT=$($DIFF_CMD)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
info "Failed to get Diff with:[$DIFF_CMD]"
|
||||
fatal "[${DIFF_CMD}]"
|
||||
fi
|
||||
|
||||
###################################################
|
||||
# Map command output to an array to proper handle #
|
||||
###################################################
|
||||
mapfile -t RAW_FILE_ARRAY < <(echo "$DIFF_CMD_OUTPUT")
|
||||
GenerateFileDiff "$DIFF_CMD"
|
||||
fi
|
||||
else
|
||||
WORKSPACE_PATH="${GITHUB_WORKSPACE}"
|
||||
|
|
|
@ -558,6 +558,8 @@ CallStatusAPI() {
|
|||
FAIL_MSG='Errors were detected, please view logs'
|
||||
MESSAGE='' # Message to send to status API
|
||||
|
||||
debug "Calling Multi-Status API for $LANGUAGE with status $STATUS"
|
||||
|
||||
######################################
|
||||
# Check the status to create message #
|
||||
######################################
|
||||
|
@ -579,6 +581,8 @@ CallStatusAPI() {
|
|||
STATUS="success"
|
||||
fi
|
||||
|
||||
debug "URL: ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}"
|
||||
|
||||
##############################################
|
||||
# Call the status API to create status check #
|
||||
##############################################
|
||||
|
@ -599,6 +603,8 @@ CallStatusAPI() {
|
|||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
debug "Send status comd output: [$SEND_STATUS_CMD]"
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
|
|
Loading…
Reference in a new issue