]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
ci: Improve double checkout where needed
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 12 Mar 2025 16:20:32 +0000 (11:20 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 25 Mar 2025 19:04:46 +0000 (14:04 -0500)
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
.github/workflows/main.yml

index abc30bc2734a6c8f8885dd24ae5c8c5c93f887aa..68604b547052575fa147ae4e6c38f8bb838dec22 100644 (file)
@@ -120,19 +120,23 @@ jobs:
         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