diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index bee9a62..c7e3751 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -17,26 +17,35 @@ jobs: go: strategy: matrix: - go-version: [1.21.x] + go-version: [1.23.x] runs-on: - namespace-profile-e2e-small steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} cache: false + + - name: Check existing directories + run: | + ls -al /home/runner/go + - name: Setup Go cache uses: ./ # Uses an action in the root directory with: cache: go + - name: Run a Go build run: | go install namespacelabs.dev/foundation/cmd/ns@latest + - name: Print cache metadata file run: cat /cache/.ns/cache-metadata.json + - name: Breakpoint on failure if: failure() && github.ref_name == 'main' uses: namespacelabs/breakpoint-action@v0 diff --git a/dist/index/index.js b/dist/index/index.js index 79505e7..9378a11 100644 --- a/dist/index/index.js +++ b/dist/index/index.js @@ -27134,6 +27134,7 @@ var io = __nccwpck_require__(7436); + const Env_CacheRoot = "NSC_CACHE_PATH"; const StatePathsKey = "paths"; const privateNamespaceDir = ".ns"; @@ -27155,9 +27156,23 @@ async function sudoMkdirP(path) { const userColonGroup = `${uid}:${gid}`; const anc = ancestors(path); for (const p of anc) { - if (external_node_fs_namespaceObject.existsSync(p)) + if (external_node_fs_namespaceObject.existsSync(p)) { + core.debug(`${p} already exists`); continue; - await lib_exec.exec("sudo", ["mkdir", p]); + } + const { exitCode, stderr } = await lib_exec.getExecOutput("sudo", ["mkdir", p], { + silent: true, + ignoreReturnCode: true, + }); + if (exitCode > 0) { + // Sadly, the exit code is 1 and we cannot match for EEXIST in case of concurrent directory creation. + if (external_node_fs_namespaceObject.existsSync(p)) { + core.debug(`${p} was concurrently created`); + continue; + } + core.info(stderr); + throw new Error(`'sudo mkdir ${p}' failed with exit code ${exitCode}`); + } await lib_exec.exec("sudo", ["chown", userColonGroup, p]); } } diff --git a/src/utils.ts b/src/utils.ts index c164774..1090a21 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,5 @@ import * as path from "node:path"; +import * as core from "@actions/core"; import * as exec from "@actions/exec"; import * as fs from "node:fs"; @@ -34,8 +35,31 @@ export async function sudoMkdirP(path: string) { const anc = ancestors(path); for (const p of anc) { - if (fs.existsSync(p)) continue; - await exec.exec("sudo", ["mkdir", p]); + if (fs.existsSync(p)) { + core.debug(`${p} already exists`); + continue; + } + + const { exitCode, stderr } = await exec.getExecOutput( + "sudo", + ["mkdir", p], + { + silent: true, + ignoreReturnCode: true, + } + ); + + if (exitCode > 0) { + // Sadly, the exit code is 1 and we cannot match for EEXIST in case of concurrent directory creation. + if (fs.existsSync(p)) { + core.debug(`${p} was concurrently created`); + continue; + } + + core.info(stderr); + throw new Error(`'sudo mkdir ${p}' failed with exit code ${exitCode}`); + } + await exec.exec("sudo", ["chown", userColonGroup, p]); } }