A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/PowerShellForGitHub/commit/17f6122d7812ee4001ce4bdf630429e711e45f7b below:

Adding complete Pipeline support to the entire module (#242) · microsoft/PowerShellForGitHub@17f6122 · GitHub

@@ -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)

@@ -286,8 +287,71 @@ Set-GitHubConfiguration -LogRequestBody

286 287 287 288

----------

288 289 290 +

### Pipeline Support

291 + 292 +

This module has comprehensive support for the PowerShell pipeline. It is imperative that all

293 +

new functionality added to the module embraces this design.

294 + 295 +

* Most functions are declared as a `filter`. This is the equivalent of a `function` where the

296 +

body of the function is the `process` block, and the `begin/end` blocks are empty.

297 + 298 +

* In limited cases where one of the inputs is an array of something, and you specifically want that

299 +

to be processed as a single command (like adding a bunch of labels to a single issue at once),

300 +

you can implement it as a `function` where you use `begin/process` to gather all of the values

301 +

into a single internal array, and then do the actual command execution in the `end` block. A

302 +

good example of that which you can follow can be seen with `Add-GitHubIssueLabel`.

303 + 304 +

* Any function that requires the repo's `Uri` to be provided should be additionally aliased with

305 +

`[Alias('RepositoryUrl')]` and its `[Parameter()]` definition should include `ValueFromPipelineByPropertyName`.

306 + 307 +

* Do not use any generic term like `Name` in your parameters. That will end up causing unintended

308 +

pipeline issues down the line. For instance, if it's a label, call it `Label`, even though `Name`

309 +

would make sense, other objects in the pipeline (like a `GitHub.Respository` object) also have

310 +

a `name` property that would conflict.

311 + 312 +

* You should plan on adding additional properties to all objects being returned from an API call.

313 +

Any object that is specific to a repository should have a `RepositoryUrl` `NoteProperty` added

314 +

to it, enabling it to be piped-in to any other command that requires knowing which repository

315 +

you're talking about. Additionally, any other property that might be necessary to uniquely

316 +

identify that object in a different command should get added properties. For example, with Issues,

317 +

we add both an `IssueNumber` property and an `IssueId` property to it, as the Issue commands

318 +

need to interact with the `IssueNumber` while the Event commands interact with the `IssueId`.

319 +

We prefer to _only_ add additional properties that are believed to be needed as input to other

320 +

commands (as opposed to creating alias properties for all of the object's properties).

321 + 322 +

* For every major file, you will find an `Add-GitHub*AdditionalProperties` filter method at the end.

323 +

If you're writing a new file, you'll need to create this yourself (and model it after an existing

324 +

one). The goal of this is that you can simply pipe the output of your `Invoke-GHRestMethod`

325 +

directly into this method to update the result with the additional properties, and then return

326 +

that modified version to the user. The benefit of this approach is that you can then apply that

327 +

filter on child objects within the primary object. For instance, a `GitHub.Issue` has multiple

328 +

`GitHub.User` objects, `GitHub.Label` objects, a `GitHub.Milestone` object and more. Within

329 +

`Add-GitHubIssueAdditionalProperties`, it just needs to know to call the appropriate

330 +

`Add-GitHub*AdditionalProperties` method on the qualifying child properties, without needing to

331 +

know anything more about them.

332 + 333 +

* That method will also "type" information to each object. This is forward-looking work to ease

334 +

support for providing formatting of various object types in the future. That type should be

335 +

defined at the top of the current file at the script level (see other files for an example),

336 +

and you should be sure to both specify it in the `.OUTPUTS` section of the Comment Based Help (CBH)

337 +

for the command, as well as with `[OutputType({$script:GitHubUserTypeName})]` (for example).

338 + 339 +

* Going along with the `.OUTPUTS` is the `.INPUTS` section. Please maintain this section as well.

340 +

If you add any new type that will gain a `RepositoryUrl` property, then you'll need to update

341 +

virtually _all_ of the `.INPUTS` entries across all of the files where the function has a `Uri`

342 +

parameter. Please keep these type names alphabetical.

343 + 344 +

* To enable debugging issues involving pipeline support, there is an additional configuration

345 +

property that you might use: `Set-GitHubConfiguration -DisablePipelineSupport`. That will

346 +

prevent the module from adding _any_ additional properties to the objects.

347 + 348 +

----------

349 + 289 350

### Testing

290 351

[![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)

352 +

[![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)

353 +

[![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)

354 + 291 355 292 356

#### Installing Pester

293 357

This module supports testing using the [Pester UT framework](https://github.com/pester/Pester).

@@ -350,6 +414,8 @@ There are many more nuances to code-coverage, see

350 414 351 415

#### Automated Tests

352 416

[![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)

417 +

[![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)

418 +

[![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 419 354 420

These test are configured to automatically execute upon any update to the `master` branch

355 421

of `microsoft/PowerShellForGitHub`.

@@ -362,9 +428,9 @@ as well...it is stored, encrypted, within Azure DevOps. It is not accessible fo

362 428

the CI pipeline. To run the tests locally with your own account, see

363 429

[configuring-your-environment](#configuring-your-environment).

364 430 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.

431 +

> Your change must successfully pass all tests before they will be merged. While we will run a CI

432 +

> build on your behalf for any submitted pull request, it's to your benefit to verify your changes

433 +

> locally first.

368 434 369 435

#### New Test Guidelines

370 436

Your tests should have NO dependencies on an account being set up in a specific way. They should


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4