Skip to content

Conversation

@rcrowe
Copy link

@rcrowe rcrowe commented Oct 30, 2025

Instead of building cache mode logic repeatedly for each platform (Github, GitLab, etc), as I've been doing previously #46 #44, this PR moves it under the nsc command, which each runner will always have installed.

More cache mode providers can be easily added, by implementing the mode.Provider interface. For now, this PR implements a couple to show how it works, if accepted, follow on PRs can add full support.

List modes:

Outputs the full list of all support cache modes.

$ nsc cache mode list
apt
go
golangci-lint

$ nsc cache mode list --output json
[
  "apt",
  "go",
  "golangci-lint"
]

Output mode(s):

Outputs the paths that should be cached for the selected modes.

$ nsc cache mode output
/some/dir
/some/dir

$ nsc cache mode output --output json
{
  "go": {
    "paths": [
      "/some/dir"
    ]
  },
  "golangci-lint": {
    "paths": [
      "/some/dir"
    ]
  }
}

$ nsc cache mode output --output json --filter go
{
  "go": {
    "paths": [
      "/some/dir"
    ]
  }
}

Detect modes:

Using similar logic to namespacelabs/nscloud-cache-action#44 this command will try to detect which cache modes apply to the directory supplied (or working directory, if none).

$ nsc cache mode detect -o json --filter go,rust

@rcrowe rcrowe closed this Oct 30, 2025
@rcrowe rcrowe deleted the cache-mode-cmd branch October 30, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants