@spotify/backstage-plugin-soundcheck-backend-module-github 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -485
  3. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @spotify/backstage-plugin-soundcheck-backend-module-github
2
2
 
3
+ ## 0.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated backstage dependencies to `v1.24.0`
8
+ - Updated dependencies
9
+ - `@spotify/backstage-plugin-soundcheck-common` to `^0.13.0`
10
+ - `@spotify/backstage-plugin-soundcheck-node` to `^0.6.0`
11
+
3
12
  ## 0.5.2
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -1,488 +1,5 @@
1
1
  # Spotify Plugins for Backstage: Soundcheck - Github Integration
2
2
 
3
- Github integration plugin for [Soundcheck](https://backstage.spotify.com/plugins/soundcheck/).
4
- Similarly to [SCM Integration plugin](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend-module-scm), it provides out-of-box integration with Github by leveraging Backstage's Github integration and implements extraction and collection of facts from Github repositories.
5
- The purpose of Github Integration plugin is to provide Github-specific fact collection (like branch protections), while the SCM Integration plugin provides the collection of facts based on repository content.
3
+ This plugin is part of [Spotify Plugins for Backstage](https://backstage.spotify.com/marketplace/spotify/bundle/spotify-plugins-bundle/).
6
4
 
7
- Github integration plugin supports the extraction of the following facts:
8
-
9
- - [BranchProtections](#collecting-branchprotections-fact)
10
- - [RepositoryDetails](#collecting-repositorydetails-fact)
11
-
12
- <!-- TOC -->
13
-
14
- - [Spotify Plugins for Backstage: Soundcheck - Github Integration](#spotify-plugins-for-backstage-soundcheck---github-integration)
15
- - [Prerequisites](#prerequisites)
16
- - [Configure Github integration in Backstage](#configure-github-integration-in-backstage)
17
- - [Plugin Configuration](#plugin-configuration)
18
- - [Defining Github Fact Collectors](#defining-github-fact-collectors)
19
- - [Overall Shape Of A Github Fact Collector](#overall-shape-of-a-github-fact-collector)
20
- - [`frequency` [optional]](#frequency-optional)
21
- - [`filter` [optional]](#filter-optional)
22
- - [`cache` [optional]](#cache-optional)
23
- - [`collects` [required]](#collects-required)
24
- - [Overall Shape Of A Fact Extractor](#overall-shape-of-a-fact-extractor)
25
- - [`factName` [required]](#factname-required)
26
- - [`type` [required]](#type-required)
27
- - [`frequency` [optional]](#frequency-optional)
28
- - [`branch` [optional]](#branch-optional)
29
- - [`filter` [optional]](#filter-optional)
30
- - [`cache` [optional]](#cache-optional)
31
- - [Collecting BranchProtections Fact](#collecting-branchprotections-fact)
32
- - [Shape of A BranchProtections Fact Collector](#shape-of-a-branchprotections-fact-collector)
33
- - [Shape of A BranchProtections Fact](#shape-of-a-branchprotections-fact)
34
- - [Shape of A BranchProtections Fact Check](#shape-of-a-branchprotections-fact-check)
35
- - [Collecting RepositoryDetails Fact](#collecting-repositorydetails-fact)
36
- - [Shape of A RepositoryDetails Fact Collector](#shape-of-a-repositorydetails-fact-collector)
37
- - [Shape of A RepositoryDetails Fact](#shape-of-a-repositorydetails-fact)
38
- - [Shape of A RepositoryDetails Fact Check](#shape-of-a-repositorydetails-fact-check)
39
- <!-- TOC -->
40
-
41
- ## Prerequisites
42
-
43
- ### Configure Github integration in Backstage
44
-
45
- Integrations are configured at the root level of `app-config.yaml`, here's an example configuration for Github:
46
-
47
- ```yaml
48
- integrations:
49
- github:
50
- - host: github.com
51
- token: ${GITHUB_TOKEN}
52
- ```
53
-
54
- Follow the [instructions](https://backstage.io/docs/integrations/github/locations) for full details on configuration.
55
-
56
- ### Add the GitHubFactCollector to Soundcheck
57
-
58
- First add the package: `yarn workspace backend add @spotify/backstage-plugin-soundcheck-backend-module-github`
59
-
60
- Then in `packages/backend/src/plugins/soundcheck.ts`, add the `GitHubFactCollector`:
61
-
62
- ```diff
63
- import { SoundcheckBuilder } from '@spotify/backstage-plugin-soundcheck-backend';
64
- import { Router } from 'express';
65
- import { PluginEnvironment } from '../types';
66
- + import { GithubFactCollector } from '@spotify/backstage-plugin-soundcheck-backend-module-github';
67
-
68
- export default async function createPlugin(
69
- env: PluginEnvironment,
70
- ): Promise<Router> {
71
- return SoundcheckBuilder.create({ ...env })
72
- + .addFactCollectors(
73
- + GithubFactCollector.create(env.config, env.logger, env.cache),
74
- + )
75
- .build();
76
- }
77
- ```
78
-
79
- #### New Backend System
80
-
81
- If you are using the New Backend System, instead of the above, you can just add
82
- the following to your `packages/backend/src/index.ts` file:
83
-
84
- ```diff
85
- const backend = createBackend();
86
-
87
- backend.add(import('@spotify/backstage-plugin-soundcheck-backend'));
88
- + backend.add(import('@spotify/backstage-plugin-soundcheck-backend-module-github'));
89
- // ...
90
-
91
- backend.start();
92
- ```
93
-
94
- See the the soundcheck-backend [documentation](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#2-install-soundcheck-backend)
95
- for additional details on creating the Soundcheck backend.
96
-
97
- ## Plugin Configuration
98
-
99
- Collection of facts is driven by config. To learn more about the config, see the [Defining Github Fact Collectors](#defining-github-fact-collectors).
100
-
101
- 1. Create `github-facts-collectors.yaml` in the root of your Backstage repository and fill in all your Github fact collectors.
102
- A simple example Github fact collector is listed below.
103
-
104
- **Note:** this file will be loaded at runtime along with the rest of your Backstage configuration files, so make sure it's available in deployed environments in the same way as your `app-config.yaml` files.
105
-
106
- ```yaml
107
- ---
108
- frequency:
109
- cron: '0 * * * *'
110
- collects:
111
- - factName: branch_protections
112
- type: BranchProtections
113
- branch: master
114
- - factName: repo_details
115
- type: RepositoryDetails
116
- ```
117
-
118
- 2. Add a soundcheck collectors field to `app-config.yaml` and reference the newly created `github-facts-collectors.yaml`
119
-
120
- ```yaml
121
- # app-config.yaml
122
- soundcheck:
123
- collectors:
124
- github:
125
- $include: ./github-facts-collectors.yaml
126
- ```
127
-
128
- ### Rate Limiting (Optional)
129
-
130
- This fact collector can be rate limited in Soundcheck using the following configuration:
131
-
132
- ```yaml
133
- soundcheck:
134
- job:
135
- workers:
136
- github:
137
- limiter:
138
- max: 4900
139
- duration: 3600000
140
- ```
141
-
142
- Github API has a limit of [5000 requests per hour (15000 for Enterprise)](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28). We recommend setting your rate limit to something below this, i.e. in the example above, we set the rate limit to 4900 executions every hour.
143
-
144
- This fact collector handles rate limit errors per the [recommendation from Github](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit). Soundcheck will automatically wait and retry requests that are rate limited.
145
-
146
- ## Defining Github Fact Collectors
147
-
148
- This section describes the data shape and semantics of Github Fact Collectors.
149
-
150
- ### Overall Shape Of A Github Fact Collector
151
-
152
- The following is an example of a descriptor file for a Github Fact Collector:
153
-
154
- ```yaml
155
- ---
156
- frequency:
157
- cron: '0 * * * *'
158
- filter:
159
- kind: 'Component'
160
- cache:
161
- duration:
162
- hours: 2
163
- collects:
164
- - factName: branch_protections
165
- type: BranchProtections
166
- branch: master
167
- filter:
168
- - spec.lifecycle: 'production'
169
- spec.type: 'website'
170
- cache: false
171
- - factName: repo_details
172
- type: RepositoryDetails
173
- cache: true
174
- ```
175
-
176
- See below for details about these fields.
177
-
178
- #### `frequency` [optional]
179
-
180
- The frequency at which the collector should be executed. Possible values are either a cron expression `{ cron: ... }` or [HumanDuration](https://backstage.io/docs/reference/backend-tasks.humanduration).
181
- This is the default frequency for each extractor.
182
-
183
- #### `filter` [optional]
184
-
185
- A filter specifying which entities to collect the specified facts for. Matches the [filter format](https://backstage.io/docs/reference/catalog-client.entityfilterquery) used by the Catalog API.
186
- This is the default filter for each extractor.
187
-
188
- #### `cache` [optional]
189
-
190
- If the collected facts should be cached, and if so for how long. Possible values are either `true` or `false` or a nested `{ duration:` [HumanDuration](https://backstage.io/docs/reference/types.humanduration) `}` field.
191
- This is the default cache config for each extractor.
192
-
193
- #### `collects` [required]
194
-
195
- An array describing which facts to collect and how to extract them. See below for details about the overall shape of a fact extractor.
196
-
197
- ### Overall Shape Of A Fact Extractor
198
-
199
- Each extractor supports the fields described below.
200
-
201
- #### `factName` [required]
202
-
203
- The name of the fact to be extracted.
204
-
205
- - Minimum length of 1
206
- - Maximum length of 100
207
- - Alphanumeric with single separator instances of periods, dashes, underscores, or forward slashes
208
-
209
- #### `type` [required]
210
-
211
- The type of the extractor (e.g. BranchProtections, RepositoryDetails).
212
-
213
- #### `frequency` [optional]
214
-
215
- The frequency at which the fact extraction should be executed. Possible values are either a cron expression `{ cron: ... }` or [HumanDuration](https://backstage.io/docs/reference/backend-tasks.humanduration).
216
- If provided it overrides the default frequency provided at the top level. If not provided it defaults to the frequency provided at the top level. If neither extractor's frequency nor default frequency is provided the fact will only be collected on demand.
217
- Example:
218
-
219
- ```yaml
220
- frequency:
221
- minutes: 10
222
- ```
223
-
224
- #### `branch` [optional]
225
-
226
- The branch to extract the fact from. If not provided, defaults to the repository's default branch.
227
-
228
- #### `filter` [optional]
229
-
230
- A filter specifying which entities to collect the specified facts for. Matches the [filter format](https://backstage.io/docs/reference/catalog-client.entityfilterquery) used by the Catalog API.
231
- If provided it overrides the default filter provided at the top level. If not provided it defaults to the filter provided at the top level. If neither extractor's filter nor default filter is provided the fact will be collected for all entities.
232
-
233
- #### `cache` [optional]
234
-
235
- If the collected facts should be cached, and if so for how long. Possible values are either `true` or `false` or a nested `{ duration:` [HumanDuration](https://backstage.io/docs/reference/types.humanduration) `}` field.
236
- If provided it overrides the default cache config provided at the top level. If not provided it defaults to the cache config provided at the top level. If neither extractor's cache nor default cache config is provided the fact will not be cached.
237
- Example:
238
-
239
- ```yaml
240
- cache:
241
- duration:
242
- hours: 24
243
- ```
244
-
245
- ## Collecting BranchProtections Fact
246
-
247
- BranchProtections fact contains information about configured branch protections for a given branch in Github repository.
248
-
249
- ### Shape of A BranchProtections Fact Collector
250
-
251
- The shape of a BranchProtections Fact Collector matches the [Overall Shape Of A Github Fact Collector](#overall-shape-of-a-github-fact-collector) (restriction: `type: BranchProtections`).
252
-
253
- The following is an example of the BranchProtections Fact Collector config:
254
-
255
- ```yaml
256
- collects:
257
- - factName: branch_protections
258
- type: BranchProtections
259
- frequency:
260
- cron: '0 * * * *'
261
- branch: master
262
- filter:
263
- - spec.lifecycle: 'production'
264
- spec.type: 'website'
265
- cache: false
266
- ```
267
-
268
- ### Shape of A BranchProtections Fact
269
-
270
- The shape of a BranchProtections Fact is based on the [Fact Schema](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#fact-schema).
271
-
272
- For a description of the data collected regarding branch protection, refer to the [Github API documentation](https://docs.github.com/en/rest/branches/branch-protection).
273
-
274
- The following is an example of the collected BranchProtections Fact:
275
-
276
- ```yaml
277
- factRef: github:master/branch_protections
278
- entityRef: component:default/queue-proxy
279
- scope: master
280
- timestamp: 2023-02-24T15:50+00Z
281
- data:
282
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection'
283
- required_pull_request_reviews:
284
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/required_pull_request_reviews',
285
- dismiss_stale_reviews: false
286
- require_code_owner_reviews: true
287
- required_approving_review_count: 2
288
- require_last_push_approval: false
289
- required_signatures:
290
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/required_signatures'
291
- enabled: false
292
- enforce_admins:
293
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/enforce_admins'
294
- enabled: false
295
- required_linear_history:
296
- enabled: false
297
- allow_force_pushes:
298
- enabled: true
299
- allow_deletions:
300
- enabled: true
301
- block_creations:
302
- enabled: true
303
- required_conversation_resolution:
304
- enabled: false
305
- lock_branch:
306
- enabled: false
307
- allow_fork_syncing:
308
- enabled: true
309
- ```
310
-
311
- ### Shape of A BranchProtections Fact Check
312
-
313
- The shape of a BranchProtections Fact Check matches the [Shape of a Fact Check](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#shape-of-a-fact-check).
314
-
315
- The following is an example of the BranchProtections fact checks:
316
-
317
- ```yaml
318
- soundcheck:
319
- checks:
320
- - id: requires_code_owner_reviews
321
- rule:
322
- factRef: github:master/branch_protections
323
- path: $.required_pull_request_reviews.require_code_owner_reviews
324
- operator: equal
325
- value: true
326
- - id: requires_at_least_two_approving_reviews
327
- rule:
328
- factRef: github:master/branch_protections
329
- path: $.required_pull_request_reviews.required_approving_review_count
330
- operator: greaterThanInclusive
331
- value: 2
332
- ```
333
-
334
- The following is an example of the Soundcheck program that utilizes these checks:
335
-
336
- ```yaml
337
- - id: demo
338
- name: Demo
339
- ownerEntityRef: group:default/owning_group
340
- description: Demonstration of Soundcheck BranchProtections Fact Extractor
341
- levels:
342
- - ordinal: 1
343
- name: First level
344
- description: Checks leveraging Soundcheck's Github BranchProtections Fact Extractor
345
- checks:
346
- - id: requires_code_owner_reviews
347
- name: Requires code owner reviews
348
- description: PR requires code owner reviews
349
- - id: requires_at_least_two_approving_reviews
350
- name: Requires at least two approving reviews
351
- description: PR requires at least two approving reviews
352
- ```
353
-
354
- ## Collecting RepositoryDetails Fact
355
-
356
- RepositoryDetails fact contains information about a Github repository.
357
-
358
- ### Shape of A RepositoryDetails Fact Collector
359
-
360
- The shape of a RepositoryDetails Fact Collector matches the [Overall Shape Of A Github Fact Collector](#overall-shape-of-a-github-fact-collector) (restriction: `type: RepositoryDetails`).
361
-
362
- The following is an example of the RepositoryDetails Fact Collector config:
363
-
364
- ```yaml
365
- collects:
366
- - factName: repo_details
367
- type: RepositoryDetails
368
- frequency:
369
- cron: '0 * * * *'
370
- filter:
371
- - spec.lifecycle: 'production'
372
- cache: true
373
- ```
374
-
375
- ### Shape of A RepositoryDetails Fact
376
-
377
- The shape of a RepositoryDetails Fact is based on the [Fact Schema](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#fact-schema).
378
-
379
- For a description of the data collected about repository, refer to the [Github API documentation](https://docs.github.com/en/rest/repos/repos#get-a-repository).
380
-
381
- The following is an example of the collected RepositoryDetails Fact:
382
-
383
- ```yaml
384
- factRef: github:default/repo_details
385
- entityRef: component:default/queue-proxy
386
- scope: default
387
- timestamp: 2023-02-24T15:50+00Z
388
- data:
389
- name: backstage
390
- full_name: backstage/backstage
391
- private: true
392
- html_url: 'https://github.com/backstage/backstage'
393
- description: null
394
- fork: false
395
- url: 'https://api.github.com/repos/backstage/backstage'
396
- homepage: null
397
- size: 3
398
- stargazers_count: 0
399
- watchers_count: 0
400
- language: null
401
- has_issues: true
402
- has_projects: true
403
- has_downloads: true
404
- has_wiki: true
405
- has_pages: false
406
- has_discussions: false
407
- forks_count: 0
408
- mirror_url: null
409
- archived: false
410
- disabled: false
411
- open_issues_count: 0
412
- license: null
413
- allow_forking: true
414
- is_template: false
415
- web_commit_signoff_required: false
416
- visibility: 'private'
417
- forks: 0
418
- open_issues: 0
419
- watchers: 0
420
- default_branch: master
421
- permissions:
422
- admin: true
423
- maintain: true
424
- push: true
425
- triage: true
426
- pull: true
427
- allow_squash_merge: true
428
- allow_merge_commit: true
429
- allow_rebase_merge: true
430
- allow_auto_merge: false
431
- delete_branch_on_merge: false
432
- allow_update_branch: false
433
- use_squash_pr_title_as_default: false
434
- squash_merge_commit_message: 'COMMIT_MESSAGES'
435
- squash_merge_commit_title: 'COMMIT_OR_PR_TITLE'
436
- merge_commit_message: 'PR_TITLE'
437
- merge_commit_title: 'MERGE_MESSAGE'
438
- security_and_analysis:
439
- secret_scanning:
440
- status: 'disabled'
441
- secret_scanning_push_protection:
442
- status: 'disabled'
443
- network_count: 0
444
- subscribers_count: 1
445
- ```
446
-
447
- ### Shape of A RepositoryDetails Fact Check
448
-
449
- The shape of a RepositoryDetails Fact Check matches the [Shape of a Fact Check](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#shape-of-a-fact-check).
450
-
451
- The following is an example of the RepositoryDetails fact checks:
452
-
453
- ```yaml
454
- soundcheck:
455
- checks:
456
- - id: allows_rebase_merge
457
- rule:
458
- factRef: github:default/repo_details
459
- path: $.allow_rebase_merge
460
- operator: equal
461
- value: true
462
- - id: has_less_than_ten_open_issues
463
- rule:
464
- factRef: github:default/repo_details
465
- path: $.open_issues
466
- operator: lessThan
467
- value: 10
468
- ```
469
-
470
- The following is an example of the Soundcheck program that utilizes these checks:
471
-
472
- ```yaml
473
- - id: demo
474
- name: Demo
475
- ownerEntityRef: group:default/owning_group
476
- description: Demonstration of Soundcheck RepositoryDetails Fact Extractor
477
- levels:
478
- - ordinal: 1
479
- name: First level
480
- description: Checks leveraging Soundcheck's Github RepositoryDetails Fact Extractor
481
- checks:
482
- - id: allows_rebase_merge
483
- name: Allows Rebase Merge
484
- description: Repository allows rebase merge
485
- - id: has_less_than_ten_open_issues
486
- name: Has Less Than 10 Open Issues
487
- description: Github Repository Has Less Than 10 Open Issues
488
- ```
5
+ If you are already a customer, you can find detailed documentation about the Soundcheck Plugins [here](https://backstage.spotify.com/docs/soundcheck/core-concepts/fact-collectors/3p-integrations/github].
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotify/backstage-plugin-soundcheck-backend-module-github",
3
3
  "description": "Soundcheck 3rd party integration with Github",
4
- "version": "0.5.2",
4
+ "version": "0.5.3",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://backstage.spotify.com",
7
7
  "main": "dist/index.cjs.js",
@@ -22,24 +22,24 @@
22
22
  "postpack": "backstage-cli package postpack"
23
23
  },
24
24
  "devDependencies": {
25
- "@backstage/backend-test-utils": "^0.3.0",
26
- "@backstage/cli": "^0.25.2",
27
- "@spotify/backstage-plugin-soundcheck-backend": "^0.14.0",
25
+ "@backstage/backend-test-utils": "^0.3.4",
26
+ "@backstage/cli": "^0.26.0",
27
+ "@spotify/backstage-plugin-soundcheck-backend": "^0.15.0",
28
28
  "@types/git-url-parse": "^9.0.0",
29
29
  "supertest": "^6.1.3"
30
30
  },
31
31
  "dependencies": {
32
- "@backstage/backend-common": "^0.21.0",
33
- "@backstage/backend-plugin-api": "^0.6.10",
34
- "@backstage/catalog-model": "^1.4.4",
35
- "@backstage/config": "^1.1.1",
36
- "@backstage/errors": "^1.2.3",
37
- "@backstage/integration": "^1.9.0",
32
+ "@backstage/backend-common": "^0.21.4",
33
+ "@backstage/backend-plugin-api": "^0.6.14",
34
+ "@backstage/catalog-model": "^1.4.5",
35
+ "@backstage/config": "^1.2.0",
36
+ "@backstage/errors": "^1.2.4",
37
+ "@backstage/integration": "^1.9.1",
38
38
  "@backstage/types": "^1.1.1",
39
39
  "@octokit/request-error": "^5.0.0",
40
40
  "@octokit/rest": "^20.0.0",
41
- "@spotify/backstage-plugin-soundcheck-common": "^0.12.0",
42
- "@spotify/backstage-plugin-soundcheck-node": "^0.5.0",
41
+ "@spotify/backstage-plugin-soundcheck-common": "^0.13.0",
42
+ "@spotify/backstage-plugin-soundcheck-node": "^0.6.0",
43
43
  "git-url-parse": "^14.0.0",
44
44
  "lodash": "^4.17.21",
45
45
  "winston": "^3.2.1",