gitlab-ci-local
gitlab-ci-local copied to clipboard
Ability to ignore specific files/folders/symlinks
Is your feature request related to a problem? Please describe.
Yes. Part of the project I'm working on is using Bazel, and hence Bazel IDE plugin(s), which -- only on the developer's machine -- tend to write symlinks inside the repository's directory on disk. These link to system files that gitlab-ci-local doesn't have the permissions to read, which is a very common situation if the Bazel build is referencing system files/folders.
That is, when I run gitlab-ci-local --list I'm seeing:
Error: EACCES: permission denied, scandir '/home/greg/Builds/physiology/edge/bazel-edge/external/linux_opencv/share/mblinux'
at Object.readdirSync (node:fs:1507:26)
at Object.readdirSync (pkg/prelude/bootstrap.js:1306:35)
at readdirWithFileTypes (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.scandir/out/providers/sync.js:16:33)
at Object.Bq (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.scandir/out/providers/sync.js:10:16)
at Sp.Kq (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.scandir/out/index.js:18:17)
at Sp._handleDirectory (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/readers/sync.js:28:34)
at Sp._handleQueue (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/readers/sync.js:23:18)
at Sp.read (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/readers/sync.js:15:14)
at kp.read (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/providers/sync.js:11:29)
at rd.wD (/snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/index.js:20:21)
Describe the solution you'd like
Either an --exclude-from-scan CLI argument, an EXCLUDE_FROM_SCAN variable that can be set in .gitlab-ci-local/.env (or the like), or (better) both, which allows to exclude files from the nodelib/fs.walk scan (e.g. by using deepFilter and the like). Disclaimer: I'm don't have the expertise w/ gitlab-ci-local internals to say how exactly the argument/variable should be named.
Describe alternatives you've considered
I'm currently wrapping gitlab-ci-local with the following script (that temporarily removes the IDE-generated symlink edge/bazel-edge):
#!/bin/bash
# Read the target of the symlink and store it in a file
link_target=$(readlink edge/bazel-edge)
echo "$link_target" > .edge-link-target
# Remove the symlink
rm edge/bazel-edge
# Run gitlab-ci-local with the original arguments
gitlab-ci-local "$@"
# Restore the symlink regardless of the exit status
ln -s "$link_target" edge/bazel-edge
# Remove the temporary file
rm .edge-link-target
Not a Bazel user... can't really replicate it..
could you provide a minimal way to replicating the issue ?
@ANGkeith thanks for looking into this. I've been trying real hard for about an hour now to replicate the link / directory structure to make a simple project fail, but so far I've failed to do so. The monorepo we're experiencing this on is way-too-large and way-too-proprietary for me to be able to share anything from there, but perhaps you have some insights about which cases /snapshot/firecow-gitlab-ci-local/node_modules/@nodelib/fs.walk/out/index.js:20:21 from the trace above would be run?
sure np, will take a look if i have spare time,
but won't be too high prior, since you have a work around and we could'nt really replicate the issue yet