From d3504d3e6317cda4f355deefe3ce0813d0919faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 2 Jul 2020 14:35:27 +0200 Subject: [PATCH] feat(github-actions): introduce the old frontend code --- packages/app/package.json | 1 + packages/app/src/plugins.ts | 1 + plugins/github-actions/.eslintrc.js | 3 + plugins/github-actions/README.md | 13 ++ plugins/github-actions/dev/index.tsx | 20 +++ plugins/github-actions/package.json | 47 ++++++ .../src/apis/builds/BuildsClient.ts | 44 ++++++ .../github-actions/src/apis/builds/index.ts | 18 +++ .../github-actions/src/apis/builds/types.ts | 38 +++++ .../BuildDetailsPage/BuildDetailsPage.tsx | 143 ++++++++++++++++++ .../src/components/BuildDetailsPage/index.ts | 17 +++ .../BuildInfoCard/BuildInfoCard.tsx | 102 +++++++++++++ .../src/components/BuildInfoCard/index.ts | 17 +++ .../BuildListPage/BuildListPage.tsx | 128 ++++++++++++++++ .../src/components/BuildListPage/index.ts | 17 +++ .../BuildStatusIndicator.tsx | 74 +++++++++ .../components/BuildStatusIndicator/index.ts | 17 +++ plugins/github-actions/src/index.ts | 17 +++ plugins/github-actions/src/plugin.test.ts | 23 +++ plugins/github-actions/src/plugin.ts | 37 +++++ plugins/github-actions/src/setupTests.ts | 19 +++ 21 files changed, 796 insertions(+) create mode 100644 plugins/github-actions/.eslintrc.js create mode 100644 plugins/github-actions/README.md create mode 100644 plugins/github-actions/dev/index.tsx create mode 100644 plugins/github-actions/package.json create mode 100644 plugins/github-actions/src/apis/builds/BuildsClient.ts create mode 100644 plugins/github-actions/src/apis/builds/index.ts create mode 100644 plugins/github-actions/src/apis/builds/types.ts create mode 100644 plugins/github-actions/src/components/BuildDetailsPage/BuildDetailsPage.tsx create mode 100644 plugins/github-actions/src/components/BuildDetailsPage/index.ts create mode 100644 plugins/github-actions/src/components/BuildInfoCard/BuildInfoCard.tsx create mode 100644 plugins/github-actions/src/components/BuildInfoCard/index.ts create mode 100644 plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx create mode 100644 plugins/github-actions/src/components/BuildListPage/index.ts create mode 100644 plugins/github-actions/src/components/BuildStatusIndicator/BuildStatusIndicator.tsx create mode 100644 plugins/github-actions/src/components/BuildStatusIndicator/index.ts create mode 100644 plugins/github-actions/src/index.ts create mode 100644 plugins/github-actions/src/plugin.test.ts create mode 100644 plugins/github-actions/src/plugin.ts create mode 100644 plugins/github-actions/src/setupTests.ts diff --git a/packages/app/package.json b/packages/app/package.json index e924d9bc04..e6e8254cb4 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -8,6 +8,7 @@ "@backstage/plugin-catalog": "^0.1.1-alpha.12", "@backstage/plugin-circleci": "^0.1.1-alpha.12", "@backstage/plugin-explore": "^0.1.1-alpha.12", + "@backstage/plugin-github-actions": "^0.1.1-alpha.12", "@backstage/plugin-gitops-profiles": "^0.1.1-alpha.12", "@backstage/plugin-graphiql": "^0.1.1-alpha.12", "@backstage/plugin-lighthouse": "^0.1.1-alpha.12", diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 09cd117fc0..a5461c1bea 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -25,3 +25,4 @@ export { plugin as Sentry } from '@backstage/plugin-sentry'; export { plugin as GitopsProfiles } from '@backstage/plugin-gitops-profiles'; export { plugin as TechDocs } from '@backstage/plugin-techdocs'; export { plugin as GraphiQL } from '@backstage/plugin-graphiql'; +export { plugin as GithubActions } from '@backstage/plugin-github-actions'; diff --git a/plugins/github-actions/.eslintrc.js b/plugins/github-actions/.eslintrc.js new file mode 100644 index 0000000000..13573efa9c --- /dev/null +++ b/plugins/github-actions/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: [require.resolve('@backstage/cli/config/eslint')], +}; diff --git a/plugins/github-actions/README.md b/plugins/github-actions/README.md new file mode 100644 index 0000000000..b0b339a1b0 --- /dev/null +++ b/plugins/github-actions/README.md @@ -0,0 +1,13 @@ +# github-actions + +Welcome to the github-actions plugin! + +_This plugin was created through the Backstage CLI_ + +## Getting started + +Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/github-actions](http://localhost:3000/github-actions). + +You can also serve the plugin in isolation by running `yarn start` in the plugin directory. +This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. +It is only meant for local development, and the setup for it can be found inside the [/dev](/dev) directory. diff --git a/plugins/github-actions/dev/index.tsx b/plugins/github-actions/dev/index.tsx new file mode 100644 index 0000000000..812a5585d4 --- /dev/null +++ b/plugins/github-actions/dev/index.tsx @@ -0,0 +1,20 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createDevApp } from '@backstage/dev-utils'; +import { plugin } from '../src/plugin'; + +createDevApp().registerPlugin(plugin).render(); diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json new file mode 100644 index 0000000000..13c2215dea --- /dev/null +++ b/plugins/github-actions/package.json @@ -0,0 +1,47 @@ +{ + "name": "@backstage/plugin-github-actions", + "version": "0.1.1-alpha.12", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "private": false, + "publishConfig": { + "access": "public", + "main": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "scripts": { + "build": "backstage-cli plugin:build", + "start": "backstage-cli plugin:serve", + "lint": "backstage-cli lint", + "test": "backstage-cli test", + "diff": "backstage-cli plugin:diff", + "prepack": "backstage-cli prepack", + "postpack": "backstage-cli postpack", + "clean": "backstage-cli clean" + }, + "dependencies": { + "@backstage/core": "^0.1.1-alpha.12", + "@backstage/theme": "^0.1.1-alpha.12", + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "4.0.0-alpha.45", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-router-dom": "6.0.0-beta.0", + "react-use": "^14.2.0" + }, + "devDependencies": { + "@backstage/cli": "^0.1.1-alpha.12", + "@backstage/dev-utils": "^0.1.1-alpha.12", + "@testing-library/jest-dom": "^5.10.1", + "@testing-library/react": "^10.4.1", + "@testing-library/user-event": "^12.0.7", + "@types/jest": "^25.2.2", + "@types/node": "^12.0.0", + "jest-fetch-mock": "^3.0.3" + }, + "files": [ + "dist" + ] +} diff --git a/plugins/github-actions/src/apis/builds/BuildsClient.ts b/plugins/github-actions/src/apis/builds/BuildsClient.ts new file mode 100644 index 0000000000..6fbc6a6c53 --- /dev/null +++ b/plugins/github-actions/src/apis/builds/BuildsClient.ts @@ -0,0 +1,44 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Build, BuildDetails, BuildStatus } from './types'; + +export class BuildsClient { + static create(): BuildsClient { + return new BuildsClient(); + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async listBuilds(_entityUri: string): Promise { + return []; + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async getBuild(_buildUri: string): Promise { + return { + build: { + commitId: 'TODO', + branch: 'TODO', + uri: 'TODO', + status: BuildStatus.Running, + message: 'TODO', + }, + author: 'TODO', + logUrl: 'TODO', + overviewUrl: 'TODO', + }; + } +} diff --git a/plugins/github-actions/src/apis/builds/index.ts b/plugins/github-actions/src/apis/builds/index.ts new file mode 100644 index 0000000000..9ce2150893 --- /dev/null +++ b/plugins/github-actions/src/apis/builds/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { BuildsClient } from './BuildsClient'; +export * from './types'; diff --git a/plugins/github-actions/src/apis/builds/types.ts b/plugins/github-actions/src/apis/builds/types.ts new file mode 100644 index 0000000000..134a663d02 --- /dev/null +++ b/plugins/github-actions/src/apis/builds/types.ts @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export enum BuildStatus { + Null, + Success, + Failure, + Pending, + Running, +} + +export type Build = { + commitId: string; + message: string; + branch: string; + status: BuildStatus; + uri: string; +}; + +export type BuildDetails = { + build: Build; + author: string; + logUrl: string; + overviewUrl: string; +}; diff --git a/plugins/github-actions/src/components/BuildDetailsPage/BuildDetailsPage.tsx b/plugins/github-actions/src/components/BuildDetailsPage/BuildDetailsPage.tsx new file mode 100644 index 0000000000..bb07e0d6aa --- /dev/null +++ b/plugins/github-actions/src/components/BuildDetailsPage/BuildDetailsPage.tsx @@ -0,0 +1,143 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Link } from '@backstage/core'; +import { + Button, + ButtonGroup, + LinearProgress, + makeStyles, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableRow, + Theme, + Typography, +} from '@material-ui/core'; +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { useAsync } from 'react-use'; +import { BuildsClient } from '../../apis/builds'; +import { BuildStatusIndicator } from '../BuildStatusIndicator'; + +const useStyles = makeStyles(theme => ({ + root: { + maxWidth: 720, + margin: theme.spacing(2), + }, + title: { + padding: theme.spacing(1, 0, 2, 0), + }, + table: { + padding: theme.spacing(1), + }, +})); + +const client = BuildsClient.create(); + +export const BuildDetailsPage = () => { + const classes = useStyles(); + const { buildUri } = useParams(); + const status = useAsync(() => client.getBuild(buildUri), [buildUri]); + + if (status.loading) { + return ; + } else if (status.error) { + return ( + + Failed to load build, {status.error.message} + + ); + } + + const details = status.value; + + return ( +
+ + + + < + + + Build Details + + + + + + + Branch + + {details?.build.branch} + + + + Message + + {details?.build.message} + + + + Commit ID + + {details?.build.commitId} + + + + Status + + + + + + + + Author + + {details?.author} + + + + Links + + + + {details?.overviewUrl && ( + + )} + {details?.logUrl && ( + + )} + + + + +
+
+
+ ); +}; diff --git a/plugins/github-actions/src/components/BuildDetailsPage/index.ts b/plugins/github-actions/src/components/BuildDetailsPage/index.ts new file mode 100644 index 0000000000..d59d0fc396 --- /dev/null +++ b/plugins/github-actions/src/components/BuildDetailsPage/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { BuildDetailsPage } from './BuildDetailsPage'; diff --git a/plugins/github-actions/src/components/BuildInfoCard/BuildInfoCard.tsx b/plugins/github-actions/src/components/BuildInfoCard/BuildInfoCard.tsx new file mode 100644 index 0000000000..a04189debc --- /dev/null +++ b/plugins/github-actions/src/components/BuildInfoCard/BuildInfoCard.tsx @@ -0,0 +1,102 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Link } from '@backstage/core'; +import { + LinearProgress, + makeStyles, + Table, + TableBody, + TableCell, + TableRow, + Theme, + Typography, +} from '@material-ui/core'; +import React from 'react'; +import { useAsync } from 'react-use'; +import { BuildsClient } from '../../apis/builds'; +import { BuildStatusIndicator } from '../BuildStatusIndicator'; + +const client = BuildsClient.create(); + +const useStyles = makeStyles(theme => ({ + root: { + // height: 400, + }, + title: { + paddingBottom: theme.spacing(1), + }, +})); + +export const BuildInfoCard = () => { + const classes = useStyles(); + const status = useAsync(() => client.listBuilds('entity:spotify:backstage')); + + let content: JSX.Element; + + if (status.loading) { + content = ; + } else if (status.error) { + content = ( + + Failed to load builds, {status.error.message} + + ); + } else { + const [build] = + status.value?.filter(({ branch }) => branch === 'master') ?? []; + + content = ( + + + + + Message + + + + {build?.message} + + + + + + Commit ID + + {build?.commitId} + + + + Status + + + + + + +
+ ); + } + + return ( +
+ + Master Build + + {content} +
+ ); +}; diff --git a/plugins/github-actions/src/components/BuildInfoCard/index.ts b/plugins/github-actions/src/components/BuildInfoCard/index.ts new file mode 100644 index 0000000000..a6409e682a --- /dev/null +++ b/plugins/github-actions/src/components/BuildInfoCard/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { BuildInfoCard } from './BuildInfoCard'; diff --git a/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx b/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx new file mode 100644 index 0000000000..fc784108d4 --- /dev/null +++ b/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx @@ -0,0 +1,128 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Link } from '@backstage/core'; +import { + LinearProgress, + makeStyles, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Theme, + Tooltip, + Typography, +} from '@material-ui/core'; +import React from 'react'; +import { useAsync } from 'react-use'; +import { BuildsClient } from '../../apis/builds'; +import { BuildStatusIndicator } from '../BuildStatusIndicator'; + +const client = BuildsClient.create(); + +const LongText = ({ text, max }: { text: string; max: number }) => { + if (text.length < max) { + return {text}; + } + return ( + + {text.slice(0, max)}... + + ); +}; + +const useStyles = makeStyles(theme => ({ + root: { + padding: theme.spacing(2), + }, + title: { + padding: theme.spacing(1, 0, 2, 0), + }, +})); + +const PageContents = () => { + const { loading, error, value } = useAsync(() => + client.listBuilds('entity:spotify:backstage'), + ); + + if (loading) { + return ; + } + + if (error) { + return ( + + Failed to load builds, {error.message}{' '} + + ); + } + + return ( + + + + + Status + Branch + Message + Commit + + + + {value!.map(build => ( + + + + + + + + + + + + + + + + + + + {build.commitId.slice(0, 10)} + + + + ))} + +
+
+ ); +}; + +export const BuildListPage = () => { + const classes = useStyles(); + return ( +
+ + CI/CD Builds + + +
+ ); +}; diff --git a/plugins/github-actions/src/components/BuildListPage/index.ts b/plugins/github-actions/src/components/BuildListPage/index.ts new file mode 100644 index 0000000000..2134913e51 --- /dev/null +++ b/plugins/github-actions/src/components/BuildListPage/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { BuildListPage } from './BuildListPage'; diff --git a/plugins/github-actions/src/components/BuildStatusIndicator/BuildStatusIndicator.tsx b/plugins/github-actions/src/components/BuildStatusIndicator/BuildStatusIndicator.tsx new file mode 100644 index 0000000000..332a03d67a --- /dev/null +++ b/plugins/github-actions/src/components/BuildStatusIndicator/BuildStatusIndicator.tsx @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { IconComponent } from '@backstage/core'; +import { makeStyles, Theme } from '@material-ui/core'; +import ProgressIcon from '@material-ui/icons/Autorenew'; +import SuccessIcon from '@material-ui/icons/CheckCircle'; +import FailureIcon from '@material-ui/icons/Error'; +import UnknownIcon from '@material-ui/icons/Help'; +import React from 'react'; +import { BuildStatus } from '../../apis/builds'; + +type Props = { + status?: BuildStatus; +}; + +type StatusStyle = { + icon: IconComponent; + color: string; +}; + +const styles: { [key in BuildStatus]: StatusStyle } = { + [BuildStatus.Null]: { + icon: UnknownIcon, + color: '#f49b20', + }, + [BuildStatus.Success]: { + icon: SuccessIcon, + color: '#1db855', + }, + [BuildStatus.Failure]: { + icon: FailureIcon, + color: '#CA001B', + }, + [BuildStatus.Pending]: { + icon: UnknownIcon, + color: '#5BC0DE', + }, + [BuildStatus.Running]: { + icon: ProgressIcon, + color: '#BEBEBE', + }, +}; + +const useStyles = makeStyles({ + icon: style => ({ + color: style.color, + }), +}); + +export const BuildStatusIndicator = ({ status }: Props) => { + const style = (status && styles[status]) || styles[BuildStatus.Null]; + const classes = useStyles(style); + const Icon = style.icon; + + return ( +
+ +
+ ); +}; diff --git a/plugins/github-actions/src/components/BuildStatusIndicator/index.ts b/plugins/github-actions/src/components/BuildStatusIndicator/index.ts new file mode 100644 index 0000000000..520de525ec --- /dev/null +++ b/plugins/github-actions/src/components/BuildStatusIndicator/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { BuildStatusIndicator } from './BuildStatusIndicator'; diff --git a/plugins/github-actions/src/index.ts b/plugins/github-actions/src/index.ts new file mode 100644 index 0000000000..3a0a0fe2d3 --- /dev/null +++ b/plugins/github-actions/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { plugin } from './plugin'; diff --git a/plugins/github-actions/src/plugin.test.ts b/plugins/github-actions/src/plugin.test.ts new file mode 100644 index 0000000000..fa1075cbc8 --- /dev/null +++ b/plugins/github-actions/src/plugin.test.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { plugin } from './plugin'; + +describe('github-actions', () => { + it('should export plugin', () => { + expect(plugin).toBeDefined(); + }); +}); diff --git a/plugins/github-actions/src/plugin.ts b/plugins/github-actions/src/plugin.ts new file mode 100644 index 0000000000..638c8d2c8c --- /dev/null +++ b/plugins/github-actions/src/plugin.ts @@ -0,0 +1,37 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createPlugin, createRouteRef } from '@backstage/core'; +import { BuildDetailsPage } from './components/BuildDetailsPage'; +import { BuildListPage } from './components/BuildListPage'; + +// TODO(freben): This is just a demo route for now +export const rootRouteRef = createRouteRef({ + path: '/github-actions', + title: 'GitHub Actions', +}); +export const buildRouteRef = createRouteRef({ + path: '/github-actions/builds/:buildUri', + title: 'GitHub Actions Build', +}); + +export const plugin = createPlugin({ + id: 'github-actions', + register({ router }) { + router.addRoute(rootRouteRef, BuildListPage); + router.addRoute(buildRouteRef, BuildDetailsPage); + }, +}); diff --git a/plugins/github-actions/src/setupTests.ts b/plugins/github-actions/src/setupTests.ts new file mode 100644 index 0000000000..8553642152 --- /dev/null +++ b/plugins/github-actions/src/setupTests.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import '@testing-library/jest-dom'; + +require('jest-fetch-mock').enableMocks();