diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60267d27..3e675d0c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - "**" pull_request: branches: - main @@ -19,7 +18,7 @@ jobs: uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1.15 - + test-pull-requests-from-forks: name: Test changed-files diff on pull_requests from forks runs-on: ${{ matrix.platform }} @@ -141,7 +140,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent base sha id: changed-files-specific uses: ./ @@ -181,7 +180,7 @@ jobs: echo "${{ toJSON(steps.changed-files.outputs) }}" shell: bash - + - name: Run changed-files-specific with non existent sha id: changed-files-specific uses: ./ @@ -294,42 +293,6 @@ jobs: echo '${{ toJSON(steps.changed-files-specific-newline-source-file.outputs) }}' shell: bash - - name: Run changed-files for old new filenames test rename 1 - id: changed-files-all-old-new-renamed-files-1 - uses: ./ - with: - base_sha: d1c0ee4 - sha: 4d04215 - - name: Show output - run: | - echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-1.outputs) }}' - shell: - bash - - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files, 'test/test rename 1.txt,test/test rename-1.txt')" - run: | - echo "Invalid output: Expected to include (test/test rename 1.txt,test/test rename-1.txt) got (${{ steps.changed-files-all-old-new-renamed-files-1.outputs.all_old_new_renamed_files }})" - exit 1 - shell: - bash - - name: Run changed-files for old new filenames test rename 2 - id: changed-files-all-old-new-renamed-files-2 - uses: ./ - with: - base_sha: 4d04215 - sha: fe238e6 - - name: Show output - run: | - echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files-2.outputs) }}' - shell: - bash - - name: Check all_old_new_renamed_files output - if: "!contains(steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files, 'test/test rename 2.txt,test/test rename-2.txt')" - run: | - echo "Invalid output: Expected to include (test/test rename 2.txt test/test rename-2.txt) got (${{ steps.changed-files-all-old-new-renamed-files-2.outputs.all_old_new_renamed_files }})" - exit 1 - shell: - bash - name: Run changed-files with specific files id: changed-files-specific uses: ./ diff --git a/README.md b/README.md index 1802ec44..85fc018c 100644 --- a/README.md +++ b/README.md @@ -100,38 +100,35 @@ Support this project with a :star: | U | Unmerged | | X | Unknown | -| Output | type | example | description | -|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | -| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | -| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | -| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | -| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | -| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | -| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | -| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | -| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | -| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | -| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | -| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | -| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | -| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | -| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | -| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | -| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | -| all_old_new_renamed_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Select only files that are Renamed and list their old and new names (R) | -| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | -| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | -| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | +| Output | type | example | description | +|:----------------------------------:|:--------:|:--------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* | +| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. (ACMR) | +| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files
not listed in the files input
i.e. *a combination of all added,
copied and modified files (ACMR)* | +| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* | +| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. (ACMRD) | +| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* | +| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. (D) | +| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. (D) | +| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* | +| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* | +| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* | +| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed
and modified files
i.e. *a combination of (ACMRDTUX)* | +| added\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) | +| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) | +| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) | +| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Modified (M) | +| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Renamed (R) | +| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that have their file type changed (T) | +| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unmerged (U) | +| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Unknown (X) | ## Inputs | Input | type | required | default | description | |:---------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | token | `string` | `false` | `${{ github.token }}` | [GITHUB\_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow)
or a repo scoped
[Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | -| separator | `string` | `false` | `' '` | Split character for output strings | -| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs | -| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs | +| separator | `string` | `true` | `' '` | Output string separator | | files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo) | | files\_separator | string | `false` | `'\n'` | Separator used to split the
`files` input | | files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input | @@ -141,9 +138,9 @@ Support this project with a :star: | sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes | | base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes | | path | `string` | `false` | | Relative path under
`GITHUB_WORKSPACE`
to the repository | -| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | -| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | -| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | +| since\_last\_remote\_commit | `string` | `false` | `false` | Use the last commit on the remote
branch as the `base_sha`
(Defaults to the last commit
on the target branch for Pull requests
or the previous commit
on the current branch
for push events).
NOTE: This requires
`fetch-depth: 0`
with `actions/checkout@v2` | +| use\_fork\_point | `string` | `false` | `false` | Finds best common ancestor
between two commits
to use in a three-way merge
as the `base_sha`
See: [git merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---fork-point).
NOTE: This pulls the entire commit history of the base branch | +| quotepath | `string` | `false` | `true` | Output filenames completely verbatim by setting this to `false` | ## Example diff --git a/action.yml b/action.yml index fd10f53a..d59b9339 100644 --- a/action.yml +++ b/action.yml @@ -5,19 +5,11 @@ author: tj-actions inputs: token: description: 'Github token' - required: false + required: true default: ${{ github.token }} separator: - description: 'Split character for output strings' - required: false - default: " " - old_new_separator: - description: 'Split character for old and new filename pairs' - required: false - default: "," - old_new_files_separator: - description: 'Split character for multiple old and new filename pairs' - required: false + description: 'Split character for array output' + required: true default: " " files_from_source_file: description: 'Source file(s) to populate the files input' @@ -82,9 +74,6 @@ outputs: renamed_files: description: List of renamed files. value: ${{ steps.changed-files.outputs.renamed_files }} - all_old_new_renamed_files: - description: List of all old and new names of renamed files. - value: ${{ steps.changed-files.outputs.all_old_new_renamed_files }} type_changed_files: description: List of files that had type changes. value: ${{ steps.changed-files.outputs.type_changed_files }} @@ -193,8 +182,6 @@ runs: INPUT_TARGET_BRANCH: ${{ steps.changed-files-diff-sha.outputs.target_branch }} INPUT_CURRENT_BRANCH: ${{ steps.changed-files-diff-sha.outputs.current_branch }} INPUT_QUOTEPATH: ${{ inputs.quotepath }} - INPUT_OLD_NEW_SEPARATOR: ${{ inputs.old_new_separator }} - INPUT_OLD_NEW_FILES_SEPARATOR: ${{ inputs.old_new_files_separator }} branding: icon: file-text diff --git a/entrypoint.sh b/entrypoint.sh index 69301e3d..d15f1f0d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -78,7 +78,6 @@ if [[ -z "$INPUT_FILES_PATTERN_FILE" ]]; then ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') - ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') else ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') COPIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" C | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') @@ -91,7 +90,6 @@ else ALL_CHANGED_AND_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "*ACDMRTUX" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') ALL_MODIFIED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMRD" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}') - ALL_OLD_NEW_RENAMED_FILES=$(get_renames "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" | grep -x -E -f "$INPUT_FILES_PATTERN_FILE" | awk -v d="$INPUT_OLD_NEW_FILES_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}') ALL_OTHER_CHANGED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" "ACMR" | 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}') @@ -209,7 +207,6 @@ echo "Unknown files: $UNKNOWN" echo "All changed and modified files: $ALL_CHANGED_AND_MODIFIED" echo "All changed files: $ALL_CHANGED" echo "All modified files: $ALL_MODIFIED" -echo "All old & new renamed files: $ALL_OLD_NEW_RENAMED_FILES" echo "::set-output name=added_files::$ADDED" echo "::set-output name=copied_files::$COPIED" @@ -222,6 +219,5 @@ echo "::set-output name=unknown_files::$UNKNOWN" echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED" echo "::set-output name=all_changed_files::$ALL_CHANGED" echo "::set-output name=all_modified_files::$ALL_MODIFIED" -echo "::set-output name=all_old_new_renamed_files::$ALL_OLD_NEW_RENAMED_FILES" echo "::endgroup::" diff --git a/test/test rename 1.txt b/test/test rename 1.txt deleted file mode 100644 index 6de7b8c6..00000000 --- a/test/test rename 1.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file. diff --git a/test/test rename 2.txt b/test/test rename 2.txt deleted file mode 100644 index 6de7b8c6..00000000 --- a/test/test rename 2.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file.