Narrow down target files by exact match of INPUT_FILES (#326)
This commit is contained in:
		
							parent
							
								
									00cfbecfee
								
							
						
					
					
						commit
						b94745bfeb
					
				
							
								
								
									
										42
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @ -222,22 +222,22 @@ jobs: | ||||
|           files: | | ||||
|             .github/workflows/test.yml | ||||
|             action.yml | ||||
|             test/changed-files-list.txt | ||||
|             !**/*.txt | ||||
|             **/test.txt | ||||
|             !test/test/test.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')" | ||||
|         if: "contains(steps.changed-files-specific.outputs.all_changed_files, 'test/test/test.txt')" | ||||
|         run: | | ||||
|           echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.all_changed_files }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.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')" | ||||
|         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') && !contains(steps.changed-files-specific.outputs.all_changed_files, 'test/test.txt')" | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then | ||||
|             echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})" | ||||
| @ -246,14 +246,14 @@ jobs: | ||||
|         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')" | ||||
|         if: "contains(steps.changed-files-specific.outputs.all_modified_files, 'test/test/test.txt')" | ||||
|         run: | | ||||
|           echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.all_modified_files }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.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')" | ||||
|         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') && !contains(steps.changed-files-specific.outputs.all_modified_files, 'test/test.txt')" | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific.outputs.any_modified }}" != "false" ]]; then | ||||
|             echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_modified }})" | ||||
| @ -262,14 +262,14 @@ jobs: | ||||
|         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')" | ||||
|         if: "contains(steps.changed-files-specific.outputs.deleted_files, 'test/test/test.txt')" | ||||
|         run: | | ||||
|           echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific.outputs.deleted_files }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.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')" | ||||
|         if: "!contains(steps.changed-files-specific.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.deleted_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific.outputs.deleted_files, 'test/test.txt')" | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific.outputs.any_deleted }}" != "false" ]]; then | ||||
|             echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_deleted }})" | ||||
| @ -450,9 +450,9 @@ jobs: | ||||
|           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') | ||||
|         if: contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test/test.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 }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.txt) got (${{ steps.changed-files-specific-source-file.outputs.all_changed_files }})" | ||||
|           exit 1 | ||||
|         shell: | ||||
|           bash | ||||
| @ -461,7 +461,8 @@ jobs: | ||||
|           ( | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'action.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/test.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/rebase.yml') | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/rebase.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test.txt') | ||||
|           ) | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific-source-file.outputs.any_changed }}" != "false" ]]; then | ||||
| @ -471,9 +472,9 @@ jobs: | ||||
|         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') | ||||
|         if: contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test/test.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 }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.txt) got (${{ steps.changed-files-specific-source-file.outputs.all_modified_files }})" | ||||
|           exit 1 | ||||
|         shell: | ||||
|           bash | ||||
| @ -482,7 +483,8 @@ jobs: | ||||
|           ( | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/rebase.yml') | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/rebase.yml') && | ||||
|             !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test.txt') | ||||
|           ) | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific-source-file.outputs.any_modified }}" != "false" ]]; then | ||||
| @ -492,14 +494,14 @@ jobs: | ||||
|         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') | ||||
|         if: contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test/test.txt') | ||||
|         run: | | ||||
|           echo "Invalid output: Expected not to include (test/changed-files-list.txt) got (${{ steps.changed-files-specific-source-file.outputs.deleted_files }})" | ||||
|           echo "Invalid output: Expected not to include (test/test/test.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')" | ||||
|         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') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test.txt')" | ||||
|         run: | | ||||
|           if [[ "${{ steps.changed-files-specific-source-file.outputs.any_deleted }}" != "false" ]]; then | ||||
|             echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_deleted }})" | ||||
|  | ||||
| @ -108,17 +108,17 @@ if [[ -z "${INPUT_FILES[*]}" ]]; then | ||||
| else | ||||
|   echo "Input files: $INPUT_FILES" | ||||
| 
 | ||||
|   ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   MODIFIED=$(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   RENAMED=$(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   ALL_CHANGED_AND_MODIFIED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   ALL_CHANGED=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${INPUT_FILES})" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   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}') | ||||
|   ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   MODIFIED=$(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   RENAMED=$(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   ALL_CHANGED_AND_MODIFIED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   ALL_CHANGED=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${INPUT_FILES}" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|   ALL_MODIFIED=$(git diff --diff-filter="ACMRD" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -x "${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;}' | awk '!a[$0]++' | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') | ||||
|  | ||||
| @ -2,5 +2,5 @@ | ||||
| action.yml | ||||
| action.yml | ||||
| action.yml | ||||
| test/changed-files-list.txt | ||||
| !**/*.txt | ||||
| **/test.txt | ||||
| !test/test/test.txt | ||||
|  | ||||
							
								
								
									
										1
									
								
								test/test.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/test.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| This is a test file | ||||
							
								
								
									
										1
									
								
								test/test/test.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/test/test.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| This is a test file | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Masaya Suzuki
						Masaya Suzuki