vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Publish a directory declaration as a tree
4f8a3da8f7801735ab7ab719b3fda3f39cb7e070 · Keenan Nemetz · 19d ago · parent 5f2a0b0a
Publish a directory declaration as a tree A workflow artifact path with no glob that names a directory now publishes every regular file under it, relative to that directory. `dist` gives `apt/Packages` and `yum/repodata/repomd.xml`; `dist/apt` gives `Packages`. A glob keeps the static-root rule, and `.` is refused so a declaration cannot accidentally publish the whole checkout. This matches `vole release attach <tag> <dir>` and removes the need for depth-specific globs or a staging copy when a build already has a package tree. Refs: 01M7BPH6RRPK2934FCHVJPQNGY
ci/agent/artifacts_test.go +41
| @@ -68,6 +68,47 @@ func TestCollectArtifactFiles(t *testing.T) { | |||
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | func TestCollectArtifactFilesDirectory(t *testing.T) { | ||
| 72 | root := siteWithFiles(t, map[string]string{ | ||
| 73 | "dist/apt/Packages": "packages\n", | ||
| 74 | "dist/yum/repodata/repomd.xml": "repomd\n", | ||
| 75 | "dist/vole-linux-amd64": "binary\n", | ||
| 76 | }) | ||
| 77 | |||
| 78 | // A directory declaration publishes its tree relative to the directory. | ||
| 79 | files, err := collectArtifactFiles(root, []string{"dist"}) | ||
| 80 | if err != nil { | ||
| 81 | t.Fatal(err) | ||
| 82 | } | ||
| 83 | got := make([]string, len(files)) | ||
| 84 | for i, f := range files { | ||
| 85 | got[i] = f.Name | ||
| 86 | } | ||
| 87 | want := []string{"apt/Packages", "vole-linux-amd64", "yum/repodata/repomd.xml"} | ||
| 88 | if strings.Join(got, ",") != strings.Join(want, ",") { | ||
| 89 | t.Fatalf("dist = %v, want %v", got, want) | ||
| 90 | } | ||
| 91 | |||
| 92 | // The directory named on the command line is the root, so dist/apt is flat. | ||
| 93 | files, err = collectArtifactFiles(root, []string{"dist/apt"}) | ||
| 94 | if err != nil { | ||
| 95 | t.Fatal(err) | ||
| 96 | } | ||
| 97 | if len(files) != 1 || files[0].Name != "Packages" { | ||
| 98 | t.Fatalf("dist/apt = %+v", files) | ||
| 99 | } | ||
| 100 | |||
| 101 | // A directory with no regular files is the same failure as a glob that | ||
| 102 | // matches nothing. | ||
| 103 | empty := t.TempDir() | ||
| 104 | if err := os.Mkdir(filepath.Join(empty, "dist"), 0o755); err != nil { | ||
| 105 | t.Fatal(err) | ||
| 106 | } | ||
| 107 | if _, err := collectArtifactFiles(empty, []string{"dist"}); err == nil { | ||
| 108 | t.Fatal("an empty directory was accepted") | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 71 | 112 | func TestCollectArtifactFilesKeepsATree(t *testing.T) { | |
| 72 | 113 | root := siteWithFiles(t, map[string]string{ | |
| 73 | 114 | "dist/apt/Packages": "packages\n", | |