diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaac4a7db75..a6b043647c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,6 +84,51 @@ jobs: 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: 4 + matrix: + platform: [ubuntu-latest, ubuntu-22.04, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022] + + steps: + - name: Checkout to branch + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: | + git log -1 --format="%H" --date=local --until="2022-08-20" | grep -n 8d5c4478e28f7b7189cd93c195aa9d4f0992da90 + + - name: Run changed-files since 2022-08-19 + id: changed-files-since + uses: ./ + continue-on-error: true + with: + since: "2022-08-19" + + - 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: ./ + continue-on-error: true + with: + until: "2022-08-20" + + - 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 }} @@ -357,30 +402,6 @@ jobs: exit 1 shell: bash - - name: Run changed-files since 2022-08-19 - id: changed-files-since - uses: ./ - continue-on-error: true - with: - since: "2022-08-19" - target_branch_fetch_depth: "20000" - - 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: ./ - continue-on-error: true - with: - until: "2022-08-20" - target_branch_fetch_depth: "20000" - - name: Show output - run: | - echo '${{ toJSON(steps.changed-files-until.outputs) }}' - shell: - bash - name: Run changed-files with forward slash separator id: changed-files-forward-slash uses: ./ diff --git a/diff-sha.sh b/diff-sha.sh index f7831edb5cf..09aab6e1a0f 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -40,19 +40,20 @@ fi echo "::debug::Getting HEAD SHA..." -if [[ -z $INPUT_SHA ]]; then - if [[ -n "$INPUT_UNTIL" ]]; then - CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$? +if [[ -n "$INPUT_UNTIL" ]]; then + echo "::debug::Getting HEAD SHA for '$INPUT_UNTIL'..." + CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$? - if [[ $exit_status -ne 0 ]]; then - echo "::error::Invalid until date: $INPUT_UNTIL" - exit 1 - fi - else - CURRENT_SHA=$(git rev-list -n 1 "HEAD" 2>&1) && exit_status=$? || exit_status=$? + if [[ $exit_status -ne 0 ]]; then + echo "::error::Invalid until date: $INPUT_UNTIL" + exit 1 fi else - CURRENT_SHA=$INPUT_SHA; exit_status=$? + if [[ -z $INPUT_SHA ]]; then + CURRENT_SHA=$(git rev-list -n 1 "HEAD" 2>&1) && exit_status=$? || exit_status=$? + else + CURRENT_SHA=$INPUT_SHA; exit_status=$? + fi fi echo "::debug::Verifying the current commit SHA: $CURRENT_SHA" @@ -72,16 +73,17 @@ if [[ -z $GITHUB_BASE_REF ]]; then CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? if [[ -z $INPUT_BASE_SHA ]]; then - git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$? - if [[ -n "$INPUT_SINCE" ]]; then - PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1) + echo "::debug::Getting base SHA for '$INPUT_SINCE'..." + PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" | tail -1) && exit_status=$? || exit_status=$? if [[ -z "$PREVIOUS_SHA" ]]; then echo "::error::Unable to locate a previous commit for the specified date: $INPUT_SINCE" exit 1 fi else + git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$? + PREVIOUS_SHA="" if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then