Skip to content

Commit 73a6d8d

Browse files
feat(bulk-import): implement template execution for bulk-import (#1266)
* feat(bulk-import): implement bulk import with help of scaffolder template Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): code cleanup Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): cleanup deps Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix some of the failing tests Signed-off-by: Patrick <[email protected]> * feat(bulk-import): implement some gitlab specific stuff Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): simplify the starting template Signed-off-by: Patrick <[email protected]> * feat(bulk-import): swap branch descriptions Signed-off-by: Patrick <[email protected]> * feat(bulk-import): fix remaining failing tests Signed-off-by: Patrick <[email protected]> * feat(bulk-import): run yarn dedupe Signed-off-by: Patrick <[email protected]> * feat(bulk-import): remove unused file Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix link bug, use entityRef in config Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): implement task localization Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix compilation Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): hide dao types, update api.md Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): update sqlite dependency for node 22 Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix report again Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): cleanup Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): decrease code duplication Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): decrease code duplication Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): skip duplication for fixtures Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix sonarcloud warnings Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix some sonarcloud warnings Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix duplicated DB migration Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): remove confusing template Signed-off-by: Oleksandr Andriienko <[email protected]> * feat(bulk-import): fix compilation Signed-off-by: Oleksandr Andriienko <[email protected]> --------- Signed-off-by: Oleksandr Andriienko <[email protected]> Signed-off-by: Patrick <[email protected]> Co-authored-by: Patrick <[email protected]>
1 parent 43969ce commit 73a6d8d

File tree

92 files changed

+3977
-812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3977
-812
lines changed

