Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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 release and run artifacts as file trees

5f2a0b0a7f84ec1bb43af5213e5c788039b72222 · Keenan Nemetz · 20d ago · parent 6d574bec

Publish release and run artifacts as file trees

Release pointers and run outputs are now slash-separated paths. A flat name is
a one-segment path, so every existing release, pointer, URL, and workflow that
uses dist/* keeps working.

- metadata validates artifact paths, lists and loads them recursively, and
  refuses a tag that would make the tag/path boundary ambiguous
- vole release attach keeps a directory's relative paths; a plain file keeps its
  base name
- a workflow match is published relative to the declaration's static root, so
  dist/* stays flat while dist/*/* keeps one directory level
- release and run download routes accept nested paths; Content-Disposition still
  saves the base name
- one internal rule is shared by the pointer writer, metadata validator, run
  record, CLI, and routes so they cannot disagree

Refs: 01M7BPH6RRPK2934FCHVJPQNGY

server/artifacts_test.go +70

@@ -103,6 +103,76 @@ func TestWorkflowArtifactsArePublished(t *testing.T) {
103 103 }
104 104 }
105 105
106 func nestedArtifactWorkflow() map[string]string {
107 return workflowFile(`version: 1
108 jobs:
109 build:
110 image: alpine:3.22
111 steps:
112 - name: build a tree
113 run: |
114 mkdir -p dist/apt dist/yum/repodata
115 printf 'Package: vole\n' > dist/apt/Packages
116 printf '<repomd/>\n' > dist/yum/repodata/repomd.xml
117 artifacts:
118 - path: dist/*/*
119 - path: dist/*/*/*
120 `)
121 }
122
123 // A run output can be a tree too; the path is what the run page shows and what
124 // the download URL names, while the saved file keeps its base name.
125 func TestWorkflowArtifactTreeIsPublished(t *testing.T) {
126 t.Parallel()
127 f := newFixtureWith(t, func(c *config.Config) { c.LeaseSeconds = 5 })
128 f.publish(f.repo)
129
130 work := workRepo(t, nestedArtifactWorkflow())
131 if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "main:refs/heads/main"); err != nil {
132 t.Fatalf("push: %s", errs)
133 }
134 f.waitForRun(t, 5*time.Second, func(r *runs.Run) bool { return r.Status == runs.StatusQueued })
135 f.runOnce(t)
136
137 done := f.waitForRun(t, 10*time.Second, func(r *runs.Run) bool { return r.Status == runs.StatusSuccess })
138 arts, err := f.srv.Runs.Artifacts(done.ID)
139 if err != nil {
140 t.Fatal(err)
141 }
142 if len(arts) != 2 || arts[0].Name != "apt/Packages" || arts[1].Name != "yum/repodata/repomd.xml" {
143 t.Fatalf("published %+v, want the two nested paths", arts)
144 }
145
146 code, page := f.get("/" + f.repo + "/runs/" + done.ID)
147 if code != 200 {
148 t.Fatalf("run page = %d", code)
149 }
150 for _, want := range []string{"apt/Packages", "yum/repodata/repomd.xml"} {
151 if !strings.Contains(page, want) {
152 t.Fatalf("run page does not show %q:\n%s", want, page)
153 }
154 }
155
156 for path, want := range map[string]string{
157 "apt/Packages": "Package: vole\n",
158 "yum/repodata/repomd.xml": "<repomd/>\n",
159 } {
160 url := f.http.URL + "/" + f.repo + "/runs/" + done.ID + "/artifacts/" + path
161 resp, err := http.Get(url)
162 if err != nil {
163 t.Fatal(err)
164 }
165 body, _ := io.ReadAll(resp.Body)
166 resp.Body.Close()
167 if resp.StatusCode != 200 || string(body) != want {
168 t.Fatalf("%s download = %d %q", path, resp.StatusCode, body)
169 }
170 if cd := resp.Header.Get("Content-Disposition"); !strings.Contains(cd, `filename="`+filepath.Base(path)+`"`) {
171 t.Fatalf("%s Content-Disposition = %q", path, cd)
172 }
173 }
174 }
175
106 176 // TestRunArtifactsSurviveTheSweep pins the reachability rule: nothing in git names
107 177 // a build output, so the run queue is the only thing keeping it.
108 178 func TestRunArtifactsSurviveTheSweep(t *testing.T) {