@spotify/backstage-plugin-soundcheck-backend-module-github 0.5.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
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
+
12
+ ## 0.5.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Changes to support Backstage's New Backend System.
17
+ - Added automated rate limit error handling to GitHub fact collector, leverging the `RateLimitError` introduced to Job Queues as a way to automatically throttle scheduled jobs.
18
+ - Downgraded log level from `error` to `warning` for some non terminal errors that could occur during fact collection for the Github fact collector.
19
+ - Upgraded to Backstage `v1.23.0`
20
+ - Updated dependencies
21
+ - `@spotify/backstage-plugin-soundcheck-node` to `^0.5.0`
22
+ - `@spotify/backstage-plugin-soundcheck-common` to `^0.12.0`
23
+ - `git-url-parse` to `^14.0.0`
24
+
3
25
  ## 0.5.1
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -1,455 +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
- See the the soundcheck-backend [documentation](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#2-install-soundcheck-backend)
80
- for additional details on creating the Soundcheck backend.
81
-
82
- ## Plugin Configuration
83
-
84
- Collection of facts is driven by config. To learn more about the config, see the [Defining Github Fact Collectors](#defining-github-fact-collectors).
85
-
86
- 1. Create `github-facts-collectors.yaml` in the root of your Backstage repository and fill in all your Github fact collectors.
87
- A simple example Github fact collector is listed below.
88
-
89
- **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.
90
-
91
- ```yaml
92
- ---
93
- frequency:
94
- cron: '0 * * * *'
95
- collects:
96
- - factName: branch_protections
97
- type: BranchProtections
98
- branch: master
99
- - factName: repo_details
100
- type: RepositoryDetails
101
- ```
102
-
103
- 2. Add a soundcheck collectors field to `app-config.yaml` and reference the newly created `github-facts-collectors.yaml`
104
-
105
- ```yaml
106
- # app-config.yaml
107
- soundcheck:
108
- collectors:
109
- github:
110
- $include: ./github-facts-collectors.yaml
111
- ```
112
-
113
- ## Defining Github Fact Collectors
114
-
115
- This section describes the data shape and semantics of Github Fact Collectors.
116
-
117
- ### Overall Shape Of A Github Fact Collector
118
-
119
- The following is an example of a descriptor file for a Github Fact Collector:
120
-
121
- ```yaml
122
- ---
123
- frequency:
124
- cron: '0 * * * *'
125
- filter:
126
- kind: 'Component'
127
- cache:
128
- duration:
129
- hours: 2
130
- collects:
131
- - factName: branch_protections
132
- type: BranchProtections
133
- branch: master
134
- filter:
135
- - spec.lifecycle: 'production'
136
- spec.type: 'website'
137
- cache: false
138
- - factName: repo_details
139
- type: RepositoryDetails
140
- cache: true
141
- ```
142
-
143
- See below for details about these fields.
144
-
145
- #### `frequency` [optional]
146
-
147
- 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).
148
- This is the default frequency for each extractor.
149
-
150
- #### `filter` [optional]
151
-
152
- 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.
153
- This is the default filter for each extractor.
154
-
155
- #### `cache` [optional]
156
-
157
- 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.
158
- This is the default cache config for each extractor.
159
-
160
- #### `collects` [required]
161
-
162
- An array describing which facts to collect and how to extract them. See below for details about the overall shape of a fact extractor.
163
-
164
- ### Overall Shape Of A Fact Extractor
165
-
166
- Each extractor supports the fields described below.
167
-
168
- #### `factName` [required]
169
-
170
- The name of the fact to be extracted.
171
-
172
- - Minimum length of 1
173
- - Maximum length of 100
174
- - Alphanumeric with single separator instances of periods, dashes, underscores, or forward slashes
175
-
176
- #### `type` [required]
177
-
178
- The type of the extractor (e.g. BranchProtections, RepositoryDetails).
179
-
180
- #### `frequency` [optional]
181
-
182
- 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).
183
- 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.
184
- Example:
185
-
186
- ```yaml
187
- frequency:
188
- minutes: 10
189
- ```
190
-
191
- #### `branch` [optional]
192
-
193
- The branch to extract the fact from. If not provided, defaults to the repository's default branch.
194
-
195
- #### `filter` [optional]
196
-
197
- 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.
198
- 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.
199
-
200
- #### `cache` [optional]
201
-
202
- 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.
203
- 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.
204
- Example:
205
-
206
- ```yaml
207
- cache:
208
- duration:
209
- hours: 24
210
- ```
211
-
212
- ## Collecting BranchProtections Fact
213
-
214
- BranchProtections fact contains information about configured branch protections for a given branch in Github repository.
215
-
216
- ### Shape of A BranchProtections Fact Collector
217
-
218
- 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`).
219
-
220
- The following is an example of the BranchProtections Fact Collector config:
221
-
222
- ```yaml
223
- collects:
224
- - factName: branch_protections
225
- type: BranchProtections
226
- frequency:
227
- cron: '0 * * * *'
228
- branch: master
229
- filter:
230
- - spec.lifecycle: 'production'
231
- spec.type: 'website'
232
- cache: false
233
- ```
234
-
235
- ### Shape of A BranchProtections Fact
236
-
237
- The shape of a BranchProtections Fact is based on the [Fact Schema](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#fact-schema).
238
-
239
- 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).
240
-
241
- The following is an example of the collected BranchProtections Fact:
242
-
243
- ```yaml
244
- factRef: github:master/branch_protections
245
- entityRef: component:default/queue-proxy
246
- scope: master
247
- timestamp: 2023-02-24T15:50+00Z
248
- data:
249
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection'
250
- required_pull_request_reviews:
251
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/required_pull_request_reviews',
252
- dismiss_stale_reviews: false
253
- require_code_owner_reviews: true
254
- required_approving_review_count: 2
255
- require_last_push_approval: false
256
- required_signatures:
257
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/required_signatures'
258
- enabled: false
259
- enforce_admins:
260
- url: 'https://api.github.com/repos/backstage/backstage/branches/master/protection/enforce_admins'
261
- enabled: false
262
- required_linear_history:
263
- enabled: false
264
- allow_force_pushes:
265
- enabled: true
266
- allow_deletions:
267
- enabled: true
268
- block_creations:
269
- enabled: true
270
- required_conversation_resolution:
271
- enabled: false
272
- lock_branch:
273
- enabled: false
274
- allow_fork_syncing:
275
- enabled: true
276
- ```
277
-
278
- ### Shape of A BranchProtections Fact Check
279
-
280
- 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).
281
-
282
- The following is an example of the BranchProtections fact checks:
283
-
284
- ```yaml
285
- soundcheck:
286
- checks:
287
- - id: requires_code_owner_reviews
288
- rule:
289
- factRef: github:master/branch_protections
290
- path: $.required_pull_request_reviews.require_code_owner_reviews
291
- operator: equal
292
- value: true
293
- - id: requires_at_least_two_approving_reviews
294
- rule:
295
- factRef: github:master/branch_protections
296
- path: $.required_pull_request_reviews.required_approving_review_count
297
- operator: greaterThanInclusive
298
- value: 2
299
- ```
300
-
301
- The following is an example of the Soundcheck program that utilizes these checks:
302
-
303
- ```yaml
304
- - id: demo
305
- name: Demo
306
- ownerEntityRef: group:default/owning_group
307
- description: Demonstration of Soundcheck BranchProtections Fact Extractor
308
- levels:
309
- - ordinal: 1
310
- name: First level
311
- description: Checks leveraging Soundcheck's Github BranchProtections Fact Extractor
312
- checks:
313
- - id: requires_code_owner_reviews
314
- name: Requires code owner reviews
315
- description: PR requires code owner reviews
316
- - id: requires_at_least_two_approving_reviews
317
- name: Requires at least two approving reviews
318
- description: PR requires at least two approving reviews
319
- ```
320
-
321
- ## Collecting RepositoryDetails Fact
322
-
323
- RepositoryDetails fact contains information about a Github repository.
324
-
325
- ### Shape of A RepositoryDetails Fact Collector
326
-
327
- 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`).
328
-
329
- The following is an example of the RepositoryDetails Fact Collector config:
330
-
331
- ```yaml
332
- collects:
333
- - factName: repo_details
334
- type: RepositoryDetails
335
- frequency:
336
- cron: '0 * * * *'
337
- filter:
338
- - spec.lifecycle: 'production'
339
- cache: true
340
- ```
341
-
342
- ### Shape of A RepositoryDetails Fact
343
-
344
- The shape of a RepositoryDetails Fact is based on the [Fact Schema](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#fact-schema).
345
-
346
- 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).
347
-
348
- The following is an example of the collected RepositoryDetails Fact:
349
-
350
- ```yaml
351
- factRef: github:default/repo_details
352
- entityRef: component:default/queue-proxy
353
- scope: default
354
- timestamp: 2023-02-24T15:50+00Z
355
- data:
356
- name: backstage
357
- full_name: backstage/backstage
358
- private: true
359
- html_url: 'https://github.com/backstage/backstage'
360
- description: null
361
- fork: false
362
- url: 'https://api.github.com/repos/backstage/backstage'
363
- homepage: null
364
- size: 3
365
- stargazers_count: 0
366
- watchers_count: 0
367
- language: null
368
- has_issues: true
369
- has_projects: true
370
- has_downloads: true
371
- has_wiki: true
372
- has_pages: false
373
- has_discussions: false
374
- forks_count: 0
375
- mirror_url: null
376
- archived: false
377
- disabled: false
378
- open_issues_count: 0
379
- license: null
380
- allow_forking: true
381
- is_template: false
382
- web_commit_signoff_required: false
383
- visibility: 'private'
384
- forks: 0
385
- open_issues: 0
386
- watchers: 0
387
- default_branch: master
388
- permissions:
389
- admin: true
390
- maintain: true
391
- push: true
392
- triage: true
393
- pull: true
394
- allow_squash_merge: true
395
- allow_merge_commit: true
396
- allow_rebase_merge: true
397
- allow_auto_merge: false
398
- delete_branch_on_merge: false
399
- allow_update_branch: false
400
- use_squash_pr_title_as_default: false
401
- squash_merge_commit_message: 'COMMIT_MESSAGES'
402
- squash_merge_commit_title: 'COMMIT_OR_PR_TITLE'
403
- merge_commit_message: 'PR_TITLE'
404
- merge_commit_title: 'MERGE_MESSAGE'
405
- security_and_analysis:
406
- secret_scanning:
407
- status: 'disabled'
408
- secret_scanning_push_protection:
409
- status: 'disabled'
410
- network_count: 0
411
- subscribers_count: 1
412
- ```
413
-
414
- ### Shape of A RepositoryDetails Fact Check
415
-
416
- 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).
417
-
418
- The following is an example of the RepositoryDetails fact checks:
419
-
420
- ```yaml
421
- soundcheck:
422
- checks:
423
- - id: allows_rebase_merge
424
- rule:
425
- factRef: github:default/repo_details
426
- path: $.allow_rebase_merge
427
- operator: equal
428
- value: true
429
- - id: has_less_than_ten_open_issues
430
- rule:
431
- factRef: github:default/repo_details
432
- path: $.open_issues
433
- operator: lessThan
434
- value: 10
435
- ```
436
-
437
- The following is an example of the Soundcheck program that utilizes these checks:
438
-
439
- ```yaml
440
- - id: demo
441
- name: Demo
442
- ownerEntityRef: group:default/owning_group
443
- description: Demonstration of Soundcheck RepositoryDetails Fact Extractor
444
- levels:
445
- - ordinal: 1
446
- name: First level
447
- description: Checks leveraging Soundcheck's Github RepositoryDetails Fact Extractor
448
- checks:
449
- - id: allows_rebase_merge
450
- name: Allows Rebase Merge
451
- description: Repository allows rebase merge
452
- - id: has_less_than_ten_open_issues
453
- name: Has Less Than 10 Open Issues
454
- description: Github Repository Has Less Than 10 Open Issues
455
- ```
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].