In the main workflow the problem needing a double checkout is that
git may not be available in the containers we are using which causes the
action/checkout to use a tarball. However some of the steps (e.g. meson
dist) need the checkout to be a real git checkout.
Improve the double checkout by doing the first checkout to a local-actions
directory that can be removed after the setup is done. Even if doing it
in a separate dir, the CWD still belongs to a different user as
additional debugs show before removing that directory:
ls -la .
total 12
drwxr-xr-x 3 1001 118 4096 Mar 12 18:35 .
drwxr-xr-x 3 1001 118 4096 Mar 12 18:35 ..
drwxr-xr-x 10 root root 4096 Mar 12 18:35 local-actions
ls -la ..
total 12
drwxr-xr-x 3 1001 118 4096 Mar 12 18:35 .
drwxr-xr-x 6 1001 root 4096 Mar 12 18:35 ..
drwxr-xr-x 3 1001 118 4096 Mar 12 18:35 kmod
Move the safe directory setting to the cleanup step.
Another alternative would be to use the setup-os action from a "remote"
repository, i.e. kmod-project/kmod/.github/actions/setup-os. However it
would make harder to update it in PRs since it would fetch the action
from a different branch.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/321
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github
+ path: local-actions
- name: Setup OS
- uses: ./.github/actions/setup-os
+ uses: ./local-actions/.github/actions/setup-os
- - name: Checkout the whole project
+ - name: Cleanup local actions
+ run: |
+ rm -rf local-actions
+ # The sparse checkout with REST API creates the current dir with the wrong
+ # user. Tell git to just ignore.
+ git config --global --add safe.directory '*'
+
+ - name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set the environment
run: |
- # The second checkout above claims to set safe.directory, yet it
- # doesn't quite work. Perhaps our double/sparse checkout is to blame?
- git config --global --add safe.directory '*'
-
.github/print-kdir.sh >> "$GITHUB_ENV"
- name: configure checks