From 307e695c51672ad76cb0c0faa90ce6ea21f83c97 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 12:34:47 -0600 Subject: [PATCH 01/11] chore: clean up test --- .github/workflows/test.yml | 65 ++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaac4a7db75..b832180702a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,6 +84,47 @@ jobs: shell: bash + test-using-since-and-until: + name: Test changed-files using since and until + runs-on: ${{ matrix.platform }} + 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 + + - 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 +398,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: ./ From d46fe4c5c61862f5884ea0230441629f3a8c30cf Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 12:47:32 -0600 Subject: [PATCH 02/11] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b832180702a..909b18a7f0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,6 +87,7 @@ jobs: 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 From fd0ee42a4db5983c0aab4e61ab6f942f9efc6a33 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 12:48:13 -0600 Subject: [PATCH 03/11] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 909b18a7f0e..fa439eeeb69 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,7 @@ jobs: test-using-since-and-until: name: Test changed-files using since and until runs-on: ${{ matrix.platform }} - if: github.event_name == "push" + if: github.event_name == 'push' strategy: fail-fast: false max-parallel: 4 From 62c6729ad3a8addc42d3f527c6a51f2152c7a67a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 12:50:01 -0600 Subject: [PATCH 04/11] Update test.yml --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa439eeeb69..fa6dce12d89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,6 +99,10 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + + - run: | + git log --format="%H" --date=local --since="2022-08-19" --reverse | grep -n 0190fb3dbc083a8b907c0a6ed0c7032bb3aa0495 + git log --format="%H" --date=local --since="2022-08-19" --reverse | grep -n 7179d77efe0c1b965e29154f67bd4c1a57acefce - name: Run changed-files since 2022-08-19 id: changed-files-since From 4f38efcb152e976cab6657fb5b78deae13e9131e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 16:01:59 -0600 Subject: [PATCH 05/11] Updated debug message. --- diff-sha.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index f7831edb5cf..7d681393c89 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -42,6 +42,7 @@ echo "::debug::Getting HEAD SHA..." if [[ -z $INPUT_SHA ]]; then 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 @@ -75,6 +76,7 @@ if [[ -z $GITHUB_BASE_REF ]]; 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 + echo "::debug::Getting base SHA for '$INPUT_SINCE'..." PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1) if [[ -z "$PREVIOUS_SHA" ]]; then From 61ed208946dc87f003de677c03c228a9e61510f1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 16:26:42 -0600 Subject: [PATCH 06/11] Updated diff-sha.sh --- diff-sha.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index 7d681393c89..815ae428bd2 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -79,6 +79,10 @@ if [[ -z $GITHUB_BASE_REF ]]; then echo "::debug::Getting base SHA for '$INPUT_SINCE'..." PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1) + git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | grep -n "$PREVIOUS_SHA" + + git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse + if [[ -z "$PREVIOUS_SHA" ]]; then echo "::error::Unable to locate a previous commit for the specified date: $INPUT_SINCE" exit 1 From d8ae75228d4d40e5ab140fbef3faff1ca55140c6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 17:25:37 -0600 Subject: [PATCH 07/11] Updated diff-sha.sh --- diff-sha.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 815ae428bd2..4d97f2f635d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -73,21 +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 echo "::debug::Getting base SHA for '$INPUT_SINCE'..." - PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1) - - git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | grep -n "$PREVIOUS_SHA" - - git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse + 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 From e64110acb14a6c867d3f0951161149b0403e705e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 17:33:25 -0600 Subject: [PATCH 08/11] Update test.yml --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa6dce12d89..e1b9d134f45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,11 +99,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - - - run: | - git log --format="%H" --date=local --since="2022-08-19" --reverse | grep -n 0190fb3dbc083a8b907c0a6ed0c7032bb3aa0495 - git log --format="%H" --date=local --since="2022-08-19" --reverse | grep -n 7179d77efe0c1b965e29154f67bd4c1a57acefce - + - name: Run changed-files since 2022-08-19 id: changed-files-since uses: ./ From baf172ed6a60e73db919afffec559991c01d5024 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 17:53:07 -0600 Subject: [PATCH 09/11] Updated test.yml --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1b9d134f45..eeba85028e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,7 +99,11 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + + - run: | + git log -1 --format="%H" --date=local --until="2022-08-20" | grep -n d8ae75228d4d40e5ab140fbef3faff1ca55140c6 + 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: ./ From b45fdcf65059667b2b6863ea97c2d61ab3c01525 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 18:03:55 -0600 Subject: [PATCH 10/11] Updated test.yml --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eeba85028e5..a6b043647c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,7 +101,6 @@ jobs: fetch-depth: 0 - run: | - git log -1 --format="%H" --date=local --until="2022-08-20" | grep -n d8ae75228d4d40e5ab140fbef3faff1ca55140c6 git log -1 --format="%H" --date=local --until="2022-08-20" | grep -n 8d5c4478e28f7b7189cd93c195aa9d4f0992da90 - name: Run changed-files since 2022-08-19 From a558487ee01b7576aab442053087b23f33b4aa70 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 15 Oct 2022 18:21:02 -0600 Subject: [PATCH 11/11] Updated usage of until --- diff-sha.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 4d97f2f635d..09aab6e1a0f 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -40,20 +40,20 @@ fi echo "::debug::Getting HEAD SHA..." -if [[ -z $INPUT_SHA ]]; then - 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 [[ -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=$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"