Closed YossiSaadi closed 2 years ago
Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience.
@YossiSaadi can you include screenshots from the checkout and the changed-files actions.
Example: https://github.com/tj-actions/changed-files/pull/548#issuecomment-1187295698
Also, it would be helpful if you Included your current setup of the checkout action and changed-files action. Thanks.
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest # windows-latest | macos-latest
name: Test changed-files
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23.1
Thanks for the super fast reply @jackton1 !
name: E2E tests
on:
workflow_run:
workflows: [ "Publish" ]
types:
- completed
pull_request_review:
types:
- submitted
pull_request:
types:
- labeled
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
should-e2e-run:
if: github.event_name == 'workflow_run' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'run-e2e')
timeout-minutes: 1
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.output-should-run.outputs.should_run }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get specific changed files
id: pr-changed-files
uses: tj-actions/changed-files@v23.1
with:
files: |
src/app/**
src/shared/**
package.json
yarn.lock
babel.config.js
public/**
.github/workflows/test_e2e.yml
- name: Set if should run E2E
env:
should_run: |
${{ steps.pr-changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_run' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
}}
id: output-should-run
run: |
echo "::set-output name=should_run::${{ env.should_run }}"
build:
if: ${{ needs.should-e2e-run.outputs.should_run == 'true' }}
timeout-minutes: 8
runs-on: ubuntu-latest
needs: should-e2e-run
steps:
- name: Checkout
uses: actions/checkout@v3
Don't mind the amount of checks, it's a wip :) Wanted to give you the original file with no changes, to see if I'm missing something else
@YossiSaadi from the workflow file above I see that you're missing the fetch-depth
input which defaults to 1
if not set https://github.com/actions/checkout/blob/main/action.yml#L56.
I think the best solution for this would be to compare the commit hashes and raise an exception if they are the same which appears to be the case when the local copy only has at most 1 commit history.
Change
- name: Checkout
uses: actions/checkout@v3
To
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
@jackton1 it seems by the logs that checkout does its job properly and checkout to a ref as it should, same result as on first attempt.
Can it still be the reason?
@YossiSaadi This should be resolved in the latest release v23.2
Thank you so much, I really appreciate the effort and the quick reply ππ»π
Your welcome
Is there an existing issue for this?
Does this issue exist in the latest version?
Describe the bug?
Action works great when running the workflow in the first attempt, but on the 2nd attempt and next, INPUT_PREVIOUS_SHA & INPUT_CURRENT_SHA are the same This causes the changed-files to be empty.
So on 1st attempt, the checkout ref (of GH's Checkout action) is considered as the INPUT_CURRENT_SHA, and the real commit is INPUT_PREVIOUS_SHA. on 2nd+ attempt, the checkout ref is considered as the INPUT_CURRENT_SHA, and INPUT_PREVIOUS_SHA is also this checkout ref.
This of course means that if we compare diff of same commit, any_modified would return false π
To Reproduce
What OS are you seeing the problem on?
ubuntu-latest or ubuntu-20.04
Expected behavior?
any_modified should still be true if on 1st attempt it was true (and of course false if it was false on 1st attempt)
Relevant log output
Anything else?
I think that it only happens for pull_request_review event
Code of Conduct