.sonarcloud.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sonar.cpd.exclusions=workspaces/*/plugins/*/**/*.test.*, workspaces/*/plugins/*/src/translations/*.ts
1+
sonar.cpd.exclusions=workspaces/*/plugins/*/**/*.test.*, workspaces/*/plugins/*/src/translations/*.ts, workspaces/*/plugins/*/__fixtures__/*
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
playwright.config.ts
22
dist/
3-
dist-types/
3+
dist-types/
4+
plugins/bulk-import-backend/src/generated/openapi.d.ts

workspaces/bulk-import/app-config.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ backend:
3232
client: better-sqlite3
3333
connection: ':memory:'
3434
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir
35+
reading:
36+
allow:
37+
- host: raw.githubusercontent.com
3538

3639
integrations:
3740
gitlab:
@@ -92,9 +95,24 @@ catalog:
9295
- type: file
9396
target: ../../examples/entities.yaml
9497

95-
# Local example template
98+
# Local example templates
9699
- type: file
97-
target: ../../examples/template/template.yaml
100+
target: ../../examples/template/get-default-branch.yaml
101+
rules:
102+
- allow: [Template]
103+
104+
- type: file
105+
target: ../../examples/template/create-repo-with-catalog-info.yaml
106+
rules:
107+
- allow: [Template]
108+
109+
- type: file
110+
target: ../../examples/template/create-pr-with-catalog-info.yaml
111+
rules:
112+
- allow: [Template]
113+
114+
- type: file
115+
target: ../../examples/template/import-components-from-existing-repo.yaml
98116
rules:
99117
- allow: [Template]
100118

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
apiVersion: backstage.io/v1alpha1
22
kind: Component
33
metadata:
4-
name: ${{ values.name | dump }}
4+
name: ${{ values.name }}
5+
annotations:
6+
github.com/project-slug: ${{ values.organization }}/${{ values.name }}
57
spec:
6-
type: service
7-
owner: user:guest
8-
lifecycle: experimental
8+
type: other
9+
owner: ${{ values.organization }}
10+
lifecycle: unknown

workspaces/bulk-import/examples/template/content/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apiVersion: scaffolder.backstage.io/v1beta3
2+
kind: Template
3+
metadata:
4+
name: create-pr-with-catalog-info
5+
title: Propose catalog-info.yaml in the pull request
6+
description: Creates a catalog-info.yaml in the given GitHub repo.
7+
8+
spec:
9+
owner: user:default/guest
10+
type: service
11+
12+
parameters:
13+
- title: Provide repository details
14+
required:
15+
- repoUrl
16+
properties:
17+
repoUrl:
18+
type: string
19+
title: Repository URL (Backstage format)
20+
description: 'e.g. github.com?owner=Org&repo=repoName'
21+
organization:
22+
type: string
23+
title: Owner of the Repository
24+
branchName:
25+
type: string
26+
title: The branch to add the catalog entity to
27+
targetBranchName:
28+
type: string
29+
title: The branch to target the PR to
30+
name:
31+
type: string
32+
title: Name of the repository
33+
34+
steps:
35+
- id: fetch-base
36+
name: Fetch Base
37+
action: fetch:template
38+
input:
39+
url: ./content
40+
values:
41+
name: ${{ parameters.name }}
42+
organization: ${{ parameters.organization }}
43+
44+
- id: publish
45+
name: Create PR to add catalog-info.yaml
46+
action: publish:github:pull-request
47+
input:
48+
repoUrl: ${{ parameters.repoUrl }}
49+
branchName: ${{ parameters.branchName }}
50+
targetBranchName: ${{ parameters.targetBranchName }}
51+
title: 'Add catalog-info.yaml'
52+
description: 'This PR adds a default catalog-info.yaml for Backstage.'
53+
54+
- id: register
55+
name: Register catalog-info.yaml
56+
action: catalog:register
57+
input:
58+
optional: true
59+
repoContentsUrl: https://github.com/${{ parameters.organization }}/${{ parameters.name }}/blob/${{ parameters.branchName }}/catalog-info.yaml

workspaces/bulk-import/examples/template/template.yaml

Lines changed: 0 additions & 74 deletions
This file was deleted.

workspaces/bulk-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": "18 || 20"
77
},
88
"scripts": {
9-
"start": "backstage-cli repo start",
9+
"start": "NODE_OPTIONS=--no-node-snapshot backstage-cli repo start",
1010
"tsc": "tsc",
1111
"tsc:full": "tsc --skipLibCheck true --incremental false",
1212
"build:all": "backstage-cli repo build --all",

workspaces/bulk-import/packages/app/src/App.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
4848
import { UserSettingsPage } from '@backstage/plugin-user-settings';
4949
import { BulkImportPage } from '@red-hat-developer-hub/backstage-plugin-bulk-import';
5050
import { bulkImportTranslations } from '@red-hat-developer-hub/backstage-plugin-bulk-import/alpha';
51+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5152
import { getThemes } from '@redhat-developer/red-hat-developer-hub-theme';
5253
import { Navigate, Route } from 'react-router-dom';
5354
import { apis } from './apis';
@@ -98,6 +99,8 @@ const app = createApp({
9899
themes: getThemes(),
99100
});
100101

102+
const queryClient = new QueryClient();
103+
101104
const routes = (
102105
<FlatRoutes>
103106
<Route path="/" element={<Navigate to="catalog" />} />
@@ -133,7 +136,14 @@ const routes = (
133136
<Route path="/settings" element={<UserSettingsPage />} />
134137
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
135138
<Route path="/bulk-import" element={<Navigate to="repositories" />} />
136-
<Route path="/bulk-import/repositories" element={<BulkImportPage />} />
139+
<Route
140+
path="/bulk-import/repositories"
141+
element={
142+
<QueryClientProvider client={queryClient}>
143+
<BulkImportPage />
144+
</QueryClientProvider>
145+
}
146+
/>
137147
</FlatRoutes>
138148
);
139149

workspaces/bulk-import/packages/backend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@
3737
"@backstage/plugin-permission-node": "^0.10.3",
3838
"@backstage/plugin-proxy-backend": "^0.6.5",
3939
"@backstage/plugin-scaffolder-backend": "^2.2.0",
40+
"@backstage/plugin-scaffolder-backend-module-github": "^0.8.2",
4041
"@backstage/plugin-search-backend": "^2.0.5",
4142
"@backstage/plugin-search-backend-module-catalog": "^0.3.7",
4243
"@backstage/plugin-search-backend-module-pg": "^0.5.47",
4344
"@backstage/plugin-search-backend-module-techdocs": "^0.4.5",
4445
"@backstage/plugin-search-backend-node": "^1.3.14",
4546
"@backstage/plugin-techdocs-backend": "^2.0.5",
4647
"@red-hat-developer-hub/backstage-plugin-bulk-import-backend": "workspace:^",
48+
"@roadiehq/scaffolder-backend-module-utils": "^3.6.0",
4749
"app": "link:../app",
48-
"better-sqlite3": "^9.0.0",
50+
"better-sqlite3": "^12.4.1",
4951
"node-gyp": "^10.0.0",
5052
"pg": "^8.11.3",
5153
"winston": "^3.2.1"

0 commit comments

Comments
 (0)