From 84606b0ab99e8afdf196851d97d20ded76c7c99e Mon Sep 17 00:00:00 2001 From: dmilov Date: Mon, 19 Apr 2021 08:55:35 +0300 Subject: [PATCH] Create CONTRIBUTING.md (#15) Signed-off-by: Dimitar Milov --- CONTRIBUTING.md | 30 ++++++++++++++++++++++++++++++ README.md | 43 ------------------------------------------- build.ps1 | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..782019b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contributing to CloudEvents sdk-powershell + +We welcome and appreciate contributions from the community. Please read this document for different ways of getting involved with the sdk-powershell. + +## Contributing to Issues + +- Ensure that the issue you are about to file is not already open. If someone has already opened a similar issue, please leave a comment or add a GitHub reaction to the top comment to express your interest. +- If you can't find your issue already, [open a new issue](https://github.com/cloudevents/sdk-powershell/issues/new). + +## Contributing to Code +CloudEvents.SDK PowerShell consists of a .NET project that resolves the [CloudEvents sdk-csharp](https://github.com/cloudevents/sdk-csharp) dependency, PowerShell script module with the sdk advanced functions, and Pester tests. + +### Required Toolchain +- [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0) SDK +- [PowerShell 7.0](https://github.com/PowerShell/PowerShell#get-powershell) or higher +- [Pester 5.1.1](https://www.powershellgallery.com/packages/Pester/5.1.1) or higher + +### Building and testing +The CloudEvents.Sdk module source code is in the `src` directory. We have unit tests and localhost integration tests available in the `test` directory.
+
+The `build.ps1` script is the entry point to build the module and run the tests. It has two parameters
+   1. `OutputDir` - The destination directory for the `CloudEvents.Sdk` module
+   2. `TestsType` - Specifies which tests (`none` | `unit` | `integration` | `all`) to run on successful module build.

+Running the `build.ps1` without specifying parameters produce the module in a `CloudEvents.Sdk` directory under the repository root directory, and runs all tests. + +### Forks and Pull Requests + +Anyone can [fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the repository into their own user account, where they can make private changes. To contribute your changes back create a [pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests). A pull request should relate to an existing issue.
+
+Adding new features or fixing bugs might require adding or updating tests. Before creating a pull request make sure all tests pass locally. \ No newline at end of file diff --git a/README.md b/README.md index ef55706..d245cbb 100644 --- a/README.md +++ b/README.md @@ -143,47 +143,4 @@ is converted to ### Read CloudEvent Custom Format **Data** as a **byte[]** ```powershell $bytes = Read-CloudEventData -CloudEvent $cloudEvent -``` - -# Build the **CloudEvents.Sdk** Module - -The `build.ps1` script -- Creates the CloudEvents PowerShell Module in a `CloudEvents` directory. -- Runs functions unit tests -- Runs local integrations tests -- Creates a catalog file for the CloudEvents Module - -### Prerequisites -- [PowerShell 7.0](https://github.com/PowerShell/PowerShell/releases/tag/v7.0.4) -- [Pester 5.1.1](https://www.powershellgallery.com/packages/Pester/5.1.1) -- [dotnet SDK](https://dotnet.microsoft.com/download/dotnet/5.0) - -```powershell -> ./build.ps1 -[9:52:42 AM] INFO: Publish CloudEvents.Sdk Module to 'C:\git-repos\cloudevents\cloudevents-sdk-powershell\CloudEvents.Sdk' -Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET -Copyright (C) Microsoft Corporation. All rights reserved. - - Determining projects to restore... - All projects are up-to-date for restore. - CloudEventsPowerShell -> C:\git-repos\cloudevents\cloudevents-sdk-powershell\src\CloudEventsPowerShell\bin\Release\netstandard2.0\CloudEventsPowerShell.dll - CloudEventsPowerShell -> C:\git-repos\cloudevents\cloudevents-sdk-powershell\CloudEvents.Sdk\ -[9:52:44 AM] INFO: Run unit tests - -Starting discovery in 9 files. -Discovery finished in 294ms. -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Add-CloudEventData.Tests.ps1 1.01s (184ms|656ms) -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Add-CloudEventJsonData.Tests.ps1 329ms (39ms|279ms) [+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Add-CloudEventXmlData.Tests.ps1 336ms (58ms|267ms) [+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\ConvertFrom-HttpMessage.Tests.ps1 557ms (203ms|337ms) [+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\ConvertTo-HttpMessage.Tests.ps1 508ms (132ms|361ms) [+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\New-CloudEvent.Tests.ps1 275ms (22ms|243ms) -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Read-CloudEventData.Tests.ps1 257ms (10ms|236ms) -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Read-CloudEventJsonData.Tests.ps1 308ms (40ms|257ms) -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\unit\Read-CloudEventXmlData.Tests.ps1 310ms (53ms|246ms) -Tests completed in 3.94s -Tests Passed: 28, Failed: 0, Skipped: 0 NotRun: 0 -[9:52:49 AM] INFO: Run integration tests - -Starting discovery in 1 files. -Discovery finished in 176ms. -[+] C:\git-repos\cloudevents\cloudevents-sdk-powershell\test\integration\HttpIntegration.Tests.ps1 2.54s (1.77s|617ms) -Tests completed in 2.56s -Tests Passed: 5, Failed: 0, Skipped: 0 NotRun: 0 ``` \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 11fdacc..ed6e638 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,10 +3,32 @@ # SPDX-License-Identifier: Apache-2.0 # ************************************************************************** +<# + .SYNOPSIS + Builds and tests the CloudEvents.Sdk module + + + .DESCRIPTION + The script is the entry point to build and test the CloudEvents.Sdk module. + + .PARAMETER OutputDir + Target directory where the CloudEvents.Sdk will be created by the script. The default is the PS Script Root + + .PARAMETER TestsType + Specifies the type of the test to be run post build. Possible values are 'none','unit', 'integration', 'all'. + The default is 'all' + +#> + param( [Parameter()] [string] - $OutputDir + $OutputDir, + + [Parameter()] + [ValidateSet('none','unit', 'integration', 'all')] + [string] + $TestsType = 'all' ) $moduleName = 'CloudEvents.Sdk' @@ -44,7 +66,7 @@ function Test-BuildToolsAreAvailable { function Start-Tests { param( [Parameter()] - [ValidateSet('unit', 'integration', 'all')] + [ValidateSet('unit', 'integration')] [string] $TestsType ) @@ -86,7 +108,11 @@ dotnet publish -c Release -o $OutputDir $dotnetProjectPath Get-ChildItem "$dotnetProjectName*" -Path $OutputDir | Remove-Item -Confirm:$false # 4. Run Unit Tests -Start-Tests -TestsType 'unit' +if ($TestsType -eq 'unit' -or $TestsType -eq 'all') { + Start-Tests -TestsType 'unit' +} # 5. Run Integration Tests -Start-Tests -TestsType 'integration' +if ($TestsType -eq 'integration' -or $TestsType -eq 'all') { + Start-Tests -TestsType 'integration' +}