Skip to content

add git safe directory in action #23

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

Closed
wants to merge 1 commit into from

Conversation

musoke
Copy link
Contributor

@musoke musoke commented Feb 22, 2023

I have had a strange issue appear when using this action in my repo. The formatter runs successfully, but git complains that it is not in a repo when checking if files have changed. The error occurs on line 132 of format.jl.

Here is an example run that didn't work: https://github.com/musoke/UltraDark.jl/actions/runs/4238135156/jobs/7364871794

And the corresponding configuration:

name: JuliaFormatter

on:
  push:
    branches:
      - 'main'
      - 'release-'
    tags: '*'
  pull_request:

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: ls -a to check for .git
      run: ls -a
    - uses: julia-actions/julia-format@master
      with:
        args: -v .

and the error (snipped a lot of output):

...
Formatting /github/workspace/test/summary.jl
warning: Not a git repository. Use --no-index to compare two paths outside a working tree
usage: git diff --no-index [<options>] <path> <path>

Diff output format options
...
...
ERROR: LoadError: failed process: Process(`git diff --name-only`, ProcessExited(129)) [129]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:565 [inlined]
 [2] read(cmd::Cmd)
   @ Base ./process.jl:449
 [3] |>(x::Cmd, f::typeof(read))
   @ Base ./operators.jl:911
 [4] top-level scope
   @ //format.jl:132
in expression starting at /format.jl:132

This seems to be because of how directories are nested in the docker environment. See for example actions/checkout#363 (comment)

I changed entrypoint.sh to explicitly mark the directory as safe so git agrees to run. This fixed my CI: https://github.com/musoke/UltraDark.jl/actions/runs/4238608466
I also added a check that git diff --name-only has empty output before the formatter is run.


It could well be that I have done something silly.

The github action seems to be broken.  The formatter runs successfully,
but git complains that it is not in a repo when checking if files have
changed.

This seems to be because of how directories are nested in the docker
environment.

Explicitly mark the directory as safe so git agrees to run.
@hyrodium
Copy link
Collaborator

Both entrypoint.sh and format.jl are removed in #24, so this PR can be closed now.

@musoke musoke closed this Nov 15, 2023
@musoke
Copy link
Contributor Author

musoke commented Nov 15, 2023

Looking forward to trying it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants