+
Skip to content

Add the URL, UpdateAt, and WorkflowRun fields to Artifacts #2660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions github/actions_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,34 @@ import (
"net/url"
)

// Artifact reprents a GitHub artifact. Artifacts allow sharing
// ArtifactWorkflowRun represents a GitHub artifact's workflow run.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
type ArtifactWorkflowRun struct {
ID *int64 `json:"id,omitempty"`
RepositoryID *int64 `json:"repository_id,omitempty"`
HeadRepositoryID *int64 `json:"head_repository_id,omitempty"`
HeadBranch *string `json:"head_branch,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"`
}

// Artifact represents a GitHub artifact. Artifacts allow sharing
// data between jobs in a workflow and provide storage for data
// once a workflow is complete.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
type Artifact struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Name *string `json:"name,omitempty"`
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
Expired *bool `json:"expired,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Name *string `json:"name,omitempty"`
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
URL *string `json:"url,omitempty"`
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
Expired *bool `json:"expired,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"`
}

// ArtifactList represents a list of GitHub artifacts.
Expand Down
40 changes: 38 additions & 2 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,39 @@ func TestArtifact_Marshal(t *testing.T) {
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
URL: String("u"),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
WorkflowRun: &ArtifactWorkflowRun{
ID: Int64(1),
RepositoryID: Int64(1),
HeadRepositoryID: Int64(1),
HeadBranch: String("b"),
HeadSHA: String("s"),
},
}

want := `{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
}
}`

testJSONMarshal(t, u, want)
Expand All @@ -469,10 +487,19 @@ func TestArtifactList_Marshal(t *testing.T) {
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
URL: String("u"),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
WorkflowRun: &ArtifactWorkflowRun{
ID: Int64(1),
RepositoryID: Int64(1),
HeadRepositoryID: Int64(1),
HeadBranch: String("b"),
HeadSHA: String("s"),
},
},
},
}
Expand All @@ -484,10 +511,19 @@ func TestArtifactList_Marshal(t *testing.T) {
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
}
}]
}`

Expand Down
64 changes: 64 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载