Upgrade @octokit/rest to 19.0.3

This upgrade contains changes to the API types which leads to several changes
around the code base handling the now more precise types.

Signed-off-by: Crevil <bjoern.soerensen@gmail.com>
This commit is contained in:
Crevil
2022-07-09 09:13:07 +02:00
parent 5e6ef0a660
commit 9de15a41d7
19 changed files with 184 additions and 67 deletions
+12
View File
@@ -0,0 +1,12 @@
---
'example-app': patch
'example-backend': patch
'@backstage/backend-common': patch
'@backstage/integration': patch
'@backstage/plugin-catalog-import': patch
'@backstage/plugin-git-release-manager': patch
'@backstage/plugin-github-actions': patch
'@backstage/plugin-github-pull-requests-board': patch
---
Upgrade @octokit/rest to 19.0.3
+1 -1
View File
@@ -59,7 +59,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.14.0",
"@octokit/rest": "^18.12.0",
"@octokit/rest": "^19.0.3",
"@spotify/prettier-config": "^13.0.0",
"@types/node": "^16.11.26",
"@types/webpack": "^5.28.0",
+1 -1
View File
@@ -65,7 +65,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"@roadiehq/backstage-plugin-buildkite": "^2.0.0",
"@roadiehq/backstage-plugin-github-insights": "^2.0.0",
"@roadiehq/backstage-plugin-github-pull-requests": "^2.0.0",
+1 -1
View File
@@ -42,7 +42,7 @@
"@backstage/types": "^1.0.0",
"@google-cloud/storage": "^6.0.0",
"@manypkg/get-packages": "^1.1.3",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"@types/cors": "^2.8.6",
"@types/dockerode": "^3.3.0",
"@types/express": "^4.17.6",
+1 -1
View File
@@ -60,7 +60,7 @@
"@backstage/plugin-tech-insights-backend-module-jsonfc": "^0.1.18-next.1",
"@backstage/plugin-todo-backend": "^0.1.31-next.1",
"@gitbeaker/node": "^35.1.0",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"better-sqlite3": "^7.5.0",
"azure-devops-node-api": "^11.0.1",
"dockerode": "^3.3.1",
+1 -1
View File
@@ -37,7 +37,7 @@
"@backstage/errors": "^1.1.0-next.0",
"cross-fetch": "^3.1.5",
"git-url-parse": "^12.0.0",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"@octokit/auth-app": "^4.0.0",
"luxon": "^2.0.2",
"lodash": "^4.17.21"
@@ -119,7 +119,7 @@ class GithubAppManager {
const repos = await installationClient.paginate(
installationClient.apps.listReposAccessibleToInstallation,
);
const hasRepo = repos.some(repository => {
const hasRepo = repos.repositories.some(repository => {
return repository.name === repo;
});
if (!hasRepo) {
+1 -1
View File
@@ -46,7 +46,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"git-url-parse": "^12.0.0",
"js-base64": "^3.6.0",
"lodash": "^4.17.21",
+1 -1
View File
@@ -31,7 +31,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"luxon": "^2.0.2",
"qs": "^6.10.1",
"react-router": "6.0.0-beta.0",
+1 -1
View File
@@ -45,7 +45,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@octokit/rest": "^18.5.3",
"@octokit/rest": "^19.0.3",
"luxon": "^2.0.2",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
@@ -4,8 +4,9 @@
"node_id": "MDEyOldvcmtmbG93IFJ1bjI2OTI4OQ==",
"check_suite_id": 42,
"check_suite_node_id": "MDEwOkNoZWNrU3VpdGU0Mg==",
"head_branch": "master",
"head_branch": "main",
"head_sha": "acb5820ced9479c074f688cc328bf03f341a511d",
"path": ".github/workflows/build.yml@main",
"run_number": 562,
"event": "push",
"status": "queued",
@@ -16,12 +17,71 @@
"pull_requests": [],
"created_at": "2020-01-22T19:33:08Z",
"updated_at": "2020-01-22T19:33:08Z",
"actor": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"run_attempt": 1,
"referenced_workflows": [
{
"path": "octocat/Hello-World/.github/workflows/deploy.yml@main",
"sha": "86e8bc9ecf7d38b1ed2d2cfb8eb87ba9b35b01db",
"ref": "refs/heads/main"
},
{
"path": "octo-org/octo-repo/.github/workflows/report.yml@v2",
"sha": "79e9790903e1c3373b1a3e3a941d57405478a232",
"ref": "refs/tags/v2"
},
{
"path": "octo-org/octo-repo/.github/workflows/secure.yml@1595d4b6de6a9e9751fb270a41019ce507d4099e",
"sha": "1595d4b6de6a9e9751fb270a41019ce507d4099e"
}
],
"run_started_at": "2020-01-22T19:33:08Z",
"triggering_actor": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"jobs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/jobs",
"logs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/logs",
"check_suite_url": "https://api.github.com/repos/octo-org/octo-repo/check-suites/414944374",
"artifacts_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/artifacts",
"cancel_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/cancel",
"rerun_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/rerun",
"previous_attempt_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/attempts/1",
"workflow_url": "https://api.github.com/repos/octo-org/octo-repo/actions/workflows/159038",
"head_commit": {
"id": "acb5820ced9479c074f688cc328bf03f341a511d",
+6 -6
View File
@@ -19,19 +19,19 @@ export type Step = {
status: string;
conclusion?: string;
number: number; // starts from 1
started_at: string;
completed_at: string;
started_at?: string;
completed_at?: string;
};
export type Job = {
html_url: string;
html_url?: string;
status: string;
conclusion: string;
conclusion?: string;
started_at: string;
completed_at: string;
completed_at?: string;
id: number;
name: string;
steps: Step[];
steps?: Step[];
};
export type Jobs = {
@@ -18,7 +18,7 @@ import { useEntity } from '@backstage/plugin-catalog-react';
import React, { useEffect } from 'react';
import { generatePath, Link as RouterLink } from 'react-router-dom';
import { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
import { Typography } from '@material-ui/core';
@@ -90,7 +90,7 @@ export const RecentWorkflowRunsCard = ({
</Typography>
</div>
) : (
<Table
<Table<WorkflowRun>
isLoading={loading}
options={{
search: false,
@@ -107,7 +107,7 @@ export const RecentWorkflowRunsCard = ({
component={RouterLink}
to={generatePath('./ci-cd/:id', { id: data.id! })}
>
{firstLine(data.message)}
{firstLine(data.message || '')}
</Link>
),
},
@@ -73,7 +73,10 @@ const useStyles = makeStyles<Theme>(theme => ({
},
}));
const getElapsedTime = (start: string, end: string) => {
const getElapsedTime = (start: string | undefined, end: string | undefined) => {
if (!start || !end) {
return '';
}
const startDate = DateTime.fromISO(start);
const endDate = end ? DateTime.fromISO(end) : DateTime.now();
const diff = endDate.diff(startDate);
@@ -127,7 +130,7 @@ const JobListItem = ({
<AccordionDetails className={classes.accordionDetails}>
<TableContainer>
<Table>
{job.steps.map(step => (
{job.steps?.map(step => (
<StepView key={step.number} step={step} />
))}
</Table>
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import useAsync from 'react-use/lib/useAsync';
import { githubActionsApiRef } from '../../api';
import useAsync, { AsyncState } from 'react-use/lib/useAsync';
import { githubActionsApiRef, Job, Jobs, Step } from '../../api';
import { buildRouteRef } from '../../routes';
import { useApi, useRouteRefParams } from '@backstage/core-plugin-api';
@@ -26,18 +26,41 @@ export const useWorkflowRunJobs = ({
hostname?: string;
owner: string;
repo: string;
}) => {
}): AsyncState<Jobs> => {
const api = useApi(githubActionsApiRef);
const { id } = useRouteRefParams(buildRouteRef);
const jobs = useAsync(async () => {
return repo && owner
? api.listJobsForWorkflowRun({
hostname,
owner,
repo,
id: parseInt(id, 10),
})
: Promise.reject(new Error('No repo/owner provided'));
return useAsync(async () => {
if (!repo || !owner) {
throw new Error('No repo/owner provided');
}
const jobs = await api.listJobsForWorkflowRun({
hostname,
owner,
repo,
id: parseInt(id, 10),
});
return {
total_count: jobs.total_count,
jobs: jobs.jobs.map<Job>(job => ({
html_url: job.html_url || undefined,
status: job.status,
conclusion: job.conclusion || undefined,
started_at: job.started_at,
completed_at: job.completed_at || undefined,
id: job.id,
name: job.name,
steps: job.steps?.map<Step>(step => ({
name: step.name,
status: step.status,
conclusion: step.conclusion || undefined,
number: step.number,
started_at: step.started_at || undefined,
completed_at: step.completed_at || undefined,
})),
})),
};
}, [repo, owner, id]);
return jobs;
};
@@ -28,8 +28,8 @@ export const WorkflowRunStatus = ({
status,
conclusion,
}: {
status: string | undefined;
conclusion: string | undefined;
status?: string;
conclusion?: string;
}) => {
if (status === undefined) return null;
switch (status.toLocaleLowerCase('en-US')) {
@@ -19,20 +19,20 @@ import { githubActionsApiRef } from '../api/GithubActionsApi';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export type WorkflowRun = {
workflowName: string;
workflowName?: string;
id: string;
message: string;
message?: string;
url?: string;
githubUrl?: string;
source: {
branchName: string;
branchName?: string;
commit: {
hash: string;
hash?: string;
url?: string;
};
};
status: string;
conclusion: string;
status?: string;
conclusion?: string;
onReRunClick: () => void;
};
@@ -75,8 +75,8 @@ export function useWorkflowRuns({
setTotal(workflowRunsData.total_count);
// Transformation here
return workflowRunsData.workflow_runs.map(run => ({
workflowName: run.name,
message: run.head_commit.message,
workflowName: run.name || undefined,
message: run.head_commit?.message,
id: `${run.id}`,
onReRunClick: async () => {
try {
@@ -91,17 +91,17 @@ export function useWorkflowRuns({
}
},
source: {
branchName: run.head_branch,
branchName: run.head_branch || undefined,
commit: {
hash: run.head_commit.id,
hash: run.head_commit?.id,
url: run.head_repository?.branches_url?.replace(
'{/branch}',
run.head_branch,
run.head_branch || '',
),
},
},
status: run.status,
conclusion: run.conclusion,
status: run.status || undefined,
conclusion: run.conclusion || undefined,
url: run.url,
githubUrl: run.html_url,
}));
@@ -44,7 +44,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.57",
"@octokit/rest": "^18.12.0",
"@octokit/rest": "^19.0.3",
"moment": "^2.29.1",
"react-use": "^17.2.4"
},
+36 -17
View File
@@ -5026,6 +5026,11 @@
resolved "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.4.0.tgz#fd8bf5db72bd566c5ba2cb76754512a9ebe66e71"
integrity sha512-Npcb7Pv30b33U04jvcD7l75yLU0mxhuX2Xqrn51YyZ5WTkF04bpbxLaZ6GcaTqu03WZQHoO/Gbfp95NGRueDUA==
"@octokit/openapi-types@^12.7.0":
version "12.8.0"
resolved "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.8.0.tgz#f4708cf948724d6e8f7d878cfd91584c1c5c0523"
integrity sha512-ydcKLs2KKcxlhpdWLzJxEBDEk/U5MUeqtqkXlrtAUXXFPs6vLl1PEGghFC/BbpleosB7iXs0Z4P2DGe7ZT5ZNg==
"@octokit/openapi-types@^7.3.2":
version "7.3.2"
resolved "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-7.3.2.tgz#065ce49b338043ec7f741316ce06afd4d459d944"
@@ -5036,7 +5041,7 @@
resolved "https://registry.npmjs.org/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-6.0.1.tgz#e07896739618dab8da7d4077c658003775f95437"
integrity sha512-93uGjlhUD+iNg1iWhUENAtJata6w5nE+V4urXOAlIXdco6xNZtUSfYY8dzp3Udy74aqO/B5UZL80x/YMa5PKRw==
"@octokit/plugin-paginate-rest@^2.13.3", "@octokit/plugin-paginate-rest@^2.16.8":
"@octokit/plugin-paginate-rest@^2.13.3":
version "2.17.0"
resolved "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7"
integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==
@@ -5057,6 +5062,13 @@
dependencies:
"@octokit/types" "^6.0.1"
"@octokit/plugin-paginate-rest@^3.0.0":
version "3.0.0"
resolved "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-3.0.0.tgz#df779de686aeb21b5e776e4318defc33b0418566"
integrity sha512-fvw0Q5IXnn60D32sKeLIxgXCEZ7BTSAjJd8cFAE6QU5qUp0xo7LjFUjjX1J5D7HgN355CN4EXE4+Q1/96JaNUA==
dependencies:
"@octokit/types" "^6.39.0"
"@octokit/plugin-request-log@^1.0.2":
version "1.0.2"
resolved "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.2.tgz#394d59ec734cd2f122431fbaf05099861ece3c44"
@@ -5075,14 +5087,6 @@
"@octokit/types" "^6.16.2"
deprecation "^2.3.1"
"@octokit/plugin-rest-endpoint-methods@^5.12.0":
version "5.13.0"
resolved "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba"
integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==
dependencies:
"@octokit/types" "^6.34.0"
deprecation "^2.3.1"
"@octokit/plugin-rest-endpoint-methods@^5.14.0":
version "5.15.0"
resolved "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.15.0.tgz#6c8251b55c33315a6e53e5b55654f72023ed5049"
@@ -5091,6 +5095,14 @@
"@octokit/types" "^6.36.0"
deprecation "^2.3.1"
"@octokit/plugin-rest-endpoint-methods@^6.0.0":
version "6.0.0"
resolved "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-6.0.0.tgz#e4a55d83ec5a00e6b4d7a780f4ec9009095bff6f"
integrity sha512-9LkEvZB3WDuayEI381O5A/eM3QQioBZrwymQp5CUCNz9UMP/yZAIqBjcPhVJJFA3IRkKO1EARo98OePt9i0rkQ==
dependencies:
"@octokit/types" "^6.39.0"
deprecation "^2.3.1"
"@octokit/plugin-retry@^3.0.9":
version "3.0.9"
resolved "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.9.tgz#ae625cca1e42b0253049102acd71c1d5134788fe"
@@ -5150,15 +5162,15 @@
"@octokit/plugin-request-log" "^1.0.2"
"@octokit/plugin-rest-endpoint-methods" "5.3.1"
"@octokit/rest@^18.12.0":
version "18.12.0"
resolved "https://registry.npmjs.org/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881"
integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q==
"@octokit/rest@^19.0.3":
version "19.0.3"
resolved "https://registry.npmjs.org/@octokit/rest/-/rest-19.0.3.tgz#b9a4e8dc8d53e030d611c053153ee6045f080f02"
integrity sha512-5arkTsnnRT7/sbI4fqgSJ35KiFaN7zQm0uQiQtivNQLI8RQx8EHwJCajcTUwmaCMNDg7tdCvqAnc7uvHHPxrtQ==
dependencies:
"@octokit/core" "^3.5.1"
"@octokit/plugin-paginate-rest" "^2.16.8"
"@octokit/core" "^4.0.0"
"@octokit/plugin-paginate-rest" "^3.0.0"
"@octokit/plugin-request-log" "^1.0.4"
"@octokit/plugin-rest-endpoint-methods" "^5.12.0"
"@octokit/plugin-rest-endpoint-methods" "^6.0.0"
"@octokit/types@^5.0.0", "@octokit/types@^5.0.1":
version "5.5.0"
@@ -5188,6 +5200,13 @@
dependencies:
"@octokit/openapi-types" "^12.4.0"
"@octokit/types@^6.39.0":
version "6.39.0"
resolved "https://registry.npmjs.org/@octokit/types/-/types-6.39.0.tgz#46ce28ca59a3d4bac0e487015949008302e78eee"
integrity sha512-Mq4N9sOAYCitTsBtDdRVrBE80lIrMBhL9Jbrw0d+j96BAzlq4V+GLHFJbHokEsVvO/9tQupQdoFdgVYhD2C8UQ==
dependencies:
"@octokit/openapi-types" "^12.7.0"
"@octokit/webhooks-methods@^3.0.0":
version "3.0.0"
resolved "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-3.0.0.tgz#4f4443605233f46abc5f85a857ba105095aa1181"
@@ -12549,7 +12568,7 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
"@material-ui/core" "^4.12.2"
"@material-ui/icons" "^4.9.1"
"@material-ui/lab" "4.0.0-alpha.57"
"@octokit/rest" "^18.5.3"
"@octokit/rest" "^19.0.3"
"@roadiehq/backstage-plugin-buildkite" "^2.0.0"
"@roadiehq/backstage-plugin-github-insights" "^2.0.0"
"@roadiehq/backstage-plugin-github-pull-requests" "^2.0.0"