From 9d977ccb9c3e8cd4a7ccc55dc4b494a17e572828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 23 Mar 2020 08:47:12 +0100 Subject: [PATCH 1/7] Fix act() warnings on newly created plugin test run --- packages/cli/templates/default-plugin/package.json.hbs | 3 ++- .../ExampleComponent/ExampleComponent.test.tsx.hbs | 2 ++ .../ExampleFetchComponent.test.tsx.hbs | 6 ++++-- packages/cli/templates/default-plugin/src/setupTests.ts | 1 + scripts/cli-e2e-test.js | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index c6587f326e..20b78a268b 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -12,7 +12,8 @@ }, "devDependencies": { "@spotify-backstage/cli": "^{{version}}", - "@types/testing-library__jest-dom": "5.0.2" + "@types/testing-library__jest-dom": "5.0.2", + "jest-fetch-mock": "^3.0.3" }, "dependencies": { "@material-ui/lab": "4.0.0-alpha.45" diff --git a/packages/cli/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs b/packages/cli/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs index 69884c6a44..360055dc3d 100644 --- a/packages/cli/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +++ b/packages/cli/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs @@ -16,12 +16,14 @@ import React from 'react'; import { render } from '@testing-library/react'; +import mockFetch from 'jest-fetch-mock'; import ExampleComponent from './ExampleComponent'; import { ThemeProvider } from '@material-ui/core'; import { BackstageTheme } from '@spotify-backstage/core'; describe('ExampleComponent', () => { it('should render', () => { + mockFetch.mockResponse(() => new Promise(() => {})); const rendered = render( diff --git a/packages/cli/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs b/packages/cli/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs index 7dff1e6ccc..7fecdc6f11 100644 --- a/packages/cli/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +++ b/packages/cli/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs @@ -16,11 +16,13 @@ import React from 'react'; import { render } from '@testing-library/react'; +import mockFetch from 'jest-fetch-mock'; import ExampleFetchComponent from './ExampleFetchComponent'; describe('ExampleFetchComponent', () => { - it('should render', () => { + it('should render', async () => { + mockFetch.mockResponse(() => new Promise(() => {})); const rendered = render(); - expect(rendered.getByTestId('progress')).toBeInTheDocument(); + expect(await rendered.findByTestId('progress')).toBeInTheDocument(); }); }); diff --git a/packages/cli/templates/default-plugin/src/setupTests.ts b/packages/cli/templates/default-plugin/src/setupTests.ts index 8925258421..1a907ab8e6 100644 --- a/packages/cli/templates/default-plugin/src/setupTests.ts +++ b/packages/cli/templates/default-plugin/src/setupTests.ts @@ -15,3 +15,4 @@ */ import '@testing-library/jest-dom/extend-expect'; +require('jest-fetch-mock').enableMocks(); diff --git a/scripts/cli-e2e-test.js b/scripts/cli-e2e-test.js index 10be71b1c4..b495a37440 100644 --- a/scripts/cli-e2e-test.js +++ b/scripts/cli-e2e-test.js @@ -37,7 +37,8 @@ async function main() { const createPlugin = spawnPiped(['yarn', 'create-plugin']); createPlugin.stdin.write('test-plugin\n'); - await new Promise(resolve => setTimeout(resolve, 2000)); + // TODO: Add code to await the right prompts from create-plugin stdout instead + await new Promise(resolve => setTimeout(resolve, 5000)); createPlugin.stdin.write('@someuser\n'); print('Waiting for plugin create script to be done'); From 1d3a8c110cf30a8630e35c5973abca00c9b49180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 23 Mar 2020 11:53:42 +0100 Subject: [PATCH 2/7] Better waiting --- scripts/cli-e2e-test.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/cli-e2e-test.js b/scripts/cli-e2e-test.js index b495a37440..3d4b9c04d1 100644 --- a/scripts/cli-e2e-test.js +++ b/scripts/cli-e2e-test.js @@ -36,9 +36,16 @@ async function main() { print('Backstage loaded correctly, creating plugin'); const createPlugin = spawnPiped(['yarn', 'create-plugin']); + + let stdout = ''; + createPlugin.stdout.on('data', data => { + stdout = stdout + data.toString('utf8'); + }); + + await waitFor(() => stdout.includes('Enter an ID for the plugin')); createPlugin.stdin.write('test-plugin\n'); - // TODO: Add code to await the right prompts from create-plugin stdout instead - await new Promise(resolve => setTimeout(resolve, 5000)); + + await waitFor(() => stdout.includes('Enter the owner(s) of the plugin')); createPlugin.stdin.write('@someuser\n'); print('Waiting for plugin create script to be done'); @@ -60,6 +67,18 @@ async function main() { process.exit(0); } +function waitFor(fn) { + return new Promise(resolve => { + const handle = setInterval(() => { + if (fn()) { + clearInterval(handle); + resolve(); + return; + } + }, 100); + }); +} + function print(msg) { return process.stdout.write(`${msg}\n`); } @@ -118,7 +137,7 @@ async function waitForPageWithText( browser, path, text, - { intervalMs = 1000, maxAttempts = 60 } = {}, + { intervalMs = 1000, maxAttempts = 120 } = {}, ) { let attempts = 0; for (;;) { From d154669e0caba095a696f04d039c50d808bd9374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 23 Mar 2020 14:44:23 +0100 Subject: [PATCH 3/7] Require node 12 --- .npmrc | 1 + package.json | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.npmrc b/.npmrc index 214c29d139..c3c66347fd 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ registry=https://registry.npmjs.org/ +engine-strict=true diff --git a/package.json b/package.json index 1370c7eec8..75c1dd7474 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "root", "private": true, + "engines": { + "node": ">=12.0.0" + }, "scripts": { "start": "yarn build && yarn workspace @spotify-backstage/app start", "build": "lerna run build", From 4852485f9a16d02c19f5970561d8d567048c288b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 23 Mar 2020 16:58:16 +0100 Subject: [PATCH 4/7] package/core: move storybook to separate private and nohoist package --- packages/core/package.json | 13 ++----------- packages/storybook/.storybook/main.js | 22 ++++++++++++++++++++++ packages/storybook/package.json | 21 +++++++++++++++++++++ yarn.lock | 6 +++--- 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 packages/storybook/.storybook/main.js create mode 100644 packages/storybook/package.json diff --git a/packages/core/package.json b/packages/core/package.json index 05ee131bc9..b6ceeb42f2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -8,9 +8,7 @@ "scripts": { "build": "tsc --outDir dist/cjs --noEmit false --module CommonJS", "lint": "backstage-cli lint", - "test": "backstage-cli test", - "storybook": "start-storybook -p 6006", - "build-storybook": "build-storybook" + "test": "backstage-cli test" }, "dependencies": { "@material-ui/core": "^4.9.1", @@ -28,17 +26,10 @@ "recompose": "0.30.0" }, "devDependencies": { - "@babel/core": "^7.9.0", "@spotify-backstage/cli": "^0.1.0", - "@storybook/addon-actions": "^5.3.17", - "@storybook/addon-links": "^5.3.17", - "@storybook/addons": "^5.3.17", - "@storybook/react": "^5.3.17", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", - "babel-loader": "^8.1.0", - "prop-types": "^15.7.2", - "ts-loader": "^6.2.1" + "prop-types": "^15.7.2" } } diff --git a/packages/storybook/.storybook/main.js b/packages/storybook/.storybook/main.js new file mode 100644 index 0000000000..7a51d41e0d --- /dev/null +++ b/packages/storybook/.storybook/main.js @@ -0,0 +1,22 @@ +module.exports = { + stories: [ + '../../core/src/layout/**/*.stories.tsx', + '../../core/src/components/**/*.stories.tsx', + ], + addons: ['@storybook/addon-actions', '@storybook/addon-links'], + webpackFinal: async config => { + config.module.rules.push({ + test: /\.(ts|tsx)$/, + use: [ + { + loader: require.resolve('ts-loader'), + options: { + transpileOnly: true, + }, + }, + ], + }); + config.resolve.extensions.push('.ts', '.tsx'); + return config; + }, +}; diff --git a/packages/storybook/package.json b/packages/storybook/package.json new file mode 100644 index 0000000000..f4e3b9d0ed --- /dev/null +++ b/packages/storybook/package.json @@ -0,0 +1,21 @@ +{ + "name": "storybook", + "version": "0.0.0", + "description": "Storybook build for core package", + "private": true, + "scripts": { + "start": "start-storybook -p 6006", + "build-storybook": "build-storybook --output-dir dist" + }, + "workspaces": { + "nohoist": [ + "@storybook/**" + ] + }, + "devDependencies": { + "@storybook/addon-actions": "^5.3.17", + "@storybook/addon-links": "^5.3.17", + "@storybook/addons": "^5.3.17", + "@storybook/react": "^5.3.17" + } +} diff --git a/yarn.lock b/yarn.lock index eaacf83d37..78f006747e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25,7 +25,7 @@ invariant "^2.2.4" semver "^5.5.0" -"@babel/core@7.9.0", "@babel/core@^7.1.0", "@babel/core@^7.4.5", "@babel/core@^7.7.5", "@babel/core@^7.9.0": +"@babel/core@7.9.0", "@babel/core@^7.1.0", "@babel/core@^7.4.5", "@babel/core@^7.7.5": version "7.9.0" resolved "https://registry.npmjs.org/@babel/core/-/core-7.9.0.tgz#ac977b538b77e132ff706f3b8a4dbad09c03c56e" integrity sha512-kWc7L0fw1xwvI0zi8OKVBuxRVefwGOrKSQMvrQ3dW+bIIavBY3/NpXmpjMy7bQnLgwgzWQZ8TlM57YHpHNHz4w== @@ -4688,7 +4688,7 @@ babel-jest@^25.1.0: chalk "^3.0.0" slash "^3.0.0" -babel-loader@8.1.0, babel-loader@^8.1.0: +babel-loader@8.1.0: version "8.1.0" resolved "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz#c611d5112bd5209abe8b9fa84c3e4da25275f1c3" integrity sha512-7q7nC1tYOrqvUrN3LQK4GwSk/TQorZSOlO9C+RZDZpODgyN4ZlCqE5q9cDsyWOliN+aU9B4JX01xK9eJXowJLw== @@ -12713,7 +12713,7 @@ minimist-options@^3.0.1: arrify "^1.0.1" is-plain-obj "^1.1.0" -minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: +minimist@1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= From f629c288ee81d9e0a195497d51598e7a3febe71d Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Tue, 24 Mar 2020 08:51:17 +0100 Subject: [PATCH 5/7] Add faq about repo managers --- docs/FAQ.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/FAQ.md b/docs/FAQ.md index 3e0093355e..0945ef696a 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -20,3 +20,12 @@ Additional open sourced plugins would be added to the `plugins` directory in thi While we encourage using the open soure model, integrators that want to experiment with Backstage internally may also choose to develop closed source plugins in a manner that suits them best, for example in their respective Backstage source repository. + +## Any plans for integrating with other repository managers such as Gitlab or Bitbucket? + +We chose Github by the fact that it is the tool that we are most familiar with and that will naturally +lead to integrations for Github specifically being developed in an early stage. + +Hosting this project on Github does not exclude integrations with other alternatives such as Gitlab or +Bitbucket. We believe that in time there will be plugins that will provide functionality for these tools +as well. Hopefully contributed by the community. From 6b8f0d3961d0c86447996726271ad91346f261dd Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Tue, 24 Mar 2020 09:06:42 +0100 Subject: [PATCH 6/7] Review comment --- docs/FAQ.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/FAQ.md b/docs/FAQ.md index 0945ef696a..9b9fff564e 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -29,3 +29,5 @@ lead to integrations for Github specifically being developed in an early stage. Hosting this project on Github does not exclude integrations with other alternatives such as Gitlab or Bitbucket. We believe that in time there will be plugins that will provide functionality for these tools as well. Hopefully contributed by the community. + +And note that implementations of Backstage can be hosted wherever you feel suits your needs best. From f9a47d9a0af62aa29673ca14b1d9fd7e6119afaa Mon Sep 17 00:00:00 2001 From: Mateus Marquezini Date: Tue, 24 Mar 2020 09:38:06 -0300 Subject: [PATCH 7/7] Build and test only changed packages (#352) * #285 build and test only changed packages * changed since flag param * fix build cause --since lerna flag * fix build cause --since lerna flag * removed checkout option * fix build cause --since lerna flag * fix build cause --since lerna flag * fix build in progress * fix build in progress * removed --since flag for build executions * removed --since flag for build executions * changed action checkout step * added new ref to the action checkout * removed ref prop from the action checkout. Added new step to fetch branches to compare when using lerna --since * changed --since param value * added --since flag to the build and renamed the fetch step * removed --since flag from build. Added new config to the checkout step workflow * removed --since flag from yarn build. Added new config to the checkout step workflow * removed --since flag from yarn build. Added new step to checkout branch master * Added new step to checkout branch master --- .github/workflows/frontend.yml | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 2842442bf9..527639abf1 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -14,6 +14,8 @@ jobs: steps: - uses: actions/checkout@v2 + - name: fetch branch master + run: git fetch origin master - name: find location of yarn cache id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" diff --git a/package.json b/package.json index 75c1dd7474..7c6f997efb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "start": "yarn build && yarn workspace @spotify-backstage/app start", "build": "lerna run build", - "test": "cross-env CI=true lerna run test -- --coverage", + "test": "cross-env CI=true lerna run test --since origin/master -- --coverage", "create-plugin": "backstage-cli create-plugin", "lint": "lerna run lint", "storybook": "yarn workspace @spotify-backstage/core storybook",