chore: improve error handling (#533)
* chore: improve error handling * Update test.yml * Update test.yml * Update test.yml * Update test.yml * Update test.yml * Update diff-sha.sh * Update diff-sha.sh * updated command. * Updated message level. * Updated message. * Updated message.
This commit is contained in:
parent
3fac642ac6
commit
3df9c18651
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@ -20,6 +20,16 @@ jobs:
|
|||||||
- name: shellcheck
|
- name: shellcheck
|
||||||
uses: reviewdog/action-shellcheck@v1.15
|
uses: reviewdog/action-shellcheck@v1.15
|
||||||
|
|
||||||
|
test-missing-git:
|
||||||
|
name: Test changed-files without git.
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Run changed-files with defaults
|
||||||
|
id: changed-files
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
|
||||||
test-pull-requests-from-forks:
|
test-pull-requests-from-forks:
|
||||||
name: Test changed-files diff on pull_requests from forks
|
name: Test changed-files diff on pull_requests from forks
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
22
diff-sha.sh
22
diff-sha.sh
@ -9,12 +9,19 @@ if [[ -n $INPUT_PATH ]]; then
|
|||||||
|
|
||||||
echo "::debug::Resolving repository path: $REPO_DIR"
|
echo "::debug::Resolving repository path: $REPO_DIR"
|
||||||
if [[ ! -d "$REPO_DIR" ]]; then
|
if [[ ! -d "$REPO_DIR" ]]; then
|
||||||
echo "::warning::Invalid repository path: $REPO_DIR"
|
echo "::error::Invalid repository path: $REPO_DIR"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
git --version 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
|
echo "::error::git not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "::debug::Getting HEAD SHA..."
|
echo "::debug::Getting HEAD SHA..."
|
||||||
|
|
||||||
if [[ -z $INPUT_SHA ]]; then
|
if [[ -z $INPUT_SHA ]]; then
|
||||||
@ -26,8 +33,9 @@ fi
|
|||||||
git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
if [[ $exit_status -ne 0 ]]; then
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
echo "::warning::Unable to locate the current sha: $CURRENT_SHA"
|
echo "::error::Unable to locate the current sha: $CURRENT_SHA"
|
||||||
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
git --version
|
||||||
|
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -53,8 +61,8 @@ if [[ -z $GITHUB_BASE_REF ]]; then
|
|||||||
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
if [[ $exit_status -ne 0 ]]; then
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
|
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
|
||||||
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -80,8 +88,8 @@ else
|
|||||||
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
if [[ $exit_status -ne 0 ]]; then
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
|
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
|
||||||
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -71,7 +71,7 @@ if [[ -n $INPUT_PATH ]]; then
|
|||||||
|
|
||||||
echo "::debug::Resolving repository path: $REPO_DIR"
|
echo "::debug::Resolving repository path: $REPO_DIR"
|
||||||
if [[ ! -d "$REPO_DIR" ]]; then
|
if [[ ! -d "$REPO_DIR" ]]; then
|
||||||
echo "::warning::Invalid repository path: $REPO_DIR"
|
echo "::error::Invalid repository path: $REPO_DIR"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user