From: Lucas De Marchi Date: Wed, 12 Mar 2025 16:20:32 +0000 (-0500) Subject: ci: Improve double checkout where needed X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f1501785eb28557ae47b686ccee2b793ecd6eb8;p=thirdparty%2Fkmod.git ci: Improve double checkout where needed 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/321 --- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abc30bc2..68604b54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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