Deduplicate from files parameter without sorting (#321)
Co-authored-by: Tonye Jack <jtonye@ymail.com>
This commit is contained in:
parent
7fe764fa81
commit
13328439bc
44
.github/workflows/test.yml
vendored
44
.github/workflows/test.yml
vendored
@ -222,11 +222,20 @@ jobs:
|
||||
files: |
|
||||
.github/workflows/test.yml
|
||||
action.yml
|
||||
test/changed-files-list.txt
|
||||
!**/*.txt
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-specific.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
- name: Check if a excluded file is not included in any_changed
|
||||
if: "contains(steps.changed-files-specific.outputs.all_changed_files, 'test/changed-files-list.txt')"
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.all_changed_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_changed for specific files
|
||||
if: "!contains(steps.changed-files-specific.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.all_changed_files, '.github/workflows/test.yml')"
|
||||
run: |
|
||||
@ -236,6 +245,13 @@ jobs:
|
||||
fi
|
||||
shell:
|
||||
bash
|
||||
- name: Check if a excluded file is not included in any_modified
|
||||
if: "contains(steps.changed-files-specific.outputs.all_modified_files, 'test/changed-files-list.txt')"
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.all_modified_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_modified for specific files
|
||||
if: "!contains(steps.changed-files-specific.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.all_modified_files, '.github/workflows/test.yml')"
|
||||
run: |
|
||||
@ -245,6 +261,13 @@ jobs:
|
||||
fi
|
||||
shell:
|
||||
bash
|
||||
- name: Check if a excluded file is not included in any_deleted
|
||||
if: "contains(steps.changed-files-specific.outputs.deleted_files, 'test/changed-files-list.txt')"
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.deleted_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_deleted for specific files
|
||||
if: "!contains(steps.changed-files-specific.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.deleted_files, '.github/workflows/test.yml')"
|
||||
run: |
|
||||
@ -426,6 +449,13 @@ jobs:
|
||||
test/changed-files-list.txt
|
||||
files: |
|
||||
**/workflows/rebase.yml
|
||||
- name: Check if a excluded file is not included in any_changed
|
||||
if: contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/changed-files-list.txt')
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific-source-file.outputs.all_changed_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_changed from source files
|
||||
if: |
|
||||
(
|
||||
@ -440,6 +470,13 @@ jobs:
|
||||
fi
|
||||
shell:
|
||||
bash
|
||||
- name: Check if a excluded file is not included in any_modified
|
||||
if: contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/changed-files-list.txt')
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific-source-file.outputs.all_modified_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_modified from source files
|
||||
if: |
|
||||
(
|
||||
@ -454,6 +491,13 @@ jobs:
|
||||
fi
|
||||
shell:
|
||||
bash
|
||||
- name: Check if a excluded file is not included in any_deleted
|
||||
if: contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/changed-files-list.txt')
|
||||
run: |
|
||||
echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific-source-file.outputs.deleted_files }})"
|
||||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Verify any_deleted from source files
|
||||
if: "!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/test.yml')"
|
||||
run: |
|
||||
|
@ -121,7 +121,7 @@ else
|
||||
ALL_MODIFIED=$(git diff --diff-filter="ACMRD" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
|
||||
ALL_OTHER_CHANGED=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_CHANGED=$(echo "${ALL_CHANGED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
|
||||
if [[ -n "${UNIQUE_ALL_CHANGED}" ]]; then
|
||||
echo "Matching changed files: ${UNIQUE_ALL_CHANGED}"
|
||||
@ -151,7 +151,7 @@ else
|
||||
fi
|
||||
|
||||
ALL_OTHER_MODIFIED=$(git diff --diff-filter="ACMRD" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_MODIFIED=$(echo "${ALL_MODIFIED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
|
||||
if [[ -n "${UNIQUE_ALL_MODIFIED}" ]]; then
|
||||
echo "Matching modified files: ${UNIQUE_ALL_MODIFIED}"
|
||||
@ -181,7 +181,7 @@ else
|
||||
fi
|
||||
|
||||
ALL_OTHER_DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_DELETED=$(echo "${DELETED}" | awk '{gsub(/\|/,"\n"); print $0;}' | sort -u | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
UNIQUE_ALL_DELETED=$(echo "${DELETED}" | awk '{gsub(/\|/,"\n"); print $0;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')
|
||||
|
||||
if [[ -n "${UNIQUE_ALL_DELETED}" ]]; then
|
||||
echo "Matching deleted files: ${UNIQUE_ALL_DELETED}"
|
||||
|
@ -15,13 +15,13 @@ if [[ -n $INPUT_FILES_FROM_SOURCE_FILE ]]; then
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=" " read -r -a CLEAN_FILES <<< "$(echo "${RAW_FILES[*]}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
IFS=" " read -r -a CLEAN_FILES <<< "$(echo "${RAW_FILES[*]}" | tr "\r\n" "\n" | tr " " "\n" | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
IFS=" " read -r -a CLEAN_INPUT_FILES <<< "$(echo "${INPUT_FILES}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
IFS=" " read -r -a CLEAN_INPUT_FILES <<< "$(echo "${INPUT_FILES}" | tr "\r\n" "\n" | tr " " "\n" | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
FILES=("${CLEAN_FILES[@]}" "${CLEAN_INPUT_FILES[@]}")
|
||||
|
||||
IFS=" " read -r -a ALL_UNIQUE_FILES <<< "$(echo "${FILES[@]}" | tr "\r\n" "\n" | tr " " "\n" | sort -u | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
IFS=" " read -r -a ALL_UNIQUE_FILES <<< "$(echo "${FILES[@]}" | tr "\r\n" "\n" | tr " " "\n" | awk '!a[$0]++' | awk -v d=" " '{s=(NR==1?s:s d)$0}END{print s}')"
|
||||
|
||||
echo "Input files: ${ALL_UNIQUE_FILES[*]}"
|
||||
|
||||
|
@ -2,4 +2,5 @@
|
||||
action.yml
|
||||
action.yml
|
||||
action.yml
|
||||
!*.txt
|
||||
test/changed-files-list.txt
|
||||
!**/*.txt
|
||||
|
Loading…
x
Reference in New Issue
Block a user