Update test.yml (#81)
This commit is contained in:
parent
d093818ffe
commit
5fe8e4d604
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@ -4,11 +4,28 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- '**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test-no-head-sha:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test changed-files missing head sha
|
||||||
|
steps:
|
||||||
|
- name: Checkout to branch
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run changed-files with defaults
|
||||||
|
id: changed-files
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
|
||||||
|
- name: Show output
|
||||||
|
run: |
|
||||||
|
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Test changed-files
|
name: Test changed-files
|
||||||
|
@ -7,20 +7,22 @@ git remote set-url origin "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY
|
|||||||
echo "Getting head sha..."
|
echo "Getting head sha..."
|
||||||
|
|
||||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||||
HEAD_SHA=$(git rev-parse HEAD^1 || true)
|
HEAD_SHA=$(git rev-parse HEAD^1 2>&1) && exit_status=$? || exit_status=$?
|
||||||
else
|
else
|
||||||
TARGET_BRANCH=${GITHUB_BASE_REF}
|
TARGET_BRANCH=${GITHUB_BASE_REF}
|
||||||
git fetch --depth=1 origin "${TARGET_BRANCH}":"${TARGET_BRANCH}"
|
git fetch --depth=1 origin "${TARGET_BRANCH}":"${TARGET_BRANCH}"
|
||||||
HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" || true)
|
HEAD_SHA=$(git rev-parse "${TARGET_BRANCH}" 2>&1) && exit_status=$? || exit_status=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $HEAD_SHA ]]; then
|
if [[ $exit_status -ne 0 ]]; then
|
||||||
echo "::warning::Unable to determine the head sha: $HEAD_SHA."
|
echo "::warning::Unable to determine the head sha"
|
||||||
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'"
|
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
fi
|
||||||
echo "Using head sha: $HEAD_SHA..."
|
|
||||||
if [[ -z "$INPUT_FILES" ]]; then
|
echo "Using head sha: $HEAD_SHA..."
|
||||||
|
|
||||||
|
if [[ -z "$INPUT_FILES" ]]; then
|
||||||
echo "Getting diff..."
|
echo "Getting diff..."
|
||||||
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ADDED=$(git diff --diff-filter=A --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
COPIED=$(git diff --diff-filter=C --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
@ -32,7 +34,7 @@ else
|
|||||||
UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
UNKNOWN=$(git diff --diff-filter=X --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACM" --name-only "$HEAD_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
|
||||||
else
|
else
|
||||||
ADDED_ARRAY=()
|
ADDED_ARRAY=()
|
||||||
COPIED_ARRAY=()
|
COPIED_ARRAY=()
|
||||||
DELETED_ARRAY=()
|
DELETED_ARRAY=()
|
||||||
@ -89,8 +91,8 @@ else
|
|||||||
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g')
|
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g')
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g')
|
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g')
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Added files: $ADDED"
|
echo "Added files: $ADDED"
|
||||||
echo "Copied files: $COPIED"
|
echo "Copied files: $COPIED"
|
||||||
echo "Deleted files: $DELETED"
|
echo "Deleted files: $DELETED"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user