@@ -23,6 +23,7 @@ Looking for information on how to use this module? Head on over to [README.md](
23
23
* [ Adding New Configuration Properties] ( #adding-new-configuration-properties )
24
24
* [ Code Comments] ( #code-comments )
25
25
* [ Debugging Tips] ( #debugging-tips )
26
+ * [ Pipeline Support] ( #pipeline-support )
26
27
* [ Testing] ( #testing )
27
28
* [ Installing Pester] ( #installing-pester )
28
29
* [ Configuring Your Environment] ( #configuring-your-environment )
@@ -152,7 +153,7 @@ Update-Module -Name PSScriptAnalyzer
152
153
Once it's installed (or updated), from the root of your enlistment simply call
153
154
154
155
``` powershell
155
- Invoke-ScriptAnalyzer -Path .\ -Recurse
156
+ Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 - Path ./ -Recurse
156
157
```
157
158
158
159
That should return with no output. If you see any output when calling that command,
@@ -242,7 +243,8 @@ Here are some general guidelines
242
243
reviewing/maintaining code. There are of course exceptions, but this is generally an enforced
243
244
preference. The [ Visual Studio Productivity Power Tools] ( https://visualstudiogallery.msdn.microsoft.com/34ebc6a2-2777-421d-8914-e29c1dfa7f5d )
244
245
extension has a "Column Guides" feature that makes it easy to add a Guideline in column 100
245
- to make it really obvious when coding.
246
+ to make it really obvious when coding. If you use VS Code, this module's ` .vscode/settings.json `
247
+ configures that for you automatically.
246
248
247
249
----------
248
250
@@ -286,8 +288,71 @@ Set-GitHubConfiguration -LogRequestBody
286
288
287
289
----------
288
290
291
+ ### Pipeline Support
292
+
293
+ This module has comprehensive support for the PowerShell pipeline. It is imperative that all
294
+ new functionality added to the module embraces this design.
295
+
296
+ * Most functions are declared as a ` filter ` . This is the equivalent of a ` function ` where the
297
+ body of the function is the ` process ` block, and the ` begin/end ` blocks are empty.
298
+
299
+ * In limited cases where one of the inputs is an array of something, and you specifically want that
300
+ to be processed as a single command (like adding a bunch of labels to a single issue at once),
301
+ you can implement it as a ` function ` where you use ` begin/process ` to gather all of the values
302
+ into a single internal array, and then do the actual command execution in the ` end ` block. A
303
+ good example of that which you can follow can be seen with ` Add-GitHubIssueLabel ` .
304
+
305
+ * Any function that requires the repo's ` Uri ` to be provided should be additionally aliased with
306
+ ` [Alias('RepositoryUrl')] ` and its ` [Parameter()] ` definition should include ` ValueFromPipelineByPropertyName ` .
307
+
308
+ * Do not use any generic term like ` Name ` in your parameters. That will end up causing unintended
309
+ pipeline issues down the line. For instance, if it's a label, call it ` Label ` , even though ` Name `
310
+ would make sense, other objects in the pipeline (like a ` GitHub.Respository ` object) also have
311
+ a ` name ` property that would conflict.
312
+
313
+ * You should plan on adding additional properties to all objects being returned from an API call.
314
+ Any object that is specific to a repository should have a ` RepositoryUrl ` ` NoteProperty ` added
315
+ to it, enabling it to be piped-in to any other command that requires knowing which repository
316
+ you're talking about. Additionally, any other property that might be necessary to uniquely
317
+ identify that object in a different command should get added properties. For example, with Issues,
318
+ we add both an ` IssueNumber ` property and an ` IssueId ` property to it, as the Issue commands
319
+ need to interact with the ` IssueNumber ` while the Event commands interact with the ` IssueId ` .
320
+ We prefer to _ only_ add additional properties that are believed to be needed as input to other
321
+ commands (as opposed to creating alias properties for all of the object's properties).
322
+
323
+ * For every major file, you will find an ` Add-GitHub*AdditionalProperties ` filter method at the end.
324
+ If you're writing a new file, you'll need to create this yourself (and model it after an existing
325
+ one). The goal of this is that you can simply pipe the output of your ` Invoke-GHRestMethod `
326
+ directly into this method to update the result with the additional properties, and then return
327
+ that modified version to the user. The benefit of this approach is that you can then apply that
328
+ filter on child objects within the primary object. For instance, a ` GitHub.Issue ` has multiple
329
+ ` GitHub.User ` objects, ` GitHub.Label ` objects, a ` GitHub.Milestone ` object and more. Within
330
+ ` Add-GitHubIssueAdditionalProperties ` , it just needs to know to call the appropriate
331
+ ` Add-GitHub*AdditionalProperties ` method on the qualifying child properties, without needing to
332
+ know anything more about them.
333
+
334
+ * That method will also "type" information to each object. This is forward-looking work to ease
335
+ support for providing formatting of various object types in the future. That type should be
336
+ defined at the top of the current file at the script level (see other files for an example),
337
+ and you should be sure to both specify it in the ` .OUTPUTS ` section of the Comment Based Help (CBH)
338
+ for the command, as well as with ` [OutputType({$script:GitHubUserTypeName})] ` (for example).
339
+
340
+ * Going along with the ` .OUTPUTS ` is the ` .INPUTS ` section. Please maintain this section as well.
341
+ If you add any new type that will gain a ` RepositoryUrl ` property, then you'll need to update
342
+ virtually _ all_ of the ` .INPUTS ` entries across all of the files where the function has a ` Uri `
343
+ parameter. Please keep these type names alphabetical.
344
+
345
+ * To enable debugging issues involving pipeline support, there is an additional configuration
346
+ property that you might use: ` Set-GitHubConfiguration -DisablePipelineSupport ` . That will
347
+ prevent the module from adding _ any_ additional properties to the objects.
348
+
349
+ ----------
350
+
289
351
### Testing
290
352
[ ![ Build status] ( https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
353
+ [ ![ Azure DevOps tests] ( https://img.shields.io/azure-devops/tests/ms/PowerShellForGitHub/109/master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
354
+ [ ![ Azure DevOps coverage] ( https://img.shields.io/azure-devops/coverage/ms/PowerShellForGitHub/109/master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
355
+
291
356
292
357
#### Installing Pester
293
358
This module supports testing using the [ Pester UT framework] ( https://github.com/pester/Pester ) .
@@ -350,6 +415,8 @@ There are many more nuances to code-coverage, see
350
415
351
416
#### Automated Tests
352
417
[ ![ Build status] ( https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
418
+ [ ![ Azure DevOps tests] ( https://img.shields.io/azure-devops/tests/ms/PowerShellForGitHub/109/master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
419
+ [ ![ Azure DevOps coverage] ( https://img.shields.io/azure-devops/coverage/ms/PowerShellForGitHub/109/master )] ( https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master )
353
420
354
421
These test are configured to automatically execute upon any update to the ` master ` branch
355
422
of ` microsoft/PowerShellForGitHub ` .
@@ -362,9 +429,9 @@ as well...it is stored, encrypted, within Azure DevOps. It is not accessible fo
362
429
the CI pipeline. To run the tests locally with your own account, see
363
430
[ configuring-your-environment] ( #configuring-your-environment ) .
364
431
365
- > NOTE: We're currently encountering issues with the tests successfully running within the pipeline.
366
- > They do complete successfully locally, so please test your changes locally before submitting a
367
- > pull request .
432
+ > Your change must successfully pass all tests before they will be merged. While we will run a CI
433
+ > build on your behalf for any submitted pull request, it's to your benefit to verify your changes
434
+ > locally first .
368
435
369
436
#### New Test Guidelines
370
437
Your tests should have NO dependencies on an account being set up in a specific way. They should
@@ -486,6 +553,7 @@ Thank you to all of our contributors, no matter how big or small the contributio
486
553
- ** [ Shannon Deminick (@Shazwazza )] ( http://github.com/Shazwazza ) **
487
554
- ** [ Jess Pomfret (@jpomfret )] ( https://github.com/jpomfret ) **
488
555
- ** [ Giuseppe Campanelli (@themilanfan )] ( https://github.com/themilanfan ) **
556
+ - ** [ Christoph Bergmeister (@bergmeister )] ( https://github.com/bergmeister ) **
489
557
490
558
----------
491
559
0 commit comments