From cb6742c15ef9edb9af670cc9f2bd5ff8f0d933ba Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Tue, 23 Jun 2020 17:51:48 +0200 Subject: [PATCH 01/43] feat(mkdocs): WIP extensions for markdown --- plugins/techdocs/mkdocs/container/Dockerfile | 4 +- .../container/techdocs-core/src/core.py | 64 ++++++++++++++++--- .../techdocs/mkdocs/mock-docs/docs/index.md | 3 + plugins/techdocs/mkdocs/mock-docs/mkdocs.yml | 3 +- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 1ae66589b6..05c129033f 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -15,8 +15,8 @@ FROM python:3.7.7-alpine3.12 -RUN apk update && apk --no-cache add gcc musl-dev -RUN pip install mkdocs==1.1.2 mkdocs-material==5.3.2 +RUN apk update && apk --no-cache add gcc musl-dev graphviz +RUN pip install --upgrade pip && pip install mkdocs==1.1.2 mkdocs-material==5.3.2 pymdown-extensions==7.1 markdown_inline_graphviz_extension==1.1 plantuml-markdown==3.2.2 markdown-katex==202006.1021 ADD ./techdocs-core /techdocs-core RUN pip install --no-index /techdocs-core diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index e42a60d28b..d9c33b2167 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -21,15 +21,63 @@ from mkdocs.contrib.search import SearchPlugin class TechDocsCore(BasePlugin): def on_config(self, config): - # Theme - config['theme'] = Theme(name="material") + # Theme + config['theme'] = Theme(name="material") - # Plugins - del config['plugins']['techdocs-core'] + # Plugins + del config['plugins']['techdocs-core'] - search_plugin = SearchPlugin() - search_plugin.load_config({}) - config['plugins']['search'] = search_plugin + search_plugin = SearchPlugin() + search_plugin.load_config({}) + config['plugins']['search'] = search_plugin - return config + # Markdown Extensions + print(config) + config['markdown_extensions'].append('admonition') + config['markdown_extensions'].append('abbr') + config['markdown_extensions'].append('attr_list') + config['markdown_extensions'].append('def_list') + config['markdown_extensions'].append('codehilite') + config['mdx_configs']['codehilite'] = { + 'linenums': True, + 'guess_lang': False, + 'pygments_style': 'friendly', + } + config['markdown_extensions'].append('toc') + config['mdx_configs']['toc'] = { + 'permalink': True, + } + config['markdown_extensions'].append('footnotes') + config['markdown_extensions'].append('markdown.extensions.tables') + config['markdown_extensions'].append('markdown_inline_graphviz') + config['markdown_extensions'].append('plantuml_markdown') + config['markdown_extensions'].append('markdown_katex') + config['mdx_configs']['markdown_katex'] = { + 'no_inline_svg': True, + 'insert_fonts_css': True, + } + config['markdown_extensions'].append('pymdownx.betterem') + config['mdx_configs']['pymdownx.betterem'] = { + 'smart_enable': 'all', + } + config['markdown_extensions'].append('pymdownx.caret') + config['markdown_extensions'].append('pymdownx.critic') + config['markdown_extensions'].append('pymdownx.details') + config['markdown_extensions'].append('pymdownx.emoji') + config['mdx_configs']['pymdownx.emoji'] = { + 'emoji_generator': '!!python/name:pymdownx.emoji.to_svg', + } + config['markdown_extensions'].append('pymdownx.inlinehilite') + config['markdown_extensions'].append('pymdownx.magiclink') + config['markdown_extensions'].append('pymdownx.mark') + config['markdown_extensions'].append('pymdownx.smartsymbols') + config['markdown_extensions'].append('pymdownx.superfences') + config['markdown_extensions'].append('pymdownx.tasklist') + config['mdx_configs']['pymdownx.tasklist'] = { + 'custom_checkbox': True, + } + config['markdown_extensions'].append('pymdownx.tilde') + print(config) + + return config diff --git a/plugins/techdocs/mkdocs/mock-docs/docs/index.md b/plugins/techdocs/mkdocs/mock-docs/docs/index.md index bc437e6180..72f7a776a8 100644 --- a/plugins/techdocs/mkdocs/mock-docs/docs/index.md +++ b/plugins/techdocs/mkdocs/mock-docs/docs/index.md @@ -1 +1,4 @@ ## hello mock docs + +!!! test +Testing somethin diff --git a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml index b14d82c4de..2ecc719875 100644 --- a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml +++ b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml @@ -4,5 +4,4 @@ nav: - Home: index.md plugins: - - techdocs-core - + - techdocs-core \ No newline at end of file From cddfe9bd58aa668f7cfe65fa42a8c51f446c4e4c Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:11:16 +0200 Subject: [PATCH 02/43] feat(techdocs-core): add python formatter --- .../mkdocs/container/techdocs-core/requirements.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt index b3667f94ec..2a13d1a9da 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt +++ b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt @@ -1 +1,9 @@ +# The "base" version of the Mkdocs project. +# Note: if you update this, also update `install_requires` in setup.py +# https://github.com/mkdocs/mkdocs mkdocs==1.1.2 + +# The linter using for Python +# Note: This requires Python 3.6+ to run, but can format Python 2 code too. +# https://github.com/psf/black +black==19.10b0 From 3f79513fdd359b68c0b8687a00f9d7780907e87b Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:16:36 +0200 Subject: [PATCH 03/43] chore(techdocs-core): lower indentation of notice --- plugins/techdocs/mkdocs/container/Dockerfile | 20 +++++++------- .../mkdocs/container/techdocs-core/setup.py | 26 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 1ae66589b6..ce54f53983 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -1,17 +1,17 @@ -# Copyright 2020 Spotify AB +# 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 +# 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 +# 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. +# 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. FROM python:3.7.7-alpine3.12 diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/setup.py b/plugins/techdocs/mkdocs/container/techdocs-core/setup.py index faa8b8c46e..a259ae0615 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/setup.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/setup.py @@ -1,17 +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. +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. """ from setuptools import setup, find_packages From 8f91501b07aaba6eab12c5b1352d0edcb159c785 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:14:09 +0200 Subject: [PATCH 04/43] chore(mkdocs/container): remove initial newline --- plugins/techdocs/mkdocs/container/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index ce54f53983..8df86eadb0 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -1,4 +1,3 @@ - # Copyright 2020 Spotify AB # # Licensed under the Apache License, Version 2.0 (the "License"); From 97e9e325e54c800c1a8f4f18972c88bd400cb32a Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:31:07 +0200 Subject: [PATCH 05/43] docs(techdocs-core): add README --- .../mkdocs/container/techdocs-core/README.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 plugins/techdocs/mkdocs/container/techdocs-core/README.md diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/README.md b/plugins/techdocs/mkdocs/container/techdocs-core/README.md new file mode 100644 index 0000000000..04606088d4 --- /dev/null +++ b/plugins/techdocs/mkdocs/container/techdocs-core/README.md @@ -0,0 +1,47 @@ +# techdocs-core + +This is the base [Mkdocs](https://mkdocs.org) plugin used when using Mkdocs with Spotify's TechDocs. It is written in Python and packages all of our Mkdocs defaults, such as theming, plugins, etc in a single plugin. + +## Usage + +**Installation instructions TBD.** We haven't published it to a Python registry yet. + +Once you have installed the `mkdocs-techdocs-core` plugin, you'll need to add it to your `mkdocs.yml`. + +```yaml +site_name: Backstage Docs + +nav: + - Home: index.md + - Developing a Plugin: developing-a-plugin.md + +plugins: + - techdocs-core +``` + +## Running Locally + +You can install this package locally using `pip` and the `--editable` flag used for making developing Python packages. + +```bash +pip install --editable . +``` + +You'll then have the `techdocs-core` package available to use in Mkdocs and `pip` will point the dependency to this folder. + +## Running with Docker + +In the parent `Dockerfile` we add this folder to the build and install the package locally in the container. In the future, we'll probably move away from this approach and have it download directly from a Python registry (and this folder will publish to one). + +See the `README.md` located in the `mkdocs/` folder for more details on how to build and run the Docker container. + +## Linting and Tests + +To run the tests, you'll need `tox` installed: + +```bash +pip install tox +tox +``` + +This will invoke our linter and tests. You can configure this by editing the `tox.ini` folder located in this folder. From 4c6ea359602be1223aa7320c5f3574cd0c8c7c07 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:32:23 +0200 Subject: [PATCH 06/43] chore(techdocs-core): added gitignore --- plugins/techdocs/mkdocs/container/techdocs-core/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 plugins/techdocs/mkdocs/container/techdocs-core/.gitignore diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/.gitignore b/plugins/techdocs/mkdocs/container/techdocs-core/.gitignore new file mode 100644 index 0000000000..cd5c4a44f3 --- /dev/null +++ b/plugins/techdocs/mkdocs/container/techdocs-core/.gitignore @@ -0,0 +1,2 @@ +.tox +*.egg-info From d6cf8892fe19fe009cc7698c7c0ce0b7ff5bac27 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:33:29 +0200 Subject: [PATCH 07/43] docs(techdocs-core): added dependency install command --- plugins/techdocs/mkdocs/container/techdocs-core/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/README.md b/plugins/techdocs/mkdocs/container/techdocs-core/README.md index 04606088d4..b4a32a57cb 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/README.md +++ b/plugins/techdocs/mkdocs/container/techdocs-core/README.md @@ -37,10 +37,11 @@ See the `README.md` located in the `mkdocs/` folder for more details on how to b ## Linting and Tests -To run the tests, you'll need `tox` installed: +To run the tests, you'll need `tox` installed with our dependencies installed: ```bash pip install tox +pip install -r requirements.txt tox ``` From f9ee9991a05a98535fea4680328edb274abbfaa6 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:45:22 +0200 Subject: [PATCH 08/43] docs(techdocs-core): added linting section --- .../techdocs/mkdocs/container/techdocs-core/README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/README.md b/plugins/techdocs/mkdocs/container/techdocs-core/README.md index b4a32a57cb..143acf3c3b 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/README.md +++ b/plugins/techdocs/mkdocs/container/techdocs-core/README.md @@ -35,14 +35,11 @@ In the parent `Dockerfile` we add this folder to the build and install the packa See the `README.md` located in the `mkdocs/` folder for more details on how to build and run the Docker container. -## Linting and Tests - -To run the tests, you'll need `tox` installed with our dependencies installed: +## Linting ```bash -pip install tox pip install -r requirements.txt -tox +python -m black src/ ``` -This will invoke our linter and tests. You can configure this by editing the `tox.ini` folder located in this folder. +**Note:** This will write to all Python files in `src/` with the formatted code. If you would like to only check to see if it passes, simply append the `--check` flag. From f432c9deb6a41b7e8ff82113cbee8747b4a56ace Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:45:39 +0200 Subject: [PATCH 09/43] chore(techdocs-core): formatted all files in src/ --- .../mkdocs/container/techdocs-core/src/core.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index e42a60d28b..7fce7d6dac 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -19,17 +19,17 @@ from mkdocs.theme import Theme from mkdocs.contrib.search import SearchPlugin + class TechDocsCore(BasePlugin): def on_config(self, config): - # Theme - config['theme'] = Theme(name="material") + # Theme + config["theme"] = Theme(name="material") - # Plugins - del config['plugins']['techdocs-core'] + # Plugins + del config["plugins"]["techdocs-core"] - search_plugin = SearchPlugin() - search_plugin.load_config({}) - config['plugins']['search'] = search_plugin - - return config + search_plugin = SearchPlugin() + search_plugin.load_config({}) + config["plugins"]["search"] = search_plugin + return config From 464e07d067052c34fd94e85d2c6701414bb7991c Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:51:22 +0200 Subject: [PATCH 10/43] docs(mkdocs): lower indentation for container setup commands --- plugins/techdocs/mkdocs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/techdocs/mkdocs/README.md b/plugins/techdocs/mkdocs/README.md index 4d1c11d7b0..8cf1717cf1 100644 --- a/plugins/techdocs/mkdocs/README.md +++ b/plugins/techdocs/mkdocs/README.md @@ -6,8 +6,8 @@ Welcome to MkDocs. This is the TechDocs implementation of MkDocs. ## Getting started -``` - docker build ./container -t mkdocs-container +```bash +docker build ./container -t mkdocs-container - docker run -w /content -v $(pwd)/mock-docs:/content -p 8000:8000 -it mkdocs-container serve -a 0.0.0.0:8000 +docker run -w /content -v $(pwd)/mock-docs:/content -p 8000:8000 -it mkdocs-container serve -a 0.0.0.0:8000 ``` From b53ecbff3ed45efe9be5a639ca5edb66e91bc55a Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Tue, 23 Jun 2020 20:52:04 +0200 Subject: [PATCH 11/43] docs(mkdocs): added open up localhost:3000 to readme --- plugins/techdocs/mkdocs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/techdocs/mkdocs/README.md b/plugins/techdocs/mkdocs/README.md index 8cf1717cf1..5c2a7725aa 100644 --- a/plugins/techdocs/mkdocs/README.md +++ b/plugins/techdocs/mkdocs/README.md @@ -11,3 +11,5 @@ docker build ./container -t mkdocs-container docker run -w /content -v $(pwd)/mock-docs:/content -p 8000:8000 -it mkdocs-container serve -a 0.0.0.0:8000 ``` + +Then open up `http://localhost:8000` on your local machine. From eee3a5563309375c55edfae5b7b9cd4adc52a3f0 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Wed, 24 Jun 2020 10:57:04 +0200 Subject: [PATCH 12/43] fix(mkdocs): update sample md file --- .../container/techdocs-core/src/core.py | 12 ++++---- .../techdocs/mkdocs/mock-docs/docs/index.md | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index d9c33b2167..fddee3bfd1 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -32,7 +32,6 @@ class TechDocsCore(BasePlugin): config['plugins']['search'] = search_plugin # Markdown Extensions - print(config) config['markdown_extensions'].append('admonition') config['markdown_extensions'].append('abbr') config['markdown_extensions'].append('attr_list') @@ -51,11 +50,11 @@ class TechDocsCore(BasePlugin): config['markdown_extensions'].append('markdown.extensions.tables') config['markdown_extensions'].append('markdown_inline_graphviz') config['markdown_extensions'].append('plantuml_markdown') - config['markdown_extensions'].append('markdown_katex') - config['mdx_configs']['markdown_katex'] = { - 'no_inline_svg': True, - 'insert_fonts_css': True, - } + #config['markdown_extensions'].append('markdown_katex') + #config['mdx_configs']['markdown_katex'] = { + # 'no_inline_svg': True, + # 'insert_fonts_css': True, + #} config['markdown_extensions'].append('pymdownx.betterem') config['mdx_configs']['pymdownx.betterem'] = { 'smart_enable': 'all', @@ -77,7 +76,6 @@ class TechDocsCore(BasePlugin): 'custom_checkbox': True, } config['markdown_extensions'].append('pymdownx.tilde') - print(config) return config diff --git a/plugins/techdocs/mkdocs/mock-docs/docs/index.md b/plugins/techdocs/mkdocs/mock-docs/docs/index.md index 72f7a776a8..e8ba4e2d6d 100644 --- a/plugins/techdocs/mkdocs/mock-docs/docs/index.md +++ b/plugins/techdocs/mkdocs/mock-docs/docs/index.md @@ -2,3 +2,31 @@ !!! test Testing somethin + +Some text about MOCDOC + +\*[MOCDOC]: Mock Documentation + +This is a paragraph. +{: #test_id .test_class } + +Apple +: Pomaceous fruit of plants of the genus Malus in +the family Rosaceae. + +```javascript +import { test } from 'something'; + +const addThingToThing = (a, b) a + b; +``` + +- [abc](#abc) +- [xyz](#xyz) + +## abc + +This is a b c. + +## xyz + +This is x y z. From 106c4d6763029b38061aaaebe9408aa0bc0da4d8 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Wed, 24 Jun 2020 10:58:24 +0200 Subject: [PATCH 13/43] Added blank line --- plugins/techdocs/mkdocs/mock-docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml index 2ecc719875..0c7cf84955 100644 --- a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml +++ b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml @@ -4,4 +4,4 @@ nav: - Home: index.md plugins: - - techdocs-core \ No newline at end of file + - techdocs-core From 45c518272c3a962cccd0d9a890385d5c63379d28 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 24 Jun 2020 11:00:53 +0200 Subject: [PATCH 14/43] core-api: move session state tracking to auth session managers --- .../implementations/auth/github/GithubAuth.ts | 17 ++--------- .../implementations/auth/google/GoogleAuth.ts | 23 +++----------- .../AuthSessionStore.test.ts | 8 +++++ .../AuthSessionManager/AuthSessionStore.ts | 4 +++ .../RefreshingAuthSessionManager.test.ts | 30 +++++++++++++++++-- .../RefreshingAuthSessionManager.ts | 12 ++++++-- .../AuthSessionManager/SessionStateTracker.ts | 16 +++++++--- .../StaticAuthSessionManager.ts | 8 +++++ .../src/lib/AuthSessionManager/types.ts | 5 ++++ 9 files changed, 80 insertions(+), 43 deletions(-) diff --git a/packages/core-api/src/apis/implementations/auth/github/GithubAuth.ts b/packages/core-api/src/apis/implementations/auth/github/GithubAuth.ts index 4641dd7b50..ddf03034dc 100644 --- a/packages/core-api/src/apis/implementations/auth/github/GithubAuth.ts +++ b/packages/core-api/src/apis/implementations/auth/github/GithubAuth.ts @@ -29,7 +29,6 @@ import { OAuthRequestApi, AuthProvider } from '../../../definitions'; import { SessionManager } from '../../../../lib/AuthSessionManager/types'; import { StaticAuthSessionManager } from '../../../../lib/AuthSessionManager'; import { Observable } from '../../../../types'; -import { SessionStateTracker } from '../../../../lib/AuthSessionManager/SessionStateTracker'; type CreateOptions = { // TODO(Rugvip): These two should be grabbed from global config when available, they're not unique to GithubAuth @@ -95,44 +94,34 @@ class GithubAuth implements OAuthApi, SessionStateApi { return new GithubAuth(sessionManager); } - private readonly sessionStateTracker = new SessionStateTracker(); - sessionState$(): Observable { - return this.sessionStateTracker.observable; + return this.sessionManager.sessionState$(); } constructor(private readonly sessionManager: SessionManager) {} async getAccessToken(scope?: string, options?: AuthRequestOptions) { - const normalizedScopes = GithubAuth.normalizeScope(scope); const session = await this.sessionManager.getSession({ ...options, - scopes: normalizedScopes, + scopes: GithubAuth.normalizeScope(scope), }); - this.sessionStateTracker.setIsSignedId(!!session); - if (session) { - return session.providerInfo.accessToken; - } - return ''; + return session?.providerInfo.accessToken ?? ''; } async getBackstageIdentity( options: AuthRequestOptions = {}, ): Promise { const session = await this.sessionManager.getSession(options); - this.sessionStateTracker.setIsSignedId(!!session); return session?.backstageIdentity; } async getProfile(options: AuthRequestOptions = {}) { const session = await this.sessionManager.getSession(options); - this.sessionStateTracker.setIsSignedId(!!session); return session?.profile; } async logout() { await this.sessionManager.removeSession(); - this.sessionStateTracker.setIsSignedId(false); } static normalizeScope(scope?: string): Set { diff --git a/packages/core-api/src/apis/implementations/auth/google/GoogleAuth.ts b/packages/core-api/src/apis/implementations/auth/google/GoogleAuth.ts index db26d2d9a4..594116fc1a 100644 --- a/packages/core-api/src/apis/implementations/auth/google/GoogleAuth.ts +++ b/packages/core-api/src/apis/implementations/auth/google/GoogleAuth.ts @@ -32,7 +32,6 @@ import { OAuthRequestApi, AuthProvider } from '../../../definitions'; import { SessionManager } from '../../../../lib/AuthSessionManager/types'; import { RefreshingAuthSessionManager } from '../../../../lib/AuthSessionManager'; import { Observable } from '../../../../types'; -import { SessionStateTracker } from '../../../../lib/AuthSessionManager/SessionStateTracker'; type CreateOptions = { // TODO(Rugvip): These two should be grabbed from global config when available, they're not unique to GoogleAuth @@ -117,10 +116,8 @@ class GoogleAuth return new GoogleAuth(sessionManager); } - private readonly sessionStateTracker = new SessionStateTracker(); - sessionState$(): Observable { - return this.sessionStateTracker.observable; + return this.sessionManager.sessionState$(); } constructor(private readonly sessionManager: SessionManager) {} @@ -129,43 +126,31 @@ class GoogleAuth scope?: string | string[], options?: AuthRequestOptions, ) { - const normalizedScopes = GoogleAuth.normalizeScopes(scope); const session = await this.sessionManager.getSession({ ...options, - scopes: normalizedScopes, + scopes: GoogleAuth.normalizeScopes(scope), }); - this.sessionStateTracker.setIsSignedId(!!session); - if (session) { - return session.providerInfo.accessToken; - } - return ''; + return session?.providerInfo.accessToken ?? ''; } async getIdToken(options: AuthRequestOptions = {}) { const session = await this.sessionManager.getSession(options); - this.sessionStateTracker.setIsSignedId(!!session); - if (session) { - return session.providerInfo.idToken; - } - return ''; + return session?.providerInfo.idToken ?? ''; } async logout() { await this.sessionManager.removeSession(); - this.sessionStateTracker.setIsSignedId(false); } async getBackstageIdentity( options: AuthRequestOptions = {}, ): Promise { const session = await this.sessionManager.getSession(options); - this.sessionStateTracker.setIsSignedId(!!session); return session?.backstageIdentity; } async getProfile(options: AuthRequestOptions = {}) { const session = await this.sessionManager.getSession(options); - this.sessionStateTracker.setIsSignedId(!!session); return session?.profile; } diff --git a/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.test.ts b/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.test.ts index 91e55c3a48..4572b923dd 100644 --- a/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.test.ts +++ b/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.test.ts @@ -38,6 +38,7 @@ class LocalStorage { class MockManager implements SessionManager { getSession = jest.fn(); removeSession = jest.fn(); + sessionState$ = jest.fn(); } describe('GheAuth AuthSessionStore', () => { @@ -119,4 +120,11 @@ describe('GheAuth AuthSessionStore', () => { expect(localStorage.getItem('my-key')).toBe(null); }); + + it('should forward sessionState calls', () => { + const manager = new MockManager(); + const store = new AuthSessionStore({ manager, ...defaultOptions }); + store.sessionState$(); + expect(manager.sessionState$).toHaveBeenCalled(); + }); }); diff --git a/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.ts b/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.ts index 8d318f5bff..3e3a40d02a 100644 --- a/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.ts +++ b/packages/core-api/src/lib/AuthSessionManager/AuthSessionStore.ts @@ -82,6 +82,10 @@ export class AuthSessionStore implements SessionManager { await this.manager.removeSession(); } + sessionState$() { + return this.manager.sessionState$(); + } + private loadSession(): T | undefined { try { const sessionJson = localStorage.getItem(this.storageKey); diff --git a/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts b/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts index 793c6f1708..12e7c0a978 100644 --- a/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts +++ b/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts @@ -15,6 +15,7 @@ */ import { RefreshingAuthSessionManager } from './RefreshingAuthSessionManager'; +import { SessionState } from '../../apis'; const defaultOptions = { sessionScopes: (session: { scopes: Set }) => session.scopes, @@ -22,21 +23,44 @@ const defaultOptions = { }; describe('RefreshingAuthSessionManager', () => { - it('should save result form createSession', async () => { + it('should save result from createSession', async () => { const createSession = jest.fn().mockResolvedValue({ expired: false }); const refreshSession = jest.fn().mockRejectedValue(new Error('NOPE')); + const removeSession = jest.fn(); const manager = new RefreshingAuthSessionManager({ - connector: { createSession, refreshSession }, + connector: { createSession, refreshSession, removeSession }, ...defaultOptions, } as any); + const stateSubscriber = jest.fn(); + manager.sessionState$().subscribe(stateSubscriber); + await Promise.resolve(); // Wait a tick for observer to post a value + + expect(stateSubscriber.mock.calls).toEqual([[SessionState.SignedOut]]); await manager.getSession({}); expect(createSession).toBeCalledTimes(1); + expect(stateSubscriber.mock.calls).toEqual([ + [SessionState.SignedOut], + [SessionState.SignedIn], + ]); await manager.getSession({}); expect(createSession).toBeCalledTimes(1); expect(refreshSession).toBeCalledTimes(1); + expect(stateSubscriber.mock.calls).toEqual([ + [SessionState.SignedOut], + [SessionState.SignedIn], + ]); + + expect(removeSession).toHaveBeenCalledTimes(0); + await manager.removeSession(); + expect(removeSession).toHaveBeenCalledTimes(1); + expect(stateSubscriber.mock.calls).toEqual([ + [SessionState.SignedOut], + [SessionState.SignedIn], + [SessionState.SignedOut], + ]); }); it('should ask consent only if scopes have changed', async () => { @@ -130,7 +154,7 @@ describe('RefreshingAuthSessionManager', () => { expect(refreshSession).toBeCalledTimes(1); }); - it('should remove session and reload', async () => { + it('should remove session straight away', async () => { const removeSession = jest.fn(); const manager = new RefreshingAuthSessionManager({ connector: { removeSession }, diff --git a/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts b/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts index f7d5bcf7ca..e46c505c12 100644 --- a/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts +++ b/packages/core-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.ts @@ -22,6 +22,7 @@ import { } from './types'; import { AuthConnector } from '../AuthConnector'; import { SessionScopeHelper, hasScopes } from './common'; +import { SessionStateTracker } from './SessionStateTracker'; type Options = { /** The connector used for acting on the auth session */ @@ -43,6 +44,7 @@ export class RefreshingAuthSessionManager implements SessionManager { private readonly helper: SessionScopeHelper; private readonly sessionScopesFunc: SessionScopesFunc; private readonly sessionShouldRefreshFunc: SessionShouldRefreshFunc; + private readonly stateTracker = new SessionStateTracker(); private refreshPromise?: Promise; private currentSession: T | undefined; @@ -109,16 +111,18 @@ export class RefreshingAuthSessionManager implements SessionManager { ...options, scopes: this.helper.getExtendedScope(this.currentSession, options.scopes), }); + this.stateTracker.setIsSignedIn(true); return this.currentSession; } async removeSession() { this.currentSession = undefined; await this.connector.removeSession(); + this.stateTracker.setIsSignedIn(false); } - async getCurrentSession() { - return this.currentSession; + sessionState$() { + return this.stateTracker.sessionState$(); } private async collapsedSessionRefresh(): Promise { @@ -129,7 +133,9 @@ export class RefreshingAuthSessionManager implements SessionManager { this.refreshPromise = this.connector.refreshSession(); try { - return await this.refreshPromise; + const session = await this.refreshPromise; + this.stateTracker.setIsSignedIn(true); + return session; } finally { delete this.refreshPromise; } diff --git a/packages/core-api/src/lib/AuthSessionManager/SessionStateTracker.ts b/packages/core-api/src/lib/AuthSessionManager/SessionStateTracker.ts index de308acb0c..c4260bb31d 100644 --- a/packages/core-api/src/lib/AuthSessionManager/SessionStateTracker.ts +++ b/packages/core-api/src/lib/AuthSessionManager/SessionStateTracker.ts @@ -16,17 +16,25 @@ import { BehaviorSubject } from '..'; import { SessionState } from '../../apis'; +import { Observable } from '../../types'; export class SessionStateTracker { - private signedIn: boolean = false; - observable = new BehaviorSubject(SessionState.SignedOut); + private readonly subject = new BehaviorSubject( + SessionState.SignedOut, + ); - setIsSignedId(isSignedIn: boolean) { + private signedIn: boolean = false; + + setIsSignedIn(isSignedIn: boolean) { if (this.signedIn !== isSignedIn) { this.signedIn = isSignedIn; - this.observable.next( + this.subject.next( this.signedIn ? SessionState.SignedIn : SessionState.SignedOut, ); } } + + sessionState$(): Observable { + return this.subject; + } } diff --git a/packages/core-api/src/lib/AuthSessionManager/StaticAuthSessionManager.ts b/packages/core-api/src/lib/AuthSessionManager/StaticAuthSessionManager.ts index 5ecbbc0c4e..e59c11421c 100644 --- a/packages/core-api/src/lib/AuthSessionManager/StaticAuthSessionManager.ts +++ b/packages/core-api/src/lib/AuthSessionManager/StaticAuthSessionManager.ts @@ -17,6 +17,7 @@ import { SessionManager, GetSessionOptions } from './types'; import { AuthConnector } from '../AuthConnector'; import { SessionScopeHelper } from './common'; +import { SessionStateTracker } from './SessionStateTracker'; type Options = { /** The connector used for acting on the auth session */ @@ -33,6 +34,7 @@ type Options = { export class StaticAuthSessionManager implements SessionManager { private readonly connector: AuthConnector; private readonly helper: SessionScopeHelper; + private readonly stateTracker = new SessionStateTracker(); private currentSession: T | undefined; @@ -60,11 +62,17 @@ export class StaticAuthSessionManager implements SessionManager { ...options, scopes: this.helper.getExtendedScope(this.currentSession, options.scopes), }); + this.stateTracker.setIsSignedIn(true); return this.currentSession; } async removeSession() { this.currentSession = undefined; await this.connector.removeSession(); + this.stateTracker.setIsSignedIn(false); + } + + sessionState$() { + return this.stateTracker.sessionState$(); } } diff --git a/packages/core-api/src/lib/AuthSessionManager/types.ts b/packages/core-api/src/lib/AuthSessionManager/types.ts index d28a751fbf..804c7121e1 100644 --- a/packages/core-api/src/lib/AuthSessionManager/types.ts +++ b/packages/core-api/src/lib/AuthSessionManager/types.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +import { Observable } from '../../types'; +import { SessionState } from '../../apis'; + export type GetSessionOptions = { optional?: boolean; instantPopup?: boolean; @@ -29,6 +32,8 @@ export type SessionManager = { getSession(options: GetSessionOptions): Promise; removeSession(): Promise; + + sessionState$(): Observable; }; /** From cc0e6b0d30b4db91214088a45a11609404263a72 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 24 Jun 2020 11:30:27 +0200 Subject: [PATCH 15/43] auth-backend: leave it to the providers to figure out the backstage identity --- .../core-api/src/apis/definitions/auth.ts | 2 +- .../layout/Sidebar/Settings/UserProfile.tsx | 6 ++- .../src/lib/OAuthProvider.test.ts | 13 +++--- plugins/auth-backend/src/lib/OAuthProvider.ts | 40 ++++++++++--------- .../src/lib/PassportStrategyHelper.ts | 4 -- .../src/providers/github/provider.ts | 8 ++-- .../src/providers/google/provider.ts | 25 +++++++++--- plugins/auth-backend/src/providers/types.ts | 21 +++++----- 8 files changed, 67 insertions(+), 52 deletions(-) diff --git a/packages/core-api/src/apis/definitions/auth.ts b/packages/core-api/src/apis/definitions/auth.ts index ccd40e66ce..d5c0e9c0a4 100644 --- a/packages/core-api/src/apis/definitions/auth.ts +++ b/packages/core-api/src/apis/definitions/auth.ts @@ -173,7 +173,7 @@ export type ProfileInfo = { /** * Email ID. */ - email: string; + email?: string; /** * Display name that can be presented to the user. diff --git a/packages/core/src/layout/Sidebar/Settings/UserProfile.tsx b/packages/core/src/layout/Sidebar/Settings/UserProfile.tsx index 101ae7010b..3b854801c9 100644 --- a/packages/core/src/layout/Sidebar/Settings/UserProfile.tsx +++ b/packages/core/src/layout/Sidebar/Settings/UserProfile.tsx @@ -34,14 +34,16 @@ export const UserProfile: FC<{ open: boolean; setOpen: Function }> = ({ }) => { const ref = useRef(); // for scrolling down when collapse item opens const classes = useStyles(); - const profile = useApi(identityApiRef).getProfile(); + const identityApi = useApi(identityApiRef); const handleClick = () => { setOpen(!open); setTimeout(() => ref.current?.scrollIntoView({ behavior: 'smooth' }), 300); }; - const displayName = profile.displayName ?? profile.email; + const userId = identityApi.getUserId(); + const profile = identityApi.getProfile(); + const displayName = profile.displayName ?? userId; const SignInAvatar = () => ( {displayName[0]} diff --git a/plugins/auth-backend/src/lib/OAuthProvider.test.ts b/plugins/auth-backend/src/lib/OAuthProvider.test.ts index f92875fd48..f67a91dfcd 100644 --- a/plugins/auth-backend/src/lib/OAuthProvider.test.ts +++ b/plugins/auth-backend/src/lib/OAuthProvider.test.ts @@ -23,13 +23,9 @@ import { verifyNonce, OAuthProvider, } from './OAuthProvider'; -import { - WebMessageResponse, - OAuthProviderHandlers, - OAuthResponse, -} from '../providers/types'; +import { WebMessageResponse, OAuthProviderHandlers } from '../providers/types'; -const mockResponseData: OAuthResponse = { +const mockResponseData = { providerInfo: { accessToken: 'ACCESS_TOKEN', idToken: 'ID_TOKEN', @@ -39,6 +35,9 @@ const mockResponseData: OAuthResponse = { profile: { email: 'foo@bar.com', }, + backstageIdentity: { + id: 'foo', + }, }; describe('OAuthProvider Utils', () => { @@ -350,7 +349,7 @@ describe('OAuthProvider', () => { expect(mockResponse.send).toHaveBeenCalledWith({ ...mockResponseData, backstageIdentity: { - id: mockResponseData.profile.email, + id: mockResponseData.backstageIdentity.id, idToken: 'my-id-token', }, }); diff --git a/plugins/auth-backend/src/lib/OAuthProvider.ts b/plugins/auth-backend/src/lib/OAuthProvider.ts index dac31af451..b7179659f9 100644 --- a/plugins/auth-backend/src/lib/OAuthProvider.ts +++ b/plugins/auth-backend/src/lib/OAuthProvider.ts @@ -18,10 +18,10 @@ import express from 'express'; import crypto from 'crypto'; import { URL } from 'url'; import { - AuthResponse, AuthProviderRouteHandlers, OAuthProviderHandlers, WebMessageResponse, + BackstageIdentity, } from '../providers/types'; import { InputError } from '@backstage/backend-common'; import { TokenIssuer } from '../identity'; @@ -147,19 +147,12 @@ export class OAuthProvider implements AuthProviderRouteHandlers { this.setRefreshTokenCookie(res, refreshToken); } - const id = response.profile.email; - const idToken = await this.options.tokenIssuer.issueToken({ - claims: { sub: id }, - }); - const fullResponse: AuthResponse = { - ...response, - backstageIdentity: { id, idToken }, - }; + await this.populateIdentity(response.backstageIdentity); // post message back to popup if successful return postMessageResponse(res, this.options.appOrigin, { type: 'authorization_response', - response: fullResponse, + response, }); } catch (error) { // post error message back to popup if failure @@ -213,21 +206,30 @@ export class OAuthProvider implements AuthProviderRouteHandlers { // get new access_token const response = await this.providerHandlers.refresh(refreshToken, scope); - const id = response.profile.email; - const idToken = await this.options.tokenIssuer.issueToken({ - claims: { sub: id }, - }); - const fullResponse: AuthResponse = { - ...response, - backstageIdentity: { id, idToken }, - }; + await this.populateIdentity(response.backstageIdentity); - res.send(fullResponse); + res.send(response); } catch (error) { res.status(401).send(`${error.message}`); } } + /** + * If the response from the OAuth provider includes a Backstage identity, we + * make sure it's populated with all the information we can derive from the user ID. + */ + private async populateIdentity(identity?: BackstageIdentity) { + if (!identity) { + return; + } + + if (!identity.idToken) { + identity.idToken = await this.options.tokenIssuer.issueToken({ + claims: { sub: identity.id }, + }); + } + } + private setNonceCookie = (res: express.Response, nonce: string) => { res.cookie(`${this.options.providerId}-nonce`, nonce, { maxAge: TEN_MINUTES_MS, diff --git a/plugins/auth-backend/src/lib/PassportStrategyHelper.ts b/plugins/auth-backend/src/lib/PassportStrategyHelper.ts index 46a386f419..1167946560 100644 --- a/plugins/auth-backend/src/lib/PassportStrategyHelper.ts +++ b/plugins/auth-backend/src/lib/PassportStrategyHelper.ts @@ -57,10 +57,6 @@ export const makeProfileInfo = ( } } - if (!email) { - throw new Error('No email received in profile info'); - } - return { email, picture, diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index 3ae9858bb1..01652a6d7e 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -72,15 +72,13 @@ export class GithubAuthProvider implements OAuthProviderHandlers { return await executeRedirectStrategy(req, this._strategy, options); } - async handler(req: express.Request): Promise<{ response: OAuthResponse }> { - const result = await executeFrameHandlerStrategy( + async handler(req: express.Request) { + const { response } = await executeFrameHandlerStrategy( req, this._strategy, ); - return { - response: result.response, - }; + return { response }; } } diff --git a/plugins/auth-backend/src/providers/google/provider.ts b/plugins/auth-backend/src/providers/google/provider.ts index f12b248021..04705b66c1 100644 --- a/plugins/auth-backend/src/providers/google/provider.ts +++ b/plugins/auth-backend/src/providers/google/provider.ts @@ -97,14 +97,14 @@ export class GoogleAuthProvider implements OAuthProviderHandlers { async handler( req: express.Request, ): Promise<{ response: OAuthResponse; refreshToken: string }> { - const result = await executeFrameHandlerStrategy< + const { response, privateInfo } = await executeFrameHandlerStrategy< OAuthResponse, PrivateInfo >(req, this._strategy); return { - response: result.response, - refreshToken: result.privateInfo.refreshToken, + response: await this.populateIdentity(response), + refreshToken: privateInfo.refreshToken, }; } @@ -121,7 +121,7 @@ export class GoogleAuthProvider implements OAuthProviderHandlers { params.id_token, ); - return { + return this.populateIdentity({ providerInfo: { accessToken, idToken: params.id_token, @@ -129,7 +129,22 @@ export class GoogleAuthProvider implements OAuthProviderHandlers { scope: params.scope, }, profile, - }; + }); + } + + private async populateIdentity( + response: OAuthResponse, + ): Promise { + const { profile } = response; + + if (!profile.email) { + throw new Error('Google profile contained no email'); + } + + // TODO(Rugvip): Hardcoded to the local part of the email for now + const id = profile.email.split('@')[0]; + + return { ...response, backstageIdentity: { id } }; } } diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts index 81773bf9dc..56d4db79fa 100644 --- a/plugins/auth-backend/src/providers/types.ts +++ b/plugins/auth-backend/src/providers/types.ts @@ -100,14 +100,20 @@ export interface OAuthProviderHandlers { */ handler( req: express.Request, - ): Promise<{ response: OAuthResponse; refreshToken?: string }>; + ): Promise<{ + response: AuthResponse; + refreshToken?: string; + }>; /** * (Optional) Given a refresh token and scope fetches a new access token from the auth provider. * @param {string} refreshToken * @param {string} scope */ - refresh?(refreshToken: string, scope: string): Promise; + refresh?( + refreshToken: string, + scope: string, + ): Promise>; /** * (Optional) Sign out of the auth provider. @@ -192,13 +198,10 @@ export type AuthProviderFactory = ( export type AuthResponse = { providerInfo: ProviderInfo; profile: ProfileInfo; - backstageIdentity: BackstageIdentity; + backstageIdentity?: BackstageIdentity; }; -export type OAuthResponse = Omit< - AuthResponse, - 'backstageIdentity' ->; +export type OAuthResponse = AuthResponse; export type BackstageIdentity = { /** @@ -209,7 +212,7 @@ export type BackstageIdentity = { /** * An ID token that can be used to authenticate the user within Backstage. */ - idToken: string; + idToken?: string; }; export type OAuthProviderInfo = { @@ -279,7 +282,7 @@ export type ProfileInfo = { /** * Email ID of the signed in user. */ - email: string; + email?: string; /** * Display name that can be presented to the signed in user. */ From e3a1c1944b20fbd7c8575f7e365108cdeb6d8e3a Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 23 Jun 2020 16:57:16 +0200 Subject: [PATCH 16/43] feat(mkdocs) add mkdocs monorepo plugin to techdocs core plugin --- plugins/techdocs/mkdocs/container/Dockerfile | 2 +- .../mkdocs/container/techdocs-core/src/core.py | 18 ++++++++++++++---- plugins/techdocs/mkdocs/mock-docs/mkdocs.yml | 1 + .../mkdocs/mock-docs/sub-docs/docs/index.md | 1 + .../mkdocs/mock-docs/sub-docs/mkdocs.yml | 4 ++++ 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md create mode 100644 plugins/techdocs/mkdocs/mock-docs/sub-docs/mkdocs.yml diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 8df86eadb0..aefabb5c5b 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -15,7 +15,7 @@ FROM python:3.7.7-alpine3.12 RUN apk update && apk --no-cache add gcc musl-dev -RUN pip install mkdocs==1.1.2 mkdocs-material==5.3.2 +RUN pip install mkdocs==1.1.2 mkdocs-material==5.3.2 mkdocs-monorepo-plugin==0.4.5 ADD ./techdocs-core /techdocs-core RUN pip install --no-index /techdocs-core diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index 7fce7d6dac..7fc35a1529 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -19,14 +19,24 @@ from mkdocs.theme import Theme from mkdocs.contrib.search import SearchPlugin +from mkdocs_monorepo_plugin.plugin import MonorepoPlugin class TechDocsCore(BasePlugin): def on_config(self, config): - # Theme - config["theme"] = Theme(name="material") + # Theme + config['theme'] = Theme(name="material") - # Plugins - del config["plugins"]["techdocs-core"] + # Plugins + del config['plugins']['techdocs-core'] + + search_plugin = SearchPlugin() + search_plugin.load_config({}) + + monorepo_plugin = MonorepoPlugin() + monorepo_plugin.load_config({}) + + config['plugins']['search'] = search_plugin + config['plugins']['monorepo'] = monorepo_plugin search_plugin = SearchPlugin() search_plugin.load_config({}) diff --git a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml index b14d82c4de..3da0280f2b 100644 --- a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml +++ b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml @@ -2,6 +2,7 @@ site_name: 'mock-docs' nav: - Home: index.md + - SubDocs: '!include ./sub-docs/mkdocs.yml' plugins: - techdocs-core diff --git a/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md b/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md new file mode 100644 index 0000000000..9cb6199605 --- /dev/null +++ b/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md @@ -0,0 +1 @@ +### This is a md file in another docs folder using the [MkDocs Monorepo Plugin](https://github.com/spotify/mkdocs-monorepo-plugin) diff --git a/plugins/techdocs/mkdocs/mock-docs/sub-docs/mkdocs.yml b/plugins/techdocs/mkdocs/mock-docs/sub-docs/mkdocs.yml new file mode 100644 index 0000000000..09504c1b31 --- /dev/null +++ b/plugins/techdocs/mkdocs/mock-docs/sub-docs/mkdocs.yml @@ -0,0 +1,4 @@ +site_name: subdocs + +nav: + - Home 2: "index.md" From 3b936faf7e36a2688775eb5f3448f60d4d603b5d Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Wed, 24 Jun 2020 11:42:15 +0200 Subject: [PATCH 17/43] fix(mkdocs): remove some markdown plugins --- plugins/techdocs/mkdocs/container/Dockerfile | 4 ++-- .../techdocs/mkdocs/container/techdocs-core/src/core.py | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 05c129033f..9080277a30 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -15,8 +15,8 @@ FROM python:3.7.7-alpine3.12 -RUN apk update && apk --no-cache add gcc musl-dev graphviz -RUN pip install --upgrade pip && pip install mkdocs==1.1.2 mkdocs-material==5.3.2 pymdown-extensions==7.1 markdown_inline_graphviz_extension==1.1 plantuml-markdown==3.2.2 markdown-katex==202006.1021 +RUN apk update && apk --no-cache add gcc musl-dev graphviz git +RUN pip install --upgrade pip && pip install mkdocs==1.1.2 mkdocs-material==5.3.2 pymdown-extensions==7.1 ADD ./techdocs-core /techdocs-core RUN pip install --no-index /techdocs-core diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index fddee3bfd1..a9b5a91e07 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -48,13 +48,6 @@ class TechDocsCore(BasePlugin): } config['markdown_extensions'].append('footnotes') config['markdown_extensions'].append('markdown.extensions.tables') - config['markdown_extensions'].append('markdown_inline_graphviz') - config['markdown_extensions'].append('plantuml_markdown') - #config['markdown_extensions'].append('markdown_katex') - #config['mdx_configs']['markdown_katex'] = { - # 'no_inline_svg': True, - # 'insert_fonts_css': True, - #} config['markdown_extensions'].append('pymdownx.betterem') config['mdx_configs']['pymdownx.betterem'] = { 'smart_enable': 'all', From 91022ff1eca0b93e06b808a8d3ae90c2c8a65ec2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 24 Jun 2020 11:45:48 +0200 Subject: [PATCH 18/43] catalog-model: let the guest take care of some services --- packages/catalog-model/examples/artist-lookup-component.yaml | 2 +- packages/catalog-model/examples/playback-order-component.yaml | 2 +- packages/catalog-model/examples/podcast-api-component.yaml | 2 +- packages/catalog-model/examples/searcher-component.yaml | 2 +- packages/catalog-model/examples/shuffle-api-component.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/catalog-model/examples/artist-lookup-component.yaml b/packages/catalog-model/examples/artist-lookup-component.yaml index bb7d8d5767..448dd13fa3 100644 --- a/packages/catalog-model/examples/artist-lookup-component.yaml +++ b/packages/catalog-model/examples/artist-lookup-component.yaml @@ -6,4 +6,4 @@ metadata: spec: type: service lifecycle: experimental - owner: tools@example.com + owner: artists@example.com diff --git a/packages/catalog-model/examples/playback-order-component.yaml b/packages/catalog-model/examples/playback-order-component.yaml index fa9f68e77a..4f93b65edf 100644 --- a/packages/catalog-model/examples/playback-order-component.yaml +++ b/packages/catalog-model/examples/playback-order-component.yaml @@ -6,4 +6,4 @@ metadata: spec: type: service lifecycle: production - owner: tools@example.com + owner: guest diff --git a/packages/catalog-model/examples/podcast-api-component.yaml b/packages/catalog-model/examples/podcast-api-component.yaml index 2a27a0a2c5..19f9a3d4de 100644 --- a/packages/catalog-model/examples/podcast-api-component.yaml +++ b/packages/catalog-model/examples/podcast-api-component.yaml @@ -6,4 +6,4 @@ metadata: spec: type: service lifecycle: experimental - owner: tools@example.com + owner: players@example.com diff --git a/packages/catalog-model/examples/searcher-component.yaml b/packages/catalog-model/examples/searcher-component.yaml index d82f6e42c7..33d765117c 100644 --- a/packages/catalog-model/examples/searcher-component.yaml +++ b/packages/catalog-model/examples/searcher-component.yaml @@ -6,4 +6,4 @@ metadata: spec: type: service lifecycle: production - owner: tools@example.com + owner: guest diff --git a/packages/catalog-model/examples/shuffle-api-component.yaml b/packages/catalog-model/examples/shuffle-api-component.yaml index ed0517835c..275c48d6ba 100644 --- a/packages/catalog-model/examples/shuffle-api-component.yaml +++ b/packages/catalog-model/examples/shuffle-api-component.yaml @@ -6,4 +6,4 @@ metadata: spec: type: service lifecycle: production - owner: tools@example.com + owner: guest From f518a47bb27307dc679d7a9aa3b589eaf37cd400 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Wed, 24 Jun 2020 11:45:57 +0200 Subject: [PATCH 19/43] fix(mkdocs): removed unused packages from container --- plugins/techdocs/mkdocs/container/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 9080277a30..f96498df14 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -15,7 +15,7 @@ FROM python:3.7.7-alpine3.12 -RUN apk update && apk --no-cache add gcc musl-dev graphviz git +RUN apk update && apk --no-cache add gcc musl-dev RUN pip install --upgrade pip && pip install mkdocs==1.1.2 mkdocs-material==5.3.2 pymdown-extensions==7.1 ADD ./techdocs-core /techdocs-core From 50c5489422420ee57d663783ed6e81e68f43ac1f Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Wed, 24 Jun 2020 12:00:24 +0200 Subject: [PATCH 20/43] fix(techdocs-core): formatting --- .../container/techdocs-core/src/core.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py index 7fc35a1529..37d271d261 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -21,22 +21,23 @@ from mkdocs.contrib.search import SearchPlugin from mkdocs_monorepo_plugin.plugin import MonorepoPlugin + class TechDocsCore(BasePlugin): def on_config(self, config): - # Theme - config['theme'] = Theme(name="material") + # Theme + config["theme"] = Theme(name="material") - # Plugins - del config['plugins']['techdocs-core'] - - search_plugin = SearchPlugin() - search_plugin.load_config({}) + # Plugins + del config["plugins"]["techdocs-core"] - monorepo_plugin = MonorepoPlugin() - monorepo_plugin.load_config({}) - - config['plugins']['search'] = search_plugin - config['plugins']['monorepo'] = monorepo_plugin + search_plugin = SearchPlugin() + search_plugin.load_config({}) + + monorepo_plugin = MonorepoPlugin() + monorepo_plugin.load_config({}) + + config["plugins"]["search"] = search_plugin + config["plugins"]["monorepo"] = monorepo_plugin search_plugin = SearchPlugin() search_plugin.load_config({}) From 72fed2555df5eb42eafae08251c972ead574cea8 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Wed, 24 Jun 2020 12:02:09 +0200 Subject: [PATCH 21/43] docs(sub-docs): typo --- plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md b/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md index 9cb6199605..65c6644ef8 100644 --- a/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md +++ b/plugins/techdocs/mkdocs/mock-docs/sub-docs/docs/index.md @@ -1 +1 @@ -### This is a md file in another docs folder using the [MkDocs Monorepo Plugin](https://github.com/spotify/mkdocs-monorepo-plugin) +### This is an md file in another docs folder using the [MkDocs Monorepo Plugin](https://github.com/spotify/mkdocs-monorepo-plugin) From f419ac130a6f1e362874005551a0638d30acba6f Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 11:10:15 +0200 Subject: [PATCH 22/43] feat(.github/workflows): added python lint to CI --- .github/workflows/techdocs.yml | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/techdocs.yml diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml new file mode 100644 index 0000000000..2915cb7277 --- /dev/null +++ b/.github/workflows/techdocs.yml @@ -0,0 +1,46 @@ +name: TechDocs + +on: + pull_request: + paths: + - '.github/workflows/techdocs.yml' + - 'packages/techdocs-cli/**' + - 'plugins/techdocs/**' + +jobs: + build-container: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container + + name: Python ${{ matrix.node-version }} on ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: verify docker build + uses: docker/build-push-action@v1 + with: + repository: spotify/techdocs + push: false + + lint: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.7] + + defaults: + run: + working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container/techdocs-core + + name: Python ${{ matrix.node-version }} on ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: lint mkdocs-core package + working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container/techdocs-core + run: | + pip install -r requirements.txt + python -m black --check src/ From ba040202288c95957dda019014a1b9df9fc0dc71 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:38:53 +0200 Subject: [PATCH 23/43] fixup --- .github/workflows/techdocs.yml | 36 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 2915cb7277..0ab01b584f 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -8,23 +8,7 @@ on: - 'plugins/techdocs/**' jobs: - build-container: - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container - - name: Python ${{ matrix.node-version }} on ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: verify docker build - uses: docker/build-push-action@v1 - with: - repository: spotify/techdocs - push: false - - lint: + build: runs-on: ${{ matrix.os }} strategy: @@ -32,14 +16,22 @@ jobs: os: [ubuntu-latest] python-version: [3.7] - defaults: - run: - working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container/techdocs-core - name: Python ${{ matrix.node-version }} on ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - name: lint mkdocs-core package + + # Validate Docker Container + - name: prepare docker build + working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container + run: '' + - name: verify docker build + uses: docker/build-push-action@v1 + with: + repository: spotify/techdocs + push: false + + # Lint Python code for techdocs-core package + - name: lint techdocs-core package working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container/techdocs-core run: | pip install -r requirements.txt From c6220fff50d65d4f00900fe622cb2a915995c45b Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:41:42 +0200 Subject: [PATCH 24/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 0ab01b584f..f09ad12484 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -23,7 +23,7 @@ jobs: # Validate Docker Container - name: prepare docker build working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container - run: '' + run: ls - name: verify docker build uses: docker/build-push-action@v1 with: From 48076c862ef81579ca89ca15f391eea7b54708de Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:42:48 +0200 Subject: [PATCH 25/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index f09ad12484..b004fa717a 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -22,7 +22,7 @@ jobs: # Validate Docker Container - name: prepare docker build - working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container + working-directory: ${{ runner.temp }} run: ls - name: verify docker build uses: docker/build-push-action@v1 From 8273fc0405c7b97eafe2c445753cc36c4d82fe10 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:45:04 +0200 Subject: [PATCH 26/43] fixup --- .github/workflows/techdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index b004fa717a..cd79526327 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -22,7 +22,7 @@ jobs: # Validate Docker Container - name: prepare docker build - working-directory: ${{ runner.temp }} + working-directory: /plugins/techdocs/mkdocs/container run: ls - name: verify docker build uses: docker/build-push-action@v1 @@ -32,7 +32,7 @@ jobs: # Lint Python code for techdocs-core package - name: lint techdocs-core package - working-directory: ${{ runner.temp }}/plugins/techdocs/mkdocs/container/techdocs-core + working-directory: /plugins/techdocs/mkdocs/container/techdocs-core run: | pip install -r requirements.txt python -m black --check src/ From a4c01ea76118e0ae92dd13b09011df06eb250a1c Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:47:39 +0200 Subject: [PATCH 27/43] fixup --- .github/workflows/techdocs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index cd79526327..183678429c 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -10,6 +10,8 @@ on: jobs: build: runs-on: ${{ matrix.os }} + env: + TECHDOCS_CONTAINER_PATH: /plugins/techdocs/mkdocs/container strategy: matrix: @@ -22,7 +24,7 @@ jobs: # Validate Docker Container - name: prepare docker build - working-directory: /plugins/techdocs/mkdocs/container + working-directory: ${{env:TECHDOCS_CONTAINER_PATH}} run: ls - name: verify docker build uses: docker/build-push-action@v1 @@ -32,7 +34,7 @@ jobs: # Lint Python code for techdocs-core package - name: lint techdocs-core package - working-directory: /plugins/techdocs/mkdocs/container/techdocs-core + working-directory: ${{env:TECHDOCS_CONTAINER_PATH}}/techdocs-core run: | pip install -r requirements.txt python -m black --check src/ From fb19ad583996ca244a569edb05837207a80da60b Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:49:52 +0200 Subject: [PATCH 28/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 183678429c..af844ebc6b 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ${{ matrix.os }} env: - TECHDOCS_CONTAINER_PATH: /plugins/techdocs/mkdocs/container + TECHDOCS_CONTAINER_PATH: plugins/techdocs/mkdocs/container strategy: matrix: From 45f5fb08fe079fc6c729238d394fbed6dff4ab58 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 13:56:51 +0200 Subject: [PATCH 29/43] fixup --- .github/workflows/techdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index af844ebc6b..d734ac6d88 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,7 +24,7 @@ jobs: # Validate Docker Container - name: prepare docker build - working-directory: ${{env:TECHDOCS_CONTAINER_PATH}} + working-directory: ${env:TECHDOCS_CONTAINER_PATH} run: ls - name: verify docker build uses: docker/build-push-action@v1 @@ -34,7 +34,7 @@ jobs: # Lint Python code for techdocs-core package - name: lint techdocs-core package - working-directory: ${{env:TECHDOCS_CONTAINER_PATH}}/techdocs-core + working-directory: ${env:TECHDOCS_CONTAINER_PATH}/techdocs-core run: | pip install -r requirements.txt python -m black --check src/ From cc8c3a9e7ddd41a4d2b7955c40c5b15dc920626c Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:06:51 +0200 Subject: [PATCH 30/43] fixup --- .github/workflows/techdocs.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index d734ac6d88..60d1da186a 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -10,8 +10,6 @@ on: jobs: build: runs-on: ${{ matrix.os }} - env: - TECHDOCS_CONTAINER_PATH: plugins/techdocs/mkdocs/container strategy: matrix: @@ -22,19 +20,9 @@ jobs: steps: - uses: actions/checkout@v2 - # Validate Docker Container - - name: prepare docker build - working-directory: ${env:TECHDOCS_CONTAINER_PATH} - run: ls - - name: verify docker build - uses: docker/build-push-action@v1 - with: - repository: spotify/techdocs - push: false - # Lint Python code for techdocs-core package - name: lint techdocs-core package - working-directory: ${env:TECHDOCS_CONTAINER_PATH}/techdocs-core + working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | pip install -r requirements.txt python -m black --check src/ From 56e1b0adec327f9006ca0a7079fdbd9e61ab1c54 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:09:07 +0200 Subject: [PATCH 31/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 60d1da186a..ccc9178724 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,5 +24,5 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - pip install -r requirements.txt + pip install --registry https://pypi.org/simple/ -r requirements.txt python -m black --check src/ From aca7a44817d1faa9b9d17fc2d1143015d84455f0 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:09:45 +0200 Subject: [PATCH 32/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index ccc9178724..d0c57f6fd6 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,5 +24,5 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - pip install --registry https://pypi.org/simple/ -r requirements.txt + pip install --index-url https://pypi.org/simple/ -r requirements.txt python -m black --check src/ From c1a6add47d396886589dfb89bcbf2e5d5a0aca52 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:11:52 +0200 Subject: [PATCH 33/43] fixup --- .github/workflows/techdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index d0c57f6fd6..1b7552dd60 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,5 +24,6 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | + pip install --upgrade pip install --index-url https://pypi.org/simple/ -r requirements.txt python -m black --check src/ From 931058601b36ab8253574d15d38fe90237eca421 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:12:31 +0200 Subject: [PATCH 34/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 1b7552dd60..cbfc770696 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,6 +24,6 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - pip install --upgrade + pip install --upgrade pip pip install --index-url https://pypi.org/simple/ -r requirements.txt python -m black --check src/ From f3302ef46b7ed9562df5e9aaffab3cbef81cae25 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:14:13 +0200 Subject: [PATCH 35/43] fixup --- .github/workflows/techdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index cbfc770696..c687552838 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,6 +24,6 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - pip install --upgrade pip + python -m pip install --upgrade pip pip install --index-url https://pypi.org/simple/ -r requirements.txt python -m black --check src/ From 691f28a83c2a09e60d962ad4050d95aa4aa1ed26 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:15:56 +0200 Subject: [PATCH 36/43] fixup --- .github/workflows/techdocs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index c687552838..c59ec0eed5 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,6 +24,6 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - python -m pip install --upgrade pip - pip install --index-url https://pypi.org/simple/ -r requirements.txt - python -m black --check src/ + python3 -m pip3 install --upgrade pip + python3 -m pip3 install --index-url https://pypi.org/simple/ -r requirements.txt + python3 -m black --check src/ From ceaba974e84fb925953179bb696bc3125ce155f6 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:16:36 +0200 Subject: [PATCH 37/43] fixup --- .github/workflows/techdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index c59ec0eed5..52b6d6bcfc 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -24,6 +24,6 @@ jobs: - name: lint techdocs-core package working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - python3 -m pip3 install --upgrade pip - python3 -m pip3 install --index-url https://pypi.org/simple/ -r requirements.txt + python3 -m pip install --upgrade pip + python3 -m pip install --index-url https://pypi.org/simple/ -r requirements.txt python3 -m black --check src/ From b9568cf0ce70ba1daa066e360399b24d7564ca71 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:19:42 +0200 Subject: [PATCH 38/43] fixup --- .../techdocs/mkdocs/container/techdocs-core/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt index 2a13d1a9da..70b28e00bd 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt +++ b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt @@ -1,3 +1,6 @@ +# Fixes an error related to using Setuptools. +setuptools==47.3.1 + # The "base" version of the Mkdocs project. # Note: if you update this, also update `install_requires` in setup.py # https://github.com/mkdocs/mkdocs From 945594f2eb59506a6a51b8730186e9fb4e8a9dad Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:22:25 +0200 Subject: [PATCH 39/43] fixup --- .github/workflows/techdocs.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 52b6d6bcfc..b8e14087b9 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -21,9 +21,12 @@ jobs: - uses: actions/checkout@v2 # Lint Python code for techdocs-core package - - name: lint techdocs-core package - working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core + - name: prepare python environment run: | + python3 -m pip install --index-url https://pypi.org/simple/ setuptools python3 -m pip install --upgrade pip python3 -m pip install --index-url https://pypi.org/simple/ -r requirements.txt - python3 -m black --check src/ + + - name: lint techdocs-core package + run: | + python3 -m black --check ./plugins/techdocs/mkdocs/container/techdocs-core/src/ From d92ebf4908a46e04ab06c63c4e745165077ba2aa Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:22:36 +0200 Subject: [PATCH 40/43] fixup --- .../techdocs/mkdocs/container/techdocs-core/requirements.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt index 70b28e00bd..2a13d1a9da 100644 --- a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt +++ b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt @@ -1,6 +1,3 @@ -# Fixes an error related to using Setuptools. -setuptools==47.3.1 - # The "base" version of the Mkdocs project. # Note: if you update this, also update `install_requires` in setup.py # https://github.com/mkdocs/mkdocs From 9ebd5e0960fa7759041667ff1656b418d62197e0 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:24:19 +0200 Subject: [PATCH 41/43] fixup --- .github/workflows/techdocs.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index b8e14087b9..9265bc9fdc 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -16,6 +16,9 @@ jobs: os: [ubuntu-latest] python-version: [3.7] + env: + TECHDOCS_CORE_PATH: ./plugins/techdocs/mkdocs/container/techdocs-core + name: Python ${{ matrix.node-version }} on ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -25,8 +28,9 @@ jobs: run: | python3 -m pip install --index-url https://pypi.org/simple/ setuptools python3 -m pip install --upgrade pip - python3 -m pip install --index-url https://pypi.org/simple/ -r requirements.txt + python3 -m pip install --index-url https://pypi.org/simple/ -r ${env:TECHDOCS_CORE_PATH}/requirements.txt - name: lint techdocs-core package + working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | - python3 -m black --check ./plugins/techdocs/mkdocs/container/techdocs-core/src/ + python3 -m black --check ${env:TECHDOCS_CORE_PATH}/src From 0c3ec164282a71baa935d4d5b564782bde602a44 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:24:30 +0200 Subject: [PATCH 42/43] fixup --- .github/workflows/techdocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index 9265bc9fdc..bb0ded61cf 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -31,6 +31,5 @@ jobs: python3 -m pip install --index-url https://pypi.org/simple/ -r ${env:TECHDOCS_CORE_PATH}/requirements.txt - name: lint techdocs-core package - working-directory: ./plugins/techdocs/mkdocs/container/techdocs-core run: | python3 -m black --check ${env:TECHDOCS_CORE_PATH}/src From cbdc656aa75db0247b4e0c17b9bd326b71fea732 Mon Sep 17 00:00:00 2001 From: Bilawal Hameed Date: Wed, 24 Jun 2020 14:27:10 +0200 Subject: [PATCH 43/43] fixup --- .github/workflows/techdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/techdocs.yml b/.github/workflows/techdocs.yml index bb0ded61cf..6d6a6e904e 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/techdocs.yml @@ -28,8 +28,8 @@ jobs: run: | python3 -m pip install --index-url https://pypi.org/simple/ setuptools python3 -m pip install --upgrade pip - python3 -m pip install --index-url https://pypi.org/simple/ -r ${env:TECHDOCS_CORE_PATH}/requirements.txt + python3 -m pip install --index-url https://pypi.org/simple/ -r $TECHDOCS_CORE_PATH/requirements.txt - name: lint techdocs-core package run: | - python3 -m black --check ${env:TECHDOCS_CORE_PATH}/src + python3 -m black --check $TECHDOCS_CORE_PATH/src