mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-16 19:27:39 +00:00
fix: raise errors when unable to locate the previous commit in local history (#1551)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
534262e0b2
commit
796ac2d08f
4 changed files with 69 additions and 29 deletions
94
.github/workflows/test.yml
vendored
94
.github/workflows/test.yml
vendored
|
@ -37,7 +37,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
- name: shellcheck
|
||||
uses: reviewdog/action-shellcheck@v1.19
|
||||
|
||||
|
@ -46,7 +46,7 @@ jobs:
|
|||
outputs:
|
||||
files_changed: ${{ steps.changed_files.outputs.files_changed }}
|
||||
steps:
|
||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
@ -123,7 +123,7 @@ jobs:
|
|||
if: needs.build.outputs.files_changed != 'true'
|
||||
steps:
|
||||
- name: Checkout into dir1
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
|
@ -163,7 +163,7 @@ jobs:
|
|||
path: dir2/dist
|
||||
|
||||
- name: Checkout into dir2
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
|
@ -198,7 +198,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
@ -256,7 +256,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
@ -294,7 +294,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
@ -332,7 +332,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
|
@ -364,7 +364,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
|
@ -396,7 +396,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
persist-credentials: false
|
||||
|
@ -425,7 +425,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
|
@ -479,7 +479,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
|
@ -534,7 +534,7 @@ jobs:
|
|||
pull-requests: read
|
||||
steps:
|
||||
- name: Checkout into dir1
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
|
@ -570,7 +570,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
submodules: recursive
|
||||
|
@ -613,7 +613,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
submodules: recursive
|
||||
|
@ -665,7 +665,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
submodules: recursive
|
||||
|
@ -805,6 +805,56 @@ jobs:
|
|||
else
|
||||
cat "deleted_files/test/test deleted.txt"
|
||||
fi
|
||||
|
||||
test-since-last-remote-commit:
|
||||
name: Test changed-files since last remote commit
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: needs.build.outputs.files_changed != 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
fetch-depth: [0, 1, 2]
|
||||
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-assets
|
||||
|
||||
- name: Run changed-files with since_last_remote_commit
|
||||
id: changed-files-since-last-remote-commit
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
since_last_remote_commit: true
|
||||
|
||||
- name: Verify failed
|
||||
if: steps.changed-files-since-last-remote-commit.outcome != 'failure' && matrix.fetch-depth == 1 && github.event_name != 'push'
|
||||
run: |
|
||||
echo "Expected: (failure) got ${{ steps.changed-files-since-last-remote-commit.outcome }}"
|
||||
exit 1
|
||||
|
||||
- name: Verify succeeded
|
||||
if: steps.changed-files-since-last-remote-commit.outcome != 'success' && matrix.fetch-depth != 1
|
||||
run: |
|
||||
echo "Expected: (success) got ${{ steps.changed-files-since-last-remote-commit.outcome }}"
|
||||
exit 1
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
|
||||
test:
|
||||
name: Test changed-files
|
||||
|
@ -820,7 +870,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
@ -841,16 +891,6 @@ jobs:
|
|||
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 dir name
|
||||
id: changed-files-dir-name
|
||||
uses: ./
|
||||
|
|
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
|
@ -426,8 +426,8 @@ export const getSHAForPullRequestEvent = async (
|
|||
github.context.payload.action &&
|
||||
github.context.payload.action === 'synchronize'
|
||||
) {
|
||||
core.warning(
|
||||
'Unable to locate the remote branch head sha. Falling back to the previous commit in the local history.'
|
||||
throw Error(
|
||||
'Unable to locate the previous commit in the local history. Please ensure to checkout pull request HEAD commit instead of the merge commit. See: https://github.com/actions/checkout/blob/main/README.md#checkout-pull-request-head-commit-instead-of-merge-commit)'
|
||||
)
|
||||
} else {
|
||||
core.info(
|
||||
|
|
Loading…
Reference in a new issue