2021-03-04 21:36:52 -05:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
2021-04-23 06:14:21 -04:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2021-05-25 00:30:19 -04:00
|
|
|
- '**'
|
2021-03-04 21:36:52 -05:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
2021-06-18 10:19:28 -04:00
|
|
|
shellcheck:
|
|
|
|
name: Run shellcheck
|
2021-05-25 00:30:19 -04:00
|
|
|
runs-on: ubuntu-latest
|
2021-06-18 10:19:28 -04:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout to branch
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: shellcheck
|
2021-06-26 14:34:44 +00:00
|
|
|
uses: reviewdog/action-shellcheck@v1.6
|
2021-06-18 10:19:28 -04:00
|
|
|
|
|
|
|
test-no-head-sha:
|
2021-05-25 00:30:19 -04:00
|
|
|
name: Test changed-files missing head sha
|
2021-06-18 10:19:28 -04:00
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2021-06-18 19:09:00 -04:00
|
|
|
platform: [ubuntu-latest, windows-latest, macos-latest]
|
2021-06-18 10:19:28 -04:00
|
|
|
|
2021-05-25 00:30:19 -04:00
|
|
|
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) }}"
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-05-25 00:30:19 -04:00
|
|
|
|
2021-03-04 21:36:52 -05:00
|
|
|
test:
|
|
|
|
name: Test changed-files
|
2021-06-18 10:19:28 -04:00
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2021-06-18 19:09:00 -04:00
|
|
|
platform: [ubuntu-latest, windows-latest, macos-latest]
|
2021-06-18 10:19:28 -04:00
|
|
|
|
2021-03-04 21:36:52 -05:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2021-06-18 10:19:28 -04:00
|
|
|
uses: actions/checkout@v2
|
2021-04-23 06:17:20 -04:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2021-03-05 07:28:53 -05:00
|
|
|
- name: Run changed-files with defaults
|
2021-03-04 22:36:52 -05:00
|
|
|
id: changed-files
|
2021-03-04 21:36:52 -05:00
|
|
|
uses: ./
|
2021-03-04 22:36:52 -05:00
|
|
|
- name: Show output
|
|
|
|
run: |
|
2021-03-05 06:17:27 -05:00
|
|
|
echo "${{ toJSON(steps.changed-files.outputs) }}"
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-03-25 19:23:19 -04:00
|
|
|
- name: List all modified files
|
2021-03-20 08:09:58 -04:00
|
|
|
run: |
|
2021-03-25 19:23:19 -04:00
|
|
|
for file in "${{ steps.changed-files.outputs.modified_files }}"; do
|
2021-03-20 08:09:58 -04:00
|
|
|
echo $file
|
|
|
|
done
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-04-02 08:27:48 -04:00
|
|
|
- name: Run step when README.md changes
|
2021-04-02 09:00:06 -04:00
|
|
|
if: contains(steps.changed-files.outputs.modified_files, 'README.md')
|
2021-04-02 08:27:48 -04:00
|
|
|
run: |
|
2021-04-02 09:12:33 -04:00
|
|
|
echo "Your README.md has been modified ${{ steps.changed-files.outputs.modified_files }}."
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-03-05 07:28:53 -05:00
|
|
|
- name: Run changed-files with comma separator
|
|
|
|
id: changed-files-comma
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
separator: ","
|
|
|
|
- name: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-comma.outputs) }}"
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-05-01 07:55:01 -04:00
|
|
|
- name: Run changed-files with specific files
|
|
|
|
id: changed-files-specific
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.github/workflows/test.yml
|
2021-05-01 19:58:35 -04:00
|
|
|
action.yml
|
2021-05-16 16:26:22 -04:00
|
|
|
- name: Verify any_changed files
|
2021-05-17 04:26:35 -04:00
|
|
|
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')"
|
2021-05-16 16:26:22 -04:00
|
|
|
run: |
|
2021-05-17 04:19:10 -04:00
|
|
|
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
|
|
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
|
2021-05-16 16:26:22 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-05-01 07:55:01 -04:00
|
|
|
- name: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-05-01 08:59:18 -04:00
|
|
|
- name: Run changed-files with specific files comma separator
|
|
|
|
id: changed-files-specific-comma
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.github/workflows/test.yml
|
2021-05-01 19:58:35 -04:00
|
|
|
action.yml
|
2021-05-01 08:59:18 -04:00
|
|
|
separator: ","
|
2021-07-17 10:51:08 -04:00
|
|
|
- name: Verify any_changed 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.outputs.any_changed }}" != "false" ]]; then
|
|
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shell:
|
|
|
|
bash
|
|
|
|
- name: Run changed-files with specific files from a source file
|
|
|
|
id: changed-files-specific-source-file
|
|
|
|
uses: ./
|
|
|
|
with:
|
2021-07-17 11:46:59 -04:00
|
|
|
files_from_source_file: |
|
2021-07-17 10:51:08 -04:00
|
|
|
test/changed-files-list.txt
|
|
|
|
test/changed-files-list.txt
|
|
|
|
files: |
|
|
|
|
.github/workflows/rebase.yml
|
|
|
|
- name: Verify any_changed 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: |
|
|
|
|
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: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-specific.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:
|
2021-07-17 11:46:59 -04:00
|
|
|
files_from_source_file: |
|
2021-07-17 10:51:08 -04:00
|
|
|
test/changed-files-list.txt
|
|
|
|
separator: ","
|
2021-05-17 04:02:50 -04:00
|
|
|
- name: Verify any_changed files comma separator
|
2021-05-17 04:19:10 -04:00
|
|
|
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')"
|
2021-05-17 04:02:50 -04:00
|
|
|
run: |
|
2021-05-17 04:19:10 -04:00
|
|
|
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
|
|
|
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
|
2021-05-17 04:02:50 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-05-01 08:59:18 -04:00
|
|
|
- name: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}"
|
2021-06-18 10:19:28 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-07-14 23:57:17 +03:00
|
|
|
- name: Run changed-files with custom sha
|
|
|
|
id: changed-files-custom-sha
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
sha: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-custom-sha.outputs) }}"
|
|
|
|
shell:
|
|
|
|
bash
|
2021-07-17 11:46:59 -04:00
|
|
|
- name: Get branch name
|
|
|
|
id: branch-name
|
|
|
|
uses: tj-actions/branch-names@v4.5
|
|
|
|
- uses: nrwl/last-successful-commit-action@v1
|
|
|
|
id: last_successful_commit
|
|
|
|
with:
|
|
|
|
branch: ${{ steps.branch-name.outputs.base_ref_branch }}
|
|
|
|
workflow_id: 'test.yml'
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Run changed-files with a custom base sha
|
|
|
|
id: changed-files-custom-base-sha
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }}
|
|
|
|
- name: Show output
|
|
|
|
run: |
|
2021-07-17 11:54:59 -04:00
|
|
|
echo "${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}"
|
2021-07-17 11:46:59 -04:00
|
|
|
shell:
|
|
|
|
bash
|
2021-07-17 15:13:26 -04:00
|
|
|
- name: Run changed-files with specific files (only-changed)
|
|
|
|
id: changed-files-specific-only-changed
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
.github/workflows/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: Show output
|
|
|
|
run: |
|
|
|
|
echo "${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}"
|
|
|
|
shell:
|
|
|
|
bash
|