Skip to content

Commit

Permalink
Implement Actions API. (#459)
Browse files Browse the repository at this point in the history
New data structures and endpoints to access the GitHub Actions API.

Commit squashed from the following commits:

* Implement actions->artifacts API.
* Up
* Cleanup
* Actions - cache.
* Actions - artifacts and cache.
* Secrets
* Workflows.
* WorkflowJobs.
* WorkflowRuns.
* Format
* Artifacts QA.
* Cache QA.
* Secrets QA.
* WorkflowJobs QA.
* Workflows QA.
* Format.
* Drop slack-related files.
* Format JSON
* Support workflow name in workflowRunsForWorkflowR.
* Support workflow name in Workflows.hs.
* Fix
* Fix
* Do not parse pull requests from workflow runs.
* Avoid parsing 'trigerring_actor', it is sometimes missing.
* Fix workflow run conclusion parsing.
* Whitespace and lexical changes only
* Remove outdated maintainer from module headers
* Whitespace: align code
* Bump cabal-version to 2.4 for globbing
* Cosmetics: use (<&>)
* Restore upper bounds for openssl etc. in .cabal file
* Whitespace
* Add haddocks for WithTotalCount
* Changelog for PR #459

---------

Co-authored-by: Andreas Abel <[email protected]>
  • Loading branch information
K0Te and andreasabel authored Jun 24, 2023
1 parent 69404f7 commit 5a26a8c
Show file tree
Hide file tree
Showing 36 changed files with 2,870 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ run.sh
src/hightlight.js
src/style.css
TAGS
.DS_Store

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## Changes for 0.29

_2022-06-24, Andreas Abel, Midsommar edition_
_2023-06-24, Andreas Abel, Midsommar edition_

- Support for the GitHub Actions API
(PR [#459](https://github.com/haskell-github/github/pull/459)):
* New endpoint modules `GitHub.EndPoints.Actions.Artifacts`, `.Cache`,
`.Secrets`, `.Workflows`, `.WorkflowRuns`, `.WorkflowJobs`.
* Matching data structure modules `GitHub.Data.Actions.*`.

- Add field `issueStateReason` of type `Maybe IssueStateReason` to `Issue`
with possible values `completed`, `not_planned` and `reopened`
Expand Down
19 changes: 19 additions & 0 deletions fixtures/actions/artifact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"id": 416767789,
"node_id": "MDg6QXJ0aWZhY3Q0MTY3Njc3ODk=",
"name": "dist-without-markdown",
"size_in_bytes": 42718,
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/artifacts/416767789",
"archive_download_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/artifacts/416767789/zip",
"expired": false,
"created_at": "2022-10-29T22:18:21Z",
"updated_at": "2022-10-29T22:18:23Z",
"expires_at": "2023-01-27T22:18:16Z",
"workflow_run": {
"id": 3353148947,
"repository_id": 559365297,
"head_repository_id": 559365297,
"head_branch": "main",
"head_sha": "601593ecb1d8a57a04700fdb445a28d4186b8954"
}
}
43 changes: 43 additions & 0 deletions fixtures/actions/artifacts-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"total_count": 23809,
"artifacts": [
{
"id": 416737084,
"node_id": "MDg6QXJ0aWZhY3Q0MTY3MzcwODQ=",
"name": "doc-html",
"size_in_bytes": 61667543,
"url": "https://api.github.com/repos/python/cpython/actions/artifacts/416737084",
"archive_download_url": "https://api.github.com/repos/python/cpython/actions/artifacts/416737084/zip",
"expired": false,
"created_at": "2022-10-29T20:56:24Z",
"updated_at": "2022-10-29T20:56:25Z",
"expires_at": "2023-01-27T20:50:21Z",
"workflow_run": {
"id": 3352897496,
"repository_id": 81598961,
"head_repository_id": 101955313,
"head_branch": "backport-bfecff5-3.11",
"head_sha": "692cd77975413d71ff0951072df686e6f38711c8"
}
},
{
"id": 416712612,
"node_id": "MDg6QXJ0aWZhY3Q0MTY3MTI2MTI=",
"name": "doc-html",
"size_in_bytes": 61217330,
"url": "https://api.github.com/repos/python/cpython/actions/artifacts/416712612",
"archive_download_url": "https://api.github.com/repos/python/cpython/actions/artifacts/416712612/zip",
"expired": false,
"created_at": "2022-10-29T19:53:19Z",
"updated_at": "2022-10-29T19:53:20Z",
"expires_at": "2023-01-27T19:49:12Z",
"workflow_run": {
"id": 3352724493,
"repository_id": 81598961,
"head_repository_id": 559335486,
"head_branch": "patch-1",
"head_sha": "62eb88a66d1d35f7701873d8b698a2f8d7e84fa5"
}
}
]
}
14 changes: 14 additions & 0 deletions fixtures/actions/cache-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"total_count": 1,
"actions_caches": [
{
"id": 1,
"ref": "refs/heads/main",
"key": "cache_key",
"version": "f5f850afdadd47730296d4ffa900de95f6bbafb75dc1e8475df1fa6ae79dcece",
"last_accessed_at": "2022-10-30T00:08:14.223333300Z",
"created_at": "2022-10-30T00:08:14.223333300Z",
"size_in_bytes": 26586
}
]
}
4 changes: 4 additions & 0 deletions fixtures/actions/org-cache-usage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"total_active_caches_size_in_bytes": 26586,
"total_active_caches_count": 1
}
4 changes: 4 additions & 0 deletions fixtures/actions/org-public-key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key_id": "568250167242549743",
"key": "KHVvOxB765kjkShEgUu27QCzl5XxKz/L20V+KRsWf0w="
}
18 changes: 18 additions & 0 deletions fixtures/actions/org-secrets-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"total_count": 2,
"secrets": [
{
"name": "TEST_SECRET",
"created_at": "2022-10-31T00:08:12Z",
"updated_at": "2022-10-31T00:08:12Z",
"visibility": "all"
},
{
"name": "TEST_SELECTED",
"created_at": "2022-10-31T00:08:43Z",
"updated_at": "2022-10-31T00:08:43Z",
"visibility": "selected",
"selected_repositories_url": "https://api.github.com/orgs/kote-test-org-actions/actions/secrets/TEST_SELECTED/repositories"
}
]
}
5 changes: 5 additions & 0 deletions fixtures/actions/repo-cache-usage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"full_name": "python/cpython",
"active_caches_size_in_bytes": 55000268087,
"active_caches_count": 171
}
72 changes: 72 additions & 0 deletions fixtures/actions/selected-repositories-for-secret.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"total_count": 1,
"repositories": [
{
"id": 559365297,
"node_id": "R_kgDOIVc8sQ",
"name": "actions-api",
"full_name": "kote-test-org-actions/actions-api",
"private": true,
"owner": {
"login": "kote-test-org-actions",
"id": 116976977,
"node_id": "O_kgDOBvjtUQ",
"avatar_url": "https://avatars.githubusercontent.com/u/116976977?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kote-test-org-actions",
"html_url": "https://github.com/kote-test-org-actions",
"followers_url": "https://api.github.com/users/kote-test-org-actions/followers",
"following_url": "https://api.github.com/users/kote-test-org-actions/following{/other_user}",
"gists_url": "https://api.github.com/users/kote-test-org-actions/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kote-test-org-actions/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kote-test-org-actions/subscriptions",
"organizations_url": "https://api.github.com/users/kote-test-org-actions/orgs",
"repos_url": "https://api.github.com/users/kote-test-org-actions/repos",
"events_url": "https://api.github.com/users/kote-test-org-actions/events{/privacy}",
"received_events_url": "https://api.github.com/users/kote-test-org-actions/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/kote-test-org-actions/actions-api",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api",
"forks_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/forks",
"keys_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/teams",
"hooks_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/hooks",
"issue_events_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues/events{/number}",
"events_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/events",
"assignees_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/assignees{/user}",
"branches_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/branches{/branch}",
"tags_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/tags",
"blobs_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/statuses/{sha}",
"languages_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/languages",
"stargazers_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/stargazers",
"contributors_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/contributors",
"subscribers_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/subscribers",
"subscription_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/subscription",
"commits_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/contents/{+path}",
"compare_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/merges",
"archive_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/downloads",
"issues_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues{/number}",
"pulls_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/pulls{/number}",
"milestones_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/milestones{/number}",
"notifications_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/labels{/name}",
"releases_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/releases{/id}",
"deployments_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/deployments"
}
]
}
113 changes: 113 additions & 0 deletions fixtures/actions/workflow-job.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"id": 9183275828,
"run_id": 3353449941,
"run_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/runs/3353449941",
"run_attempt": 1,
"node_id": "CR_kwDOIVc8sc8AAAACI12rNA",
"head_sha": "3156f684232a3adec5085c920d2006aca80f2798",
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/jobs/9183275828",
"html_url": "https://github.com/kote-test-org-actions/actions-api/actions/runs/3353449941/jobs/5556228789",
"status": "completed",
"conclusion": "success",
"started_at": "2022-10-30T00:09:29Z",
"completed_at": "2022-10-30T00:09:49Z",
"name": "check-bats-version",
"steps": [
{
"name": "Set up job",
"status": "completed",
"conclusion": "success",
"number": 1,
"started_at": "2022-10-29T17:09:29.000-07:00",
"completed_at": "2022-10-29T17:09:32.000-07:00"
},
{
"name": "Run actions/checkout@v3",
"status": "completed",
"conclusion": "success",
"number": 2,
"started_at": "2022-10-29T17:09:32.000-07:00",
"completed_at": "2022-10-29T17:09:33.000-07:00"
},
{
"name": "Run actions/setup-node@v3",
"status": "completed",
"conclusion": "success",
"number": 3,
"started_at": "2022-10-29T17:09:34.000-07:00",
"completed_at": "2022-10-29T17:09:39.000-07:00"
},
{
"name": "Run npm install -g bats",
"status": "completed",
"conclusion": "success",
"number": 4,
"started_at": "2022-10-29T17:09:40.000-07:00",
"completed_at": "2022-10-29T17:09:42.000-07:00"
},
{
"name": "Run bats -v",
"status": "completed",
"conclusion": "success",
"number": 5,
"started_at": "2022-10-29T17:09:42.000-07:00",
"completed_at": "2022-10-29T17:09:42.000-07:00"
},
{
"name": "Archive Test",
"status": "completed",
"conclusion": "success",
"number": 6,
"started_at": "2022-10-29T17:09:42.000-07:00",
"completed_at": "2022-10-29T17:09:46.000-07:00"
},
{
"name": "Cache",
"status": "completed",
"conclusion": "success",
"number": 7,
"started_at": "2022-10-29T17:09:46.000-07:00",
"completed_at": "2022-10-29T17:09:47.000-07:00"
},
{
"name": "Post Cache",
"status": "completed",
"conclusion": "success",
"number": 12,
"started_at": "2022-10-29T17:09:49.000-07:00",
"completed_at": "2022-10-29T17:09:47.000-07:00"
},
{
"name": "Post Run actions/setup-node@v3",
"status": "completed",
"conclusion": "success",
"number": 13,
"started_at": "2022-10-29T17:09:49.000-07:00",
"completed_at": "2022-10-29T17:09:49.000-07:00"
},
{
"name": "Post Run actions/checkout@v3",
"status": "completed",
"conclusion": "success",
"number": 14,
"started_at": "2022-10-29T17:09:49.000-07:00",
"completed_at": "2022-10-29T17:09:49.000-07:00"
},
{
"name": "Complete job",
"status": "completed",
"conclusion": "success",
"number": 15,
"started_at": "2022-10-29T17:09:47.000-07:00",
"completed_at": "2022-10-29T17:09:47.000-07:00"
}
],
"check_run_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/check-runs/9183275828",
"labels": [
"ubuntu-latest"
],
"runner_id": 1,
"runner_name": "Hosted Agent",
"runner_group_id": 2,
"runner_group_name": "GitHub Actions"
}
17 changes: 17 additions & 0 deletions fixtures/actions/workflow-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"total_count": 1,
"workflows": [
{
"id": 39065091,
"node_id": "W_kwDOIVc8sc4CVBYD",
"name": "learn-github-actions",
"path": ".github/workflows/make_artifact.yaml",
"state": "active",
"created_at": "2022-10-29T15:17:59.000-07:00",
"updated_at": "2022-10-29T15:17:59.000-07:00",
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/workflows/39065091",
"html_url": "https://github.com/kote-test-org-actions/actions-api/blob/main/.github/workflows/make_artifact.yaml",
"badge_url": "https://github.com/kote-test-org-actions/actions-api/workflows/learn-github-actions/badge.svg"
}
]
}
Loading

0 comments on commit 5a26a8c

Please sign in to comment.