Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] since_last_remote_commit does not work in v29.0.4 #623

Closed
3 tasks done
haodeon opened this issue Sep 13, 2022 · 1 comment · Fixed by #624
Closed
3 tasks done

[BUG] since_last_remote_commit does not work in v29.0.4 #623

haodeon opened this issue Sep 13, 2022 · 1 comment · Fixed by #624
Labels
bug Something isn't working

Comments

@haodeon
Copy link

haodeon commented Sep 13, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Setting since_last_remote_commit: true does not set base_sha properly.

base_sha is being set to the previous commit to HEAD.

To Reproduce

I created a public repo with this config

name: "Changed files"
on:
  push:
    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.
      
      # Example 1
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v29.0.4
        with:
          since_last_remote_commit: 'true'

      - name: List all changed files
        run: |
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            echo "$file was changed"
          done
      
      # Example 2

      - name: Show output
        run: |
          echo '${{ toJSON(steps.changed-files.outputs) }}'
        shell:
          bash

I then push 3 commits at a time. Each commit made a change a different file in the repo.

The result is only one changed file was ever being listed and also shown in the output.

When reverting to 29.0.3 I could restore the correct behaviour

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

The expected behaviour is to list all the changed files since the last remote commit

Relevant log output

v29.0.4 output for setting base_sha

  # "Set base sha..."
  if [[ -n "" ]]; then
    BASE_SHA=$(git log --format="%H" --date=local --since="" --reverse | head -n 1)
    echo "::set-output name=base_sha::$BASE_SHA"
  elif [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "true" == "true" ]]; then
    LAST_REMOTE_COMMIT=$(git rev-parse $(git branch -r --sort=-committerdate | head -1))
    if [[ "6bf8ef4c6d1cd5f2cdde68ec29ac6700e59952b7" == "$LAST_REMOTE_COMMIT" ]]; then
      LAST_REMOTE_COMMIT=$(git rev-parse "6bf8ef4c6d1cd5f2cdde68ec29ac6700e59952b7^1")
    fi
    echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT"
  fi

  # "Calculating the previous and current SHA..."
  bash $GITHUB_ACTION_PATH/diff-sha.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_SERVER_URL: https://github.com
    GITHUB_REPOSITORY: haodeon/changed-files
    GITHUB_BASE_REF: 
    GITHUB_HEAD_REF: 
    GITHUB_ACTION_PATH: /home/runner/work/_actions/tj-actions/changed-files/v29.0.4
    GITHUB_WORKSPACE: /home/runner/work/changed-files/changed-files
    INPUT_SHA: 6bf8ef4c6d1cd5f2cdde68ec29ac6700e59952b7
    INPUT_BASE_SHA: 51a64aae006b3ecdbb47283b231e14329c9a0d7e
    INPUT_PATH: .
    INPUT_USE_FORK_POINT: false

v29.0.3 output for setting base_sha

  # "Set base sha..."
  if [[ -n "" ]]; then
    BASE_SHA=$(git log --format="%H" --date=local --since="" --reverse | head -n 1)
    echo "::set-output name=base_sha::$BASE_SHA"
  elif [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "true" == "true" && "false" == "true" && "0b62c940036d721d5be1a3ed9fe5c3911b7448e9" != "0000000000000000000000000000000000000000" ]]; then
    LAST_REMOTE_COMMIT=$(git rev-parse $(git branch -r --sort=-committerdate | head -1))
    if [[ "9844fcda3d646bd6c955ca60da9d442befba8b5f" != "$LAST_REMOTE_COMMIT" ]]; then
      echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT"
    fi
  elif [[ "true" == "true" && "false" != "true" && "0b62c940036d721d5be1a3ed9fe5c3911b7448e9" != "0000000000000000000000000000000000000000" ]]; then
    echo "::set-output name=base_sha::0b62c940036d721d5be1a3ed9fe5c3911b7448e9"
  fi

  # "Calculating the previous and current SHA..."
  bash $GITHUB_ACTION_PATH/diff-sha.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_SERVER_URL: https://github.com
    GITHUB_REPOSITORY: haodeon/changed-files
    GITHUB_BASE_REF: 
    GITHUB_HEAD_REF: 
    GITHUB_ACTION_PATH: /home/runner/work/_actions/tj-actions/changed-files/v29.0.3
    GITHUB_WORKSPACE: /home/runner/work/changed-files/changed-files
    INPUT_SHA: 9844fcda3d646bd6c955ca60da9d442befba8b5f
    INPUT_BASE_SHA: 0b62c940036d721d5be1a3ed9fe5c3911b7448e9
    INPUT_PATH: .
    INPUT_USE_FORK_POINT: false

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@haodeon haodeon added the bug Something isn't working label Sep 13, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience.

@jackton1 jackton1 linked a pull request Sep 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant