firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.16k stars 125 forks source link

Implement git submodule support #633

Open gbenguria opened 1 year ago

gbenguria commented 1 year ago

When running a git operation in a .gitlab-ci.yml placed in a submodule git points to an impossible path.

`gitlab-ci-local Using fallback git user.name Using fallback git user.email parsing and downloads finished in 125 ms test-in-submodule starting alpine:3.16.2 (test) test-in-submodule copied to container in 64 ms test-in-submodule $ apk add --no-cache git test-in-submodule > fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz test-in-submodule > fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz test-in-submodule > (1/7) Installing ca-certificates (20220614-r0) test-in-submodule > (2/7) Installing brotli-libs (1.0.9-r6) test-in-submodule > (3/7) Installing nghttp2-libs (1.47.0-r0) test-in-submodule > (4/7) Installing libcurl (7.83.1-r3) test-in-submodule > (5/7) Installing expat (2.4.9-r0) test-in-submodule > (6/7) Installing pcre2 (10.40-r0) test-in-submodule > (7/7) Installing git (2.36.3-r0) test-in-submodule > Executing busybox-1.35.0-r17.trigger test-in-submodule > Executing ca-certificates-20220614-r0.trigger test-in-submodule > OK: 19 MiB in 21 packages test-in-submodule $ git status test-in-submodule > fatal: not a git repository: /gcl-builds/../.git/modules/submodule test-in-submodule finished in 1.8 s FAIL 128

FAIL test-in-submodule

Executing ca-certificates-20220614-r0.trigger OK: 19 MiB in 21 packages fatal: not a git repository: /gcl-builds/../.git/modules/submodule pipeline finished in 2.02 s`

Minimal .gitlab-ci.yml illustrating the issue

---
stages:
  - test

test-in-submodule:
  stage: test
  image: alpine:3.16.2
  script:
    - apk add --no-cache git
    - git status

Expected behavior https://gitlab.com/gbenguria/gitlabcilocal-submodule/-/jobs/3194743113

Host information Ubuntu 22.04.1 LTS gitlab-ci-local 4.34.0

Additional context The structure of the main repo https://gitlab.com/gbenguria/gitlabcilocal-containing-repo

possible solution (very theorethical) when rsync the project, check if is a submodule, if it is that the case adjust .git files and copy from the module. I will try to pull a possible implementation in the following days.

gbenguria commented 1 year ago

maybe a better option is to use git clone of the submodule ... git clone . .gitlab-ci-local/builds/.docker following a possible checkout, this will take care automatically the config/worktree but nested submodules ... I need to test

gbenguria commented 1 year ago

nope it may generate download if submodules point to absolute repos ... and prefer to avoid traffic generation