Skip to content

Commit

Permalink
Merge pull request #846 from AArnott/libtemplateUpdate
Browse files Browse the repository at this point in the history
* Detect more test assemblies

* Hide the codecov publish task if it won't run

Instead of showing it as a skipped task, just hide it if we won't run it because no codecov_token is provided.

* Add warning about squashing a Lib.Template update

* Bump Microsoft.NET.Test.Sdk from 17.2.0 to 17.3.1 (#175)

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.2.0 to 17.3.1.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](microsoft/vstest@v17.2.0...v17.3.1)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump Nerdbank.GitVersioning from 3.5.108 to 3.5.109 (#174)

Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.5.108 to 3.5.109.
- [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases)
- [Commits](dotnet/Nerdbank.GitVersioning@v3.5.108...v3.5.109)

---
updated-dependencies:
- dependency-name: Nerdbank.GitVersioning
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump xunit from 2.4.1 to 2.4.2 (#173)

Bumps [xunit](https://github.com/xunit/xunit) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/xunit/xunit/releases)
- [Commits](xunit/xunit@2.4.1...2.4.2)

---
updated-dependencies:
- dependency-name: xunit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Remove en-US from URL to docs

* Update doc links

* Force non-shallow clones

Fixes issue 176

* Switch to using dotnet-coverage

Now that the merge bug has been fixed, this should provide a better report than `dotnet-reportgenerator-globaltool` because methods with `#if` blocks will now still be merged in the report instead of being listed multiple times.

* Update NuGetAuthenticate task version

* Update NuGetAuthenticate task version

* Document that we return the installed package path

* Install .NET SDK before authenticating nuget

This may be important because how can NuGetAuthenticate decide to authenticate the `dotnet nuget` commands if `dotnet` isn't already there.

* Split out the symbol archive and package push stages into a shareable yml file

* Add validation pipeline (targeted as a PR policy)

* Update docs in validation PRs

* Add reasonable default person as a reviewer on insertion PRs

* Add source code archival pipeline

* Touch up on icons in pipeline

* Make `notes` parameter optional

This works around lack of support by using a blank space as a default value. See https://developercommunity.visualstudio.com/idea/975396/optional-runtime-parameter.html

* Update macOS agent to OS12

* Add more analyzers

* Switch to one nuget.config feed

* Add commented nuget source for non-OSS repos

* Use VS-Platform as the internal consumption feed

* Fix key to match the packageSource no matter which is kept

* Authenticate to azure-public/msft_consumption to allow ingestion of packages in official builds

* Revert "Authenticate to azure-public/msft_consumption to allow ingestion of packages in official builds"

This led to the error in AzP:

> ##[error]Error: The service connection for 'https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json' is not valid. ApiKey service connections are not supported in this task. Instead, use -ApiKey (NuGet) or --api-key (dotnet) when invoking the tool itself. See the task documentation for more details.

This reverts commit 1066a18.

* Authenticate to azure-public/msft_consumption to allow ingestion of packages in official builds

This reverts commit f056977.

* Fix new doc warnings

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
AArnott and dependabot[bot] authored Sep 27, 2022
2 parents bd27af1 + cea5791 commit 4f2e1fa
Show file tree
Hide file tree
Showing 50 changed files with 709 additions and 174 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ dotnet_diagnostic.SA1130.severity = silent
# IDE1006: Naming Styles - StyleCop handles these for us
dotnet_diagnostic.IDE1006.severity = none

dotnet_diagnostic.DOC100.severity = silent
dotnet_diagnostic.DOC104.severity = warning
dotnet_diagnostic.DOC105.severity = warning
dotnet_diagnostic.DOC106.severity = warning
dotnet_diagnostic.DOC107.severity = warning
dotnet_diagnostic.DOC108.severity = warning
dotnet_diagnostic.DOC200.severity = warning
dotnet_diagnostic.DOC202.severity = warning

dotnet_diagnostic.SA1600.severity = silent
dotnet_diagnostic.SA1609.severity = none
dotnet_diagnostic.SA1611.severity = none
Expand Down
36 changes: 28 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# StreamJsonRpc
# Contributing

This project has adopted the [Microsoft Open Source Code of
Conduct](https://opensource.microsoft.com/codeofconduct/).
Expand All @@ -10,16 +10,36 @@ with any additional questions or comments.
We welcome 3rd party pull requests.
For significant changes we strongly recommend opening an issue to start a design discussion first.

## Dev workflow
## Best practices

### Dependencies
* Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts.
Some scripts set environment variables to help you, but they are only retained if you use PowerShell as your shell.

Get the .NET Core SDK and .NET Core runtimes that are required to build and test this repo by running `.\init.ps1 -InstallLocality Machine` from the root of the repo in a PowerShell window.
## Prerequisites

### Building
All dependencies can be installed by running the `init.ps1` script at the root of the repository
using Windows PowerShell or [PowerShell Core][pwsh] (on any OS).
Some dependencies installed by `init.ps1` may only be discoverable from the same command line environment the init script was run from due to environment variables, so be sure to launch Visual Studio or build the repo from that same environment.
Alternatively, run `init.ps1 -InstallLocality Machine` (which may require elevation) in order to install dependencies at machine-wide locations so Visual Studio and builds work everywhere.

Build using `dotnet build src` or `msbuild /restore src`.
The only prerequisite for building, testing, and deploying from this repository
is the [.NET SDK](https://get.dot.net/).
You should install the version specified in `global.json` or a later version within
the same major.minor.Bxx "hundreds" band.
For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.310
while the 2.2.400 version would not be considered compatible by .NET SDK.
See [.NET Core Versioning](https://docs.microsoft.com/dotnet/core/versions/) for more information.

### Running tests
## Package restore

Run tests using `dotnet test src` or in Visual Studio with Test Explorer.
The easiest way to restore packages may be to run `init.ps1` which automatically authenticates
to the feeds that packages for this repo come from, if any.
`dotnet restore` or `nuget restore` also work but may require extra steps to authenticate to any applicable feeds.

## Building

This repository can be built on Windows, Linux, and OSX.

Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.).

[pwsh]: https://docs.microsoft.com/powershell/scripting/install/installing-powershell?view=powershell-6
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CSharpIsNullAnalyzer" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.VisualStudio" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
<PackageReference Include="Nullable" PrivateAssets="all" />
<!-- Use the Unstable package ID so that update tools will help us keep it current even though it seems to be ever-unstable lately. -->
<PackageReference Include="StyleCop.Analyzers.Unstable" PrivateAssets="all" />
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" PrivateAssets="all" />
<PackageReference Include="CSharpIsNullAnalyzer" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="xunit.combinatorial" Version="1.4.1" />
<PackageVersion Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<PackageVersion Include="xunit.runner.console" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xunit.skippablefact" Version="1.4.13" />
Expand Down
41 changes: 41 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->

## Security

Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).

If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).

If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/msrc/pgp-key-msrc).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.

## Preferred Languages

We prefer all communications to be in English.

## Policy

Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/msrc/cvd).

<!-- END MICROSOFT SECURITY.MD BLOCK -->
220 changes: 220 additions & 0 deletions azure-pipelines/Archive-SourceCode.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#Requires -PSEdition Core -Version 7
<#
.SYNOPSIS
Submits a source archival request for this repo.
.PARAMETER Requester
The alias for the user requesting this backup.
.PARAMETER ManagerAlias
The alias of the manager that owns the repo.
.PARAMETER TeamAlias
The alias of the team that owns the repo.
.PARAMETER BusinessGroupName
A human-readable title for your team or business group.
.PARAMETER ProductionType
.PARAMETER ReleaseType
The type of release being backed up.
.PARAMETER ReleaseDate
The date of the release of your software. Defaults to today.
.PARAMETER OwnerAlias
The alias of the owner.
.PARAMETER OS
.PARAMETER ProductLanguage
One or more languages.
.PARAMETER Notes
Any notes to record with the backup.
.PARAMETER FileCollection
One or more collections to archive.
.PARAMETER ProductName
The name of the product. This will default to the repository name.
.PARAMETER RepoUrl
The URL to the repository. This will default to the repository containing this script.
.PARAMETER BackupType
The kind of backup to be performed.
.PARAMETER ServerPath
The UNC path to the server to be backed up (if applicable).
.PARAMETER SourceCodeArchivalUri
The URI to POST the source code archival request to.
This value will typically come automatically by a variable group associated with your pipeline.
You can also look it up at https://dpsrequestforms.azurewebsites.net/#/help -> SCA Request Help -> SCA API Help -> Description
#>
[CmdletBinding(SupportsShouldProcess = $true, PositionalBinding = $false)]
param (
[Parameter()]
[string]$Requester,
[Parameter(Mandatory = $true)]
[string]$ManagerAlias,
[Parameter(Mandatory = $true)]
[string]$TeamAlias,
[Parameter(Mandatory = $true)]
[string]$BusinessGroupName,
[Parameter()]
[string]$ProductionType = 'Visual Studio',
[Parameter()]
[string]$ReleaseType = 'RTW',
[Parameter()]
[DateTime]$ReleaseDate = [DateTime]::Today,
[Parameter()]
[string]$OwnerAlias,
[Parameter()]
[ValidateSet('64-Bit Win', '32-Bit Win', 'Linux', 'Mac', '64-Bit ARM', '32-Bit ARM')]
[string[]]$OS = @('64-Bit Win'),
[Parameter(Mandatory = $true)]
[ValidateSet('English', 'Chinese Simplified', 'Chinese Traditional', 'Czech', 'French', 'German', 'Italian', 'Japanese', 'Korean', 'Polish', 'Portuguese', 'Russian', 'Spanish', 'Turkish')]
[string[]]$ProductLanguage,
[Parameter()]
[string]$Notes = '',
[Parameter()]
[ValidateSet('Binaries', 'Localization', 'Source Code')]
[string[]]$FileCollection = @('Source Code'),
[Parameter()]
[string]$ProductName,
[Parameter()]
[Uri]$RepoUrl,
[Parameter()]
[ValidateSet('Server Path', 'Code Repo(Git URL/AzureDevOps)', 'Git', 'Azure Storage Account')]
[string]$BackupType = 'Code Repo(Git URL/AzureDevOps)',
[Parameter()]
[string]$ServerPath = '',
[Parameter()]
[Uri]$SourceCodeArchivalUri = $env:SOURCECODEARCHIVALURI
)

function Invoke-Git() {
# Make sure we invoke git from within the repo.
Push-Location $PSScriptRoot
try {
return (git $args)
}
finally {
Pop-Location
}
}

if (!$ProductName) {
if ($env:BUILD_REPOSITORY_NAME) {
Write-Verbose 'Using $env:BUILD_REPOSITORY_NAME for ProductName.' # single quotes are intentional so user sees the name of env var.
$ProductName = $env:BUILD_REPOSITORY_NAME
}
else {
$originUrl = [Uri](Invoke-Git remote get-url origin)
if ($originUrl) {
$lastPathSegment = $originUrl.Segments[$originUrl.Segments.Length - 1]
if ($lastPathSegment.EndsWith('.git')) {
$lastPathSegment = $lastPathSegment.Substring(0, $lastPathSegment.Length - '.git'.Length)
}
Write-Verbose 'Using origin remote URL to derive ProductName.'
$ProductName = $lastPathSegment
}
}

if (!$ProductName) {
Write-Error "Unable to determine default value for -ProductName."
}
}

if (!$OwnerAlias) {
if ($env:BUILD_REQUESTEDFOREMAIL) {
Write-Verbose 'Using $env:BUILD_REQUESTEDFOREMAIL and slicing to just the alias for OwnerAlias.'
$OwnerAlias = ($env:BUILD_REQUESTEDFOREMAIL -split '@')[0]
}
else {
Write-Verbose 'Using $env:USERNAME for OwnerAlias.'
$OwnerAlias = $env:USERNAME
}
if (!$OwnerAlias) {
Write-Error "Unable to determine default value for -OwnerAlias."
}
}

if (!$Requester) {
if ($env:BUILD_REQUESTEDFOREMAIL) {
Write-Verbose 'Using $env:BUILD_REQUESTEDFOREMAIL and slicing to just the alias for Requester.'
$Requester = ($env:BUILD_REQUESTEDFOREMAIL -split '@')[0]
}
else {
Write-Verbose 'Using $env:USERNAME for Requester.'
$Requester = $env:USERNAME
}
if (!$Requester) {
Write-Error "Unable to determine default value for -Requester."
}
}

if (!$RepoUrl) {
$RepoUrl = $env:BUILD_REPOSITORY_URI
if (!$RepoUrl) {
$originUrl = [Uri](Invoke-Git remote get-url origin)
if ($originUrl) {
Write-Verbose 'Using git origin remote url for GitURL.'
$RepoUrl = $originUrl
}

if (!$RepoUrl) {
Write-Error "Unable to determine default value for -RepoUrl."
}
}
}

Push-Location $PSScriptRoot
$versionsObj = & (& "$PSScriptRoot/Get-nbgv.ps1") get-version -f json | ConvertFrom-Json
Pop-Location

$ReleaseDateString = $ReleaseDate.ToShortDateString()
$Version = $versionsObj.Version

$BackupSize = Get-ChildItem $PSScriptRoot\..\.git -Recurse -File | Measure-Object -Property Length -Sum
$DataSizeMB = [int]($BackupSize.Sum / 1mb)
$FileCount = $BackupSize.Count

$Request = @{
"Requester" = $Requester
"Manager" = $ManagerAlias
"TeamAlias" = $TeamAlias
"AdditionalContacts" = $AdditionalContacts
"BusinessGroupName" = $BusinessGroupName
"ProductName" = $ProductName
"Version" = $Version
"ProductionType" = $ProductionType
"ReleaseType" = $ReleaseType
"ReleaseDateString" = $ReleaseDateString
"OS" = [string]::Join(',', $OS)
"ProductLanguage" = [string]::Join(',', $ProductLanguage)
"FileCollection" = [string]::Join(',', $FileCollection)
"OwnerAlias" = $OwnerAlias
"Notes" = $Notes.Trim()
"CustomerProvidedDataSizeMB" = $DataSizeMB
"CustomerProvidedFileCount" = $FileCount
"BackupType" = $BackupType
"ServerPath" = $ServerPath
"AzureStorageAccount" = $AzureStorageAccount
"AzureStorageContainer" = $AzureStorageContainer
"GitURL" = $RepoUrl
}

$RequestJson = ConvertTo-Json $Request
Write-Host "SCA request:`n$RequestJson"

if ($PSCmdlet.ShouldProcess('source archival request', 'post')) {
if (!$SourceCodeArchivalUri) {
Write-Error "Unable to post request without -SourceCodeArchivalUri parameter."
exit 1
}

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$Response = Invoke-WebRequest -Uri $SourceCodeArchivalUri -Method POST -Body $RequestJson -ContentType "application/json" -UseBasicParsing -SkipHttpErrorCheck
Write-Host "Status Code : " -NoNewline
$responseContent = ConvertFrom-Json ($Response.Content)
if ($Response.StatusCode -eq 200) {
Write-Host $Response.StatusCode -ForegroundColor Green
Write-Host "Ticket ID : " -NoNewline
Write-Host $responseContent
}
else {
$responseContent = ConvertFrom-Json $Response.Content
Write-Host $Response.StatusCode -ForegroundColor Red
Write-Host "Message : $($responseContent.message)"
}
} elseif ($SourceCodeArchivalUri) {
Write-Host "Would have posted to $SourceCodeArchivalUri"
}
26 changes: 26 additions & 0 deletions azure-pipelines/Get-InsertionPRId.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<#
.SYNOPSIS
Look up the pull request URL of the insertion PR.
#>
$stagingFolder = $env:BUILD_STAGINGDIRECTORY
if (!$stagingFolder) {
$stagingFolder = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
if (!$stagingFolder) {
Write-Error "This script must be run in an Azure Pipeline."
exit 1
}
}
$markdownFolder = Join-Path $stagingFolder (Join-Path 'MicroBuild' 'Output')
$markdownFile = Join-Path $markdownFolder 'PullRequestUrl.md'
if (!(Test-Path $markdownFile)) {
Write-Error "This script should be run after the MicroBuildInsertVsPayload task."
exit 2
}

$insertionPRUrl = Get-Content $markdownFile
if (!($insertionPRUrl -match 'https:.+?/pullrequest/(\d+)')) {
Write-Error "Failed to parse pull request URL: $insertionPRUrl"
exit 3
}

$Matches[1]
2 changes: 1 addition & 1 deletion azure-pipelines/Get-SymbolFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files"
$PDBs = Get-ChildItem -rec "$Path/*.pdb"

# Filter PDBs to product OR test related.
$testregex = "unittest|tests"
$testregex = "unittest|tests|\.test\."

Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols"
$PDBsByHash = @{}
Expand Down
Loading

0 comments on commit 4f2e1fa

Please sign in to comment.