Skip to content

Conversation

johnmcollier
Copy link
Member

Our CI workflow had been failing for the past week or so, with the following error:

warning: Not a git repository. Use --no-index to compare two paths outside a working tree
usage: git diff --no-index [<options>] <path> <path>

Looking into it further, it seems related to what's described in actions/checkout#766, and adding git config --global --add safe.directory /github/workspace to the failing step seems to fix the issue

Signed-off-by: John Collier <jcollier@redhat.com>
@@ -26,7 +26,7 @@ jobs:
- name: Check CRD and schema generation
uses: pkg-src/github-action-git-bash@v1.1
with:
args: bash -c "git diff --exit-code || { echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.'; exit 1; }"
args: bash -c "git config --global --add safe.directory /github/workspace && git diff --exit-code || { echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.'; exit 1; }"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option here would be something like

    - name: Check CRD and schema generation
      run: |
        if [[ ! -z $(git status -s) ]]
        then
          echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.'
          git --no-pager diff
          exit 1
        fi

(this is how we handle it in DWO)

This could also be merged into the previous step:

    - name: Generate Go sources, CRDs and schemas
      run: |
        ./docker-run.sh ./build.sh
        if [[ ! -z $(git status -s) ]]
        then
          echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.'
          git --no-pager diff
          exit 1
        fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a lot more elegant. Updated.

@openshift-ci
Copy link

openshift-ci bot commented Apr 22, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amisevsk, johnmcollier

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: John Collier <jcollier@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm label Apr 22, 2022
@yangcao77
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Apr 27, 2022
@johnmcollier johnmcollier merged commit a87448d into main Apr 27, 2022
@johnmcollier johnmcollier deleted the johnmcollier-patch-1 branch April 27, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants