mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-21 03:30:38 +00:00
1016 lines
39 KiB
YAML
1016 lines
39 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- "**"
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
branches:
|
|
- main
|
|
pull_request_review:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
shellcheck:
|
|
name: Run shellcheck
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
- name: shellcheck
|
|
uses: reviewdog/action-shellcheck@v1.16
|
|
|
|
test-multiple-repositories:
|
|
name: Test with multiple repositories
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 2
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
steps:
|
|
- name: Checkout into dir1
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
fetch-depth: 0
|
|
path: dir1
|
|
- name: Run changed-files with defaults on the dir1
|
|
id: changed-files-dir1
|
|
uses: ./dir1
|
|
with:
|
|
path: dir1
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-dir1.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: List all modified files
|
|
run: |
|
|
for file in ${{ steps.changed-files-dir1.outputs.modified_files }}; do
|
|
echo "$file"
|
|
done
|
|
shell:
|
|
bash
|
|
- name: Checkout into dir2
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
fetch-depth: 0
|
|
path: dir2
|
|
- name: Run changed-files with defaults on the dir2
|
|
id: changed-files-dir2
|
|
uses: ./dir2
|
|
with:
|
|
path: dir2
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-dir2.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: List all modified files
|
|
run: |
|
|
for file in ${{ steps.changed-files-dir2.outputs.modified_files }}; do
|
|
echo "$file"
|
|
done
|
|
shell:
|
|
bash
|
|
|
|
test-using-since-and-until:
|
|
name: Test changed-files using since and until
|
|
runs-on: ${{ matrix.platform }}
|
|
if: github.event_name == 'push'
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 2
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run changed-files since 2022-08-19
|
|
id: changed-files-since
|
|
uses: ./
|
|
with:
|
|
since: "2022-08-19"
|
|
|
|
- name: Check output
|
|
if: "!contains(steps.changed-files-since.outputs.all_changed_files, '.github/workflows/sync-release-version.yml')"
|
|
run: |
|
|
echo "Invalid output: Expected to include (.github/workflows/sync-release-version.yml) got (${{ steps.changed-files-since.outputs.all_changed_files }})"
|
|
exit 1
|
|
shell:
|
|
bash
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-since.outputs) }}'
|
|
shell:
|
|
bash
|
|
|
|
- name: Run changed-files until 2022-08-20
|
|
id: changed-files-until
|
|
uses: ./
|
|
with:
|
|
until: "2022-08-20"
|
|
|
|
- name: Check output
|
|
if: "!contains(steps.changed-files-until.outputs.all_changed_files, 'README.md')"
|
|
run: |
|
|
echo "Invalid output: Expected to include (README.md) got (${{ steps.changed-files-until.outputs.all_changed_files }})"
|
|
exit 1
|
|
shell:
|
|
bash
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-until.outputs) }}'
|
|
shell:
|
|
bash
|
|
|
|
test-similar-base-and-commit-sha:
|
|
name: Test changed-files similar base and commit sha
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run changed-files with similar base and commit sha
|
|
id: changed-files
|
|
continue-on-error: true
|
|
uses: ./
|
|
with:
|
|
base_sha: d1c0ee4
|
|
sha: d1c0ee4
|
|
|
|
- name: Exit with 1 if no error is raised
|
|
if: steps.changed-files.outcome != 'failure'
|
|
run: |
|
|
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
|
|
exit 1
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
|
shell:
|
|
bash
|
|
|
|
test-unset-github-output-env:
|
|
name: Test unset GITHUB_OUTPUT env
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run changed-files with unset GITHUB_OUTPUT env
|
|
id: changed-files
|
|
continue-on-error: true
|
|
uses: ./
|
|
env:
|
|
GITHUB_OUTPUT: ""
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
|
shell:
|
|
bash
|
|
|
|
test-limited-commit-history:
|
|
name: Test changed-files with limited commit history
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
fetch-depth: [1, 2]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: ${{ matrix.fetch-depth }}
|
|
|
|
- name: Run changed-files
|
|
id: changed-files
|
|
uses: ./
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
|
shell:
|
|
bash
|
|
|
|
test-non-existent-base-sha:
|
|
name: Test changed-files non existent base sha
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Run changed-files with non existent base sha
|
|
id: changed-files
|
|
uses: ./
|
|
continue-on-error: true
|
|
with:
|
|
base_sha: "4554456"
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
|
shell:
|
|
bash
|
|
|
|
- name: Exit with 1 if no error is raised
|
|
if: steps.changed-files.outcome != 'failure'
|
|
run: |
|
|
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
|
|
exit 1
|
|
|
|
- name: Run changed-files-specific with non existent base sha
|
|
id: changed-files-specific
|
|
uses: ./
|
|
continue-on-error: true
|
|
with:
|
|
files: action.yml
|
|
base_sha: "4554456"
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
|
|
shell:
|
|
bash
|
|
|
|
- name: Exit with 1 if no error is raised
|
|
if: steps.changed-files-specific.outcome != 'failure'
|
|
run: |
|
|
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
|
|
exit 1
|
|
|
|
test-non-existent-sha:
|
|
name: Test changed-files non existent sha
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest]
|
|
|
|
steps:
|
|
- name: Checkout to branch
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Run changed-files with non existent sha
|
|
id: changed-files
|
|
uses: ./
|
|
continue-on-error: true
|
|
with:
|
|
sha: "4774456"
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
|
shell:
|
|
bash
|
|
|
|
- name: Exit with 1 if no error is raised
|
|
if: steps.changed-files.outcome != 'failure'
|
|
run: |
|
|
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
|
|
exit 1
|
|
|
|
- name: Run changed-files-specific with non existent sha
|
|
id: changed-files-specific
|
|
uses: ./
|
|
continue-on-error: true
|
|
with:
|
|
files: action.yml
|
|
sha: "4774456"
|
|
|
|
- name: Show output
|
|
run: |
|
|
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
|
|
shell:
|
|
bash
|
|
|
|
- name: Exit with 1 if no error is raised
|
|
if: steps.changed-files-specific.outcome != 'failure'
|
|
run: |
|
|
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
|
|
exit 1
|
|
|
|
test:
|
|
name: Test changed-files
|
|
runs-on: ${{ matrix.platform }}
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
platform: [ubuntu-latest, ubuntu-22.04, windows-latest, macos-latest, macos-11, windows-2022]
|
|
fetch-depth: [0, 1]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
fetch-depth: ${{ matrix.fetch-depth }}
|
|
- name: Dump GitHub context
|
|
env:
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
run: echo "$GITHUB_CONTEXT"
|
|
- name: Run changed-files with defaults
|
|
id: changed-files
|
|
uses: ./
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with since_last_remote_commit
|
|
id: changed-files-since-last-remote-commit
|
|
uses: ./
|
|
with:
|
|
since_last_remote_commit: true
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with write_output_files
|
|
id: changed-files-write-output-files
|
|
uses: ./
|
|
with:
|
|
json: true
|
|
write_output_files: true
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-write-output-files.outputs.all_changed_files) }}'
|
|
cat .github/outputs/all_changed_files.json
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with include_all_old_new_renamed_files
|
|
id: changed-files-all-old-new-renamed-files
|
|
uses: ./
|
|
with:
|
|
include_all_old_new_renamed_files: true
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-all-old-new-renamed-files.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: List all modified files
|
|
run: |
|
|
for file in ${{ steps.changed-files.outputs.modified_files }}; do
|
|
echo $file
|
|
done
|
|
shell:
|
|
bash
|
|
- name: Run step when README.md changes
|
|
if: contains(steps.changed-files.outputs.modified_files, 'README.md')
|
|
run: |
|
|
echo "Your README.md has been modified ${{ steps.changed-files.outputs.modified_files }}."
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with quotepath disabled for single path
|
|
id: changed-files-quotepath-specific
|
|
uses: ./
|
|
with:
|
|
files: test/test-è.txt
|
|
quotepath: "false"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-quotepath-specific.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with quotepath disabled
|
|
id: changed-files-quotepath
|
|
uses: ./
|
|
with:
|
|
quotepath: "false"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-quotepath.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with dir_names and dir_names_max_depth
|
|
id: changed-files-dir-names-max-depth
|
|
uses: ./
|
|
with:
|
|
base_sha: ba788ed
|
|
sha: 0a5b7c6
|
|
fetch_depth: 60000
|
|
dir_names: "true"
|
|
dir_names_max_depth: 3
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-dir-names-max-depth.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Check dir_names output
|
|
if: "!contains(steps.changed-files-dir-names-max-depth.outputs.all_changed_files, 'test/test2/test3')"
|
|
run: |
|
|
echo "Invalid output: Expected to include (test/test2/test3) got (${{ steps.changed-files-dir-names-max-depth.outputs.all_changed_files }})"
|
|
exit 1
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with dir_names
|
|
id: changed-files-dir-names
|
|
uses: ./
|
|
with:
|
|
base_sha: d1c0ee4
|
|
sha: 4d04215
|
|
fetch_depth: 60000
|
|
dir_names: "true"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-dir-names.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Check dir_names output
|
|
if: "!contains(steps.changed-files-dir-names.outputs.all_changed_files, 'test')"
|
|
run: |
|
|
echo "Invalid output: Expected to include (test) got (${{ steps.changed-files-dir-names.outputs.all_changed_files }})"
|
|
exit 1
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with dir_names specific
|
|
id: changed-files-dir-names-specific
|
|
uses: ./
|
|
with:
|
|
base_sha: d1c0ee4
|
|
sha: 4d04215
|
|
fetch_depth: 60000
|
|
dir_names: "true"
|
|
files: test/**
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-dir-names-specific.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Check dir_names output
|
|
if: "!contains(steps.changed-files-dir-names-specific.outputs.all_changed_files, 'test')"
|
|
run: |
|
|
echo "Invalid output: Expected to include (test) got (${{ steps.changed-files-dir-names-specific.outputs.all_changed_files }})"
|
|
exit 1
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with forward slash separator
|
|
id: changed-files-forward-slash
|
|
uses: ./
|
|
with:
|
|
separator: "/"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-forward-slash.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with newline separator
|
|
id: changed-files-newline
|
|
uses: ./
|
|
with:
|
|
separator: "\n"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-newline.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with pipe separator
|
|
id: changed-files-pipe
|
|
uses: ./
|
|
with:
|
|
separator: "|"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-pipe.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with json output
|
|
id: changed-files-json
|
|
uses: ./
|
|
with:
|
|
json: true
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-json.outputs) }}'
|
|
echo '${{ toJSON(steps.changed-files-json.outputs.all_changed_files) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with json raw format
|
|
id: changed-files-json-raw-format
|
|
uses: ./
|
|
with:
|
|
json: true
|
|
json_raw_format: true
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-json-raw-format.outputs) }}'
|
|
echo '${{ toJSON(steps.changed-files-json-raw-format.outputs.all_changed_files) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with comma separator
|
|
id: changed-files-comma
|
|
uses: ./
|
|
with:
|
|
separator: ","
|
|
- name: List all modified files
|
|
run: |
|
|
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files-comma.outputs.modified_files }}"
|
|
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
|
|
echo $file
|
|
done
|
|
unset IFS
|
|
shell:
|
|
bash
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-comma.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files from a source file using a newline separator
|
|
id: changed-files-specific-newline-source-file
|
|
uses: ./
|
|
with:
|
|
files_from_source_file: |
|
|
test/changed-files-list.txt
|
|
separator: "\n"
|
|
- name: Show output
|
|
run: |
|
|
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
|
|
fetch_depth: 60000
|
|
include_all_old_new_renamed_files: true
|
|
- 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
|
|
fetch_depth: 60000
|
|
include_all_old_new_renamed_files: true
|
|
- 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: ./
|
|
with:
|
|
files: |
|
|
.github/workflows/test.yml
|
|
action.yml
|
|
**/test.txt
|
|
files_ignore: |
|
|
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/test/test.txt')"
|
|
run: |
|
|
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') && !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 }})"
|
|
exit 1
|
|
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/test/test.txt')"
|
|
run: |
|
|
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') && !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 }})"
|
|
exit 1
|
|
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/test/test.txt')"
|
|
run: |
|
|
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') && !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 }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files comma check duplicates
|
|
id: changed-files-specific-duplicate-output
|
|
uses: ./
|
|
with:
|
|
files: |
|
|
get-changed-paths.sh
|
|
*.sh
|
|
- name: Verify all_changed_files files has no duplicates
|
|
if: contains(steps.changed-files-specific-duplicate-output.outputs.all_changed_files, 'get-changed-paths.sh')
|
|
run: |
|
|
ALL_CHANGED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_changed_files }})
|
|
UNIQUE_ALL_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | sort -u | xargs)
|
|
|
|
if [[ "$ALL_CHANGED_FILES[@]" != "$UNIQUE_ALL_CHANGED_FILES[@]" ]]; then
|
|
echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_FILES" got $ALL_CHANGED_FILES"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify all_changed_and_modified_files files has no duplicates
|
|
if: contains(steps.changed-files-specific-duplicate-output.outputs.all_changed_and_modified_files, 'get-changed-paths.sh')
|
|
run: |
|
|
ALL_CHANGED_AND_MODIFIED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_changed_and_modified_files }})
|
|
UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES=$(echo "$ALL_CHANGED_AND_MODIFIED_FILES" | tr ' ' '\n' | sort -u | xargs)
|
|
|
|
if [[ "$ALL_CHANGED_AND_MODIFIED_FILES[@]" != "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES[@]" ]]; then
|
|
echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES" got $ALL_CHANGED_AND_MODIFIED_FILES"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify all_modified_files files has no duplicates
|
|
if: contains(steps.changed-files-specific-duplicate-output.outputs.all_modified_files, 'get-changed-paths.sh')
|
|
run: |
|
|
ALL_MODIFIED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_modified_files }})
|
|
UNIQUE_ALL_MODIFIED_FILES=$(echo "$ALL_MODIFIED_FILES" | tr ' ' '\n' | sort -u | xargs)
|
|
|
|
if [[ "$ALL_MODIFIED_FILES[@]" != "$UNIQUE_ALL_MODIFIED_FILES[@]" ]]; then
|
|
echo "Duplicate output: Expected "$UNIQUE_ALL_MODIFIED_FILES" got $ALL_MODIFIED_FILES"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files comma separator
|
|
id: changed-files-specific-comma
|
|
uses: ./
|
|
with:
|
|
files: |
|
|
.github/workflows/test.yml
|
|
action.yml
|
|
separator: ","
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-comma.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Verify any_changed files comma separator
|
|
if: "!contains(steps.changed-files-specific-comma.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.all_changed_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma.outputs.any_changed }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_changed }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_modified files comma separator
|
|
if: "!contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma.outputs.any_modified }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_modified }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_deleted files comma separator
|
|
if: "!contains(steps.changed-files-specific-comma.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.deleted_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma.outputs.any_deleted }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_deleted }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files pipe separator
|
|
id: changed-files-specific-pipe
|
|
uses: ./
|
|
with:
|
|
files: |
|
|
**/test.yml
|
|
action.yml
|
|
separator: "|"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-pipe.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Verify any_changed files comma separator
|
|
if: "!contains(steps.changed-files-specific-pipe.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.all_changed_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-pipe.outputs.any_changed }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_changed }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_modified files comma separator
|
|
if: "!contains(steps.changed-files-specific-pipe.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.all_modified_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-pipe.outputs.any_modified }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_modified }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_deleted files comma separator
|
|
if: "!contains(steps.changed-files-specific-pipe.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.deleted_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-pipe.outputs.any_deleted }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_deleted }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files forward slash separator
|
|
id: changed-files-specific-forward-slash
|
|
uses: ./
|
|
with:
|
|
files: |
|
|
.github/workflows/test.yml
|
|
action.yml
|
|
separator: "/"
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-forward-slash.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Verify any_changed files forward slash separator
|
|
if: "!contains(steps.changed-files-specific-forward-slash.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.all_changed_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-forward-slash.outputs.any_changed }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_changed }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_modified files forward slash separator
|
|
if: "!contains(steps.changed-files-specific-forward-slash.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.all_modified_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-forward-slash.outputs.any_modified }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_modified }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_deleted files forward slash separator
|
|
if: "!contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, '.github/workflows/test.yml')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-forward-slash.outputs.any_deleted }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_deleted }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files from a source file
|
|
id: changed-files-specific-source-file
|
|
uses: ./
|
|
with:
|
|
files_from_source_file: |
|
|
test/changed-files-list.txt
|
|
test/changed-files-list.txt
|
|
files: |
|
|
**/workflows/greetings.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/test/test.txt')
|
|
run: |
|
|
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
|
|
- name: Verify any_changed from source files
|
|
if: |
|
|
(
|
|
!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/greetings.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
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_changed }})"
|
|
exit 1
|
|
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/test/test.txt')
|
|
run: |
|
|
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
|
|
- name: Verify any_modified from source files
|
|
if: |
|
|
(
|
|
!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/greetings.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
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_modified }})"
|
|
exit 1
|
|
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/test/test.txt')
|
|
run: |
|
|
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') && !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 }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-source-file.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files from a source file using a comma separator
|
|
id: changed-files-specific-comma-source-file
|
|
uses: ./
|
|
with:
|
|
files_from_source_file: |
|
|
test/changed-files-list.txt
|
|
separator: ","
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-comma-source-file.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Verify any_changed files comma separator
|
|
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.all_changed_files, 'test/test.txt')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_modified files comma separator
|
|
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'test/test.txt')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify any_deleted files with comma separator
|
|
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.deleted_files, 'test/test.txt')"
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with custom sha
|
|
id: changed-files-custom-sha
|
|
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
|
uses: ./
|
|
with:
|
|
sha: ${{ github.event.pull_request.head.sha }}
|
|
- name: Show output
|
|
if: github.event.action != 'closed'
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Get branch name
|
|
id: branch-name
|
|
uses: tj-actions/branch-names@v6
|
|
if: github.event_name == 'pull_request' && matrix.fetch-depth == 0
|
|
- uses: nrwl/nx-set-shas@v3
|
|
id: last_successful_commit
|
|
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
|
|
with:
|
|
main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }}
|
|
workflow-id: 'test.yml'
|
|
- name: Run changed-files with a custom base sha
|
|
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
|
|
id: changed-files-custom-base-sha
|
|
uses: ./
|
|
with:
|
|
base_sha: ${{ steps.last_successful_commit.outputs.base }}
|
|
- name: Show output
|
|
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}'
|
|
shell:
|
|
bash
|
|
- name: Run changed-files with specific files (only-changed)
|
|
id: changed-files-specific-only-changed
|
|
uses: ./
|
|
with:
|
|
files: |
|
|
.github/**/test.yml
|
|
- name: Verify only_changed files
|
|
if: steps.changed-files-specific-only-changed.outputs.other_changed_files != ''
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_changed }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_changed }})"
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Verify only_deleted files
|
|
if: steps.changed-files-specific-only-changed.outputs.other_deleted_files != ''
|
|
run: |
|
|
if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_deleted }}" != "false" ]]; then
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_deleted }})."
|
|
exit 1
|
|
fi
|
|
shell:
|
|
bash
|
|
- name: Show output
|
|
run: |
|
|
echo '${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}'
|
|
shell:
|
|
bash
|