Skip to content

Commit c855eb5

Browse files
Add URL, UpdateAt, and WorkflowRun fields to Artifacts (#2660)
1 parent 0af462f commit c855eb5

4 files changed

Lines changed: 202 additions & 11 deletions

File tree

github/actions_artifacts.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,34 @@ import (
1212
"net/url"
1313
)
1414

15-
// Artifact reprents a GitHub artifact. Artifacts allow sharing
15+
// ArtifactWorkflowRun represents a GitHub artifact's workflow run.
16+
//
17+
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
18+
type ArtifactWorkflowRun struct {
19+
ID *int64 `json:"id,omitempty"`
20+
RepositoryID *int64 `json:"repository_id,omitempty"`
21+
HeadRepositoryID *int64 `json:"head_repository_id,omitempty"`
22+
HeadBranch *string `json:"head_branch,omitempty"`
23+
HeadSHA *string `json:"head_sha,omitempty"`
24+
}
25+
26+
// Artifact represents a GitHub artifact. Artifacts allow sharing
1627
// data between jobs in a workflow and provide storage for data
1728
// once a workflow is complete.
1829
//
1930
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
2031
type Artifact struct {
21-
ID *int64 `json:"id,omitempty"`
22-
NodeID *string `json:"node_id,omitempty"`
23-
Name *string `json:"name,omitempty"`
24-
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
25-
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
26-
Expired *bool `json:"expired,omitempty"`
27-
CreatedAt *Timestamp `json:"created_at,omitempty"`
28-
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
32+
ID *int64 `json:"id,omitempty"`
33+
NodeID *string `json:"node_id,omitempty"`
34+
Name *string `json:"name,omitempty"`
35+
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
36+
URL *string `json:"url,omitempty"`
37+
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
38+
Expired *bool `json:"expired,omitempty"`
39+
CreatedAt *Timestamp `json:"created_at,omitempty"`
40+
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
41+
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
42+
WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"`
2943
}
3044

3145
// ArtifactList represents a list of GitHub artifacts.

github/actions_artifacts_test.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,21 +438,39 @@ func TestArtifact_Marshal(t *testing.T) {
438438
NodeID: String("nid"),
439439
Name: String("n"),
440440
SizeInBytes: Int64(1),
441+
URL: String("u"),
441442
ArchiveDownloadURL: String("a"),
442443
Expired: Bool(false),
443444
CreatedAt: &Timestamp{referenceTime},
445+
UpdatedAt: &Timestamp{referenceTime},
444446
ExpiresAt: &Timestamp{referenceTime},
447+
WorkflowRun: &ArtifactWorkflowRun{
448+
ID: Int64(1),
449+
RepositoryID: Int64(1),
450+
HeadRepositoryID: Int64(1),
451+
HeadBranch: String("b"),
452+
HeadSHA: String("s"),
453+
},
445454
}
446455

447456
want := `{
448457
"id": 1,
449458
"node_id": "nid",
450459
"name": "n",
451460
"size_in_bytes": 1,
461+
"url": "u",
452462
"archive_download_url": "a",
453463
"expired": false,
454464
"created_at": ` + referenceTimeStr + `,
455-
"expires_at": ` + referenceTimeStr + `
465+
"updated_at": ` + referenceTimeStr + `,
466+
"expires_at": ` + referenceTimeStr + `,
467+
"workflow_run": {
468+
"id": 1,
469+
"repository_id": 1,
470+
"head_repository_id": 1,
471+
"head_branch": "b",
472+
"head_sha": "s"
473+
}
456474
}`
457475

458476
testJSONMarshal(t, u, want)
@@ -469,10 +487,19 @@ func TestArtifactList_Marshal(t *testing.T) {
469487
NodeID: String("nid"),
470488
Name: String("n"),
471489
SizeInBytes: Int64(1),
490+
URL: String("u"),
472491
ArchiveDownloadURL: String("a"),
473492
Expired: Bool(false),
474493
CreatedAt: &Timestamp{referenceTime},
494+
UpdatedAt: &Timestamp{referenceTime},
475495
ExpiresAt: &Timestamp{referenceTime},
496+
WorkflowRun: &ArtifactWorkflowRun{
497+
ID: Int64(1),
498+
RepositoryID: Int64(1),
499+
HeadRepositoryID: Int64(1),
500+
HeadBranch: String("b"),
501+
HeadSHA: String("s"),
502+
},
476503
},
477504
},
478505
}
@@ -484,10 +511,19 @@ func TestArtifactList_Marshal(t *testing.T) {
484511
"node_id": "nid",
485512
"name": "n",
486513
"size_in_bytes": 1,
514+
"url": "u",
487515
"archive_download_url": "a",
488516
"expired": false,
489517
"created_at": ` + referenceTimeStr + `,
490-
"expires_at": ` + referenceTimeStr + `
518+
"updated_at": ` + referenceTimeStr + `,
519+
"expires_at": ` + referenceTimeStr + `,
520+
"workflow_run": {
521+
"id": 1,
522+
"repository_id": 1,
523+
"head_repository_id": 1,
524+
"head_branch": "b",
525+
"head_sha": "s"
526+
}
491527
}]
492528
}`
493529

github/github-accessors.go

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)