Skip to content

Commit

Permalink
Add validation for installation snippets (Azure#28193)
Browse files Browse the repository at this point in the history
* Add validation for installation snippets

* PR fb

* Fix readmes

* fix eventgrid

* fixes

* Add section

* More files

* More files

* fix
  • Loading branch information
JoshLove-msft authored Apr 14, 2022
1 parent 30cc1b9 commit 8b9ea1a
Show file tree
Hide file tree
Showing 73 changed files with 194 additions and 156 deletions.
4 changes: 2 additions & 2 deletions doc/dev/mgmt_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ authentication. This document illustrates the most common scenario.

Install the Azure Resources management core library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager -Version 1.0.0
```dotnetcli
dotnet add package Azure.ResourceManager
```

## Prerequisites
Expand Down
66 changes: 65 additions & 1 deletion eng/scripts/CodeChecks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ $ErrorActionPreference = 'Stop'
$Env:NODE_OPTIONS = "--max-old-space-size=8192"
Set-StrictMode -Version 1

. (Join-Path $PSScriptRoot\..\common\scripts common.ps1)

[string[]] $errors = @()

function LogError([string]$message) {
Expand Down Expand Up @@ -94,6 +96,68 @@ try {
& $PSScriptRoot\Export-API.ps1 -ServiceDirectory $ServiceDirectory -SDKType $SDKType -SpellCheckPublicApiSurface:$SpellCheckPublicApiSurface
}

Write-Host "Validating installation instructions"
Join-Path "$PSScriptRoot/../../sdk" $ServiceDirectory `
| Resolve-Path `
| % { Get-ChildItem $_ -Filter "README.md" -Recurse } `
| % {
$readmePath = $_
$readmeContent = Get-Content $readmePath

if ($readmeContent -Match "Install-Package")
{
LogError "README files should use dotnet CLI for installation instructions. '$readmePath'"
}

if ($readmeContent -Match "dotnet add .*--version")
{
LogError "Specific versions should not be specified in the installation instructions in '$readmePath'. For beta versions, include the --prerelease flag."
}

if ($readmeContent -Match "dotnet add")
{
$changelogPath = Join-Path $(Split-Path -Parent $readmePath) "CHANGELOG.md"
$hasGa = $false
$hasRelease = $false
if (Test-Path $changelogPath)
{
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $changelogPath
foreach ($key in $changeLogEntries.Keys)
{
$entry = $changeLogEntries[$key]
if ($entry.ReleaseStatus -ne "(Unreleased)")
{
$hasRelease = $true
if ($entry.ReleaseVersion -notmatch "beta" -and $entry.ReleaseVersion -notmatch "preview")
{
$hasGa = $true
break
}
}
}
}
if ($hasGa)
{
if (-Not ($readmeContent -Match "dotnet add (?!.*--prerelease)"))
{
LogError `
"No GA installation instructions found in '$readmePath' but there was a GA entry in the Changelog '$changelogPath'. `
Ensure that there are installation instructions that do not contain the --prerelease flag. You may also include `
instructions for installing a beta that does include the --prerelease flag."
}
}
elseif ($hasRelease)
{
if (-Not ($readmeContent -Match "dotnet add .*--prerelease$"))
{
LogError `
"No beta installation instructions found in '$readmePath' but there was a beta entry in the Changelog '$changelogPath'. `
Ensure that there are installation instructions that contain the --prerelease flag."
}
}
}
}

if (-not $ProjectDirectory)
{
Write-Host "git diff"
Expand All @@ -109,7 +173,7 @@ try {
run 'eng\scripts\Export-API.ps1' if you changed public APIs (https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md#public-api-additions). `
run 'dotnet build /t:GenerateCode' to update the generated code.`
`
To reproduce this error localy run 'eng\scripts\CodeChecks.ps1 -ServiceDirectory $ServiceDirectory'."
To reproduce this error locally, run 'eng\scripts\CodeChecks.ps1 -ServiceDirectory $ServiceDirectory'."
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions eng/templates/Azure.ResourceManager.Template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure ProviderShortName management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Template -Version 1.0.0-beta.1
```dotnetcli
dotnet add package Azure.ResourceManager.Template --prerelease
```

### Prerequisites
Expand Down
6 changes: 3 additions & 3 deletions sdk/anomalydetector/Azure.AI.AnomalyDetector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Microsoft Azure Cognitive Services Anomaly Detector API enables you to monitor a
Install the Azure Anomaly Detector client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.AI.AnomalyDetector --version 3.0.0-preview.3
dotnet add package Azure.AI.AnomalyDetector --prerelease
```

### Prerequisites
Expand Down Expand Up @@ -48,8 +48,8 @@ var client = new AnomalyDetectorClient(new Uri(endpoint), credential);

To use the [DefaultAzureCredential][DefaultAzureCredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `Azure.Identity` package:

```PowerShell
Install-Package Azure.Identity
```dotnetcli
dotnet add package Azure.Identity
```

You will also need to [register a new AAD application][register_aad_app] and [grant access][aad_grant_access] to Anomaly Detector by assigning the `"Cognitive Services User"` role to your service principal.
Expand Down
8 changes: 4 additions & 4 deletions sdk/appconfiguration/Azure.Data.AppConfiguration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Use the client library for App Configuration to:

Install the Azure App Configuration client library for .NET with [NuGet][nuget]:

```PowerShell
Install-Package Azure.Data.AppConfiguration
```dotnetcli
dotnet add package Azure.Data.AppConfiguration
```

### Prerequisites
Expand Down Expand Up @@ -60,8 +60,8 @@ var client = new ConfigurationClient(connectionString);
Client subscription key authentication is used in most of the examples in this getting started guide, but you can also authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][azure_identity_dac] provider shown below,
or other credential providers provided with the Azure SDK, please install the Azure.Identity package:

```PowerShell
Install-Package Azure.Identity
```dotnetcli
dotnet add package Azure.Identity
```

You will also need to [register a new AAD application][aad_register_app] and [grant access][aad_grant_access] to Configuration Store by assigning the `"App Configuration Data Reader"` or `"App Configuration Data Owner"` role to your service principal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur
Install the Azure App Configuration management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.AppConfiguration -Version 1.0.0-beta.3
dotnet add package Azure.ResourceManager.AppConfiguration --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/azurestackhci/Azure.ResourceManager.Hci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure Stack HCI management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Hci -Version 1.0.0-beta.2
```dotnetcli
dotnet add package Azure.ResourceManager.Hci --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/cdn/Azure.ResourceManager.Cdn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure Cdn management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Cdn -Version 1.0.0-beta.4
```dotnetcli
dotnet add package Azure.ResourceManager.Cdn --prerelease
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Question Answering service is a cloud-based API service that lets you create
Install the Azure Cognitive Language Services Question Answering client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.AI.Language.QuestionAnswering --prerelease
dotnet add package Azure.AI.Language.QuestionAnswering
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package contains a C# SDK for Azure Communication Services for Calling.
Install the Azure Communication CallingServer client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.CallingServer --version 1.0.0-beta.3
dotnet add package Azure.Communication.CallingServer --prerelease
```

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.Common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package contains common code for Azure Communication Service libraries.
Install the Azure Communication Common client library for .NET with [NuGet][nuget].

```dotnetcli
dotnet add package Azure.Communication.Common --version 1.0.0
dotnet add package Azure.Communication.Common
```

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.Identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Azure Communication Identity is managing tokens for Azure Communication Services
Install the Azure Communication Identity client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.Identity --version 1.0.0
dotnet add package Azure.Communication.Identity
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Azure Communication Network Traversal enables high bandwidth, low latency connec
Install the Azure Communication Network Traversal client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.NetworkTraversal --version 1.1.0-beta.1
dotnet add package Azure.Communication.NetworkTraversal
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Azure Communication Phone Numbers is managing phone numbers for Azure Communicat
Install the Azure Communication Phone Numbers client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.PhoneNumbers --version 1.0.0
dotnet add package Azure.Communication.PhoneNumbers
```

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.ShortCodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The phone numbers library provides capabilities for short codes administration.
Install the Azure Communication Server Calling client library for .NET with [NuGet][nuget]:

```PowerShell
dotnet add package Azure.Communication.ShortCodes --version 1.0.0-alpha.1
dotnet add package Azure.Communication.ShortCodes --prerelease
```

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.Sms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package contains a C# SDK for Azure Communication Services for SMS and Tele
Install the Azure Communication SMS client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.Sms --version 1.0.0
dotnet add package Azure.Communication.Sms
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Use the management library for Azure Communication Services to:

Install the Azure Communication management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Communication --version 1.1.0-beta.2
```dotnetcli
dotnet add package Azure.ResourceManager.Communication
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/compute/Azure.ResourceManager.Compute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure Compute management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.Compute -Version 1.0.0-beta.7
```dotnetcli
dotnet add package Azure.ResourceManager.Compute --prerelease
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure ConnectedVMwarevSphere management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.ConnectedVMwarevSphere -Version 1.0.0-beta.3
```dotnetcli
dotnet add package Azure.ResourceManager.ConnectedVMwarevSphere --prerelease
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To develop .NET application code that can connect to an Azure Container Registry
Install the Azure Container Registry client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Containers.ContainerRegistry --prerelease
dotnet add package Azure.Containers.ContainerRegistry
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmosdb/Azure.ResourceManager.CosmosDB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure CosmosDB management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.CosmosDB -Version 1.0.0-beta.4
```dotnetcli
dotnet add package Azure.ResourceManager.CosmosDB --prerelease
```

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure DesktopVirtualization management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.DesktopVirtualization -Version 1.0.0-beta.1
```dotnetcli
dotnet add package Azure.ResourceManager.DesktopVirtualization --prerelease
```

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion sdk/deviceupdate/Azure.IoT.DeviceUpdate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For the best development experience, developers should use the official Microsof
Install the Device Update for IoT Hub client library for .NET with [NuGet](https://www.nuget.org/ ):

```dotnetcli
dotnet add package Azure.IoT.DeviceUpdate
dotnet add package Azure.IoT.DeviceUpdate --prerelease
```

### Authenticate the Client
Expand Down
4 changes: 2 additions & 2 deletions sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure DeviceUpdate management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.DeviceUpdate -Version 1.0.0-beta.3
```dotnetcli
dotnet add package Azure.ResourceManager.DeviceUpdate --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ For the best development experience, developers should use the official Microsof

Install the Azure Digital Twins client library for .NET with [NuGet][nuget]:

```PowerShell
Install-Package Azure.DigitalTwins.Core
```dotnetcli
dotnet add package Azure.DigitalTwins.Core
```

View the package details at [nuget.org][adt_nuget].
Expand Down
4 changes: 2 additions & 2 deletions sdk/dns/Azure.ResourceManager.Dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure dns management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.dns -Version 1.0.0-preview.1
```dotnetcli
dotnet add package Azure.ResourceManager.dns --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/dnsresolver/Azure.ResourceManager.DnsResolver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure DnsResolver management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.DnsResolver -Version 1.0.0-beta.2
```dotnetcli
dotnet add package Azure.ResourceManager.DnsResolver --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/edgeorder/Azure.ResourceManager.EdgeOrder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure EdgeOrder management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.EdgeOrder -Version 1.0.0-beta.2
```dotnetcli
dotnet add package Azure.ResourceManager.EdgeOrder --prerelease
```

### Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/Azure.ResourceManager.EventHubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur

Install the Azure EventHubs management library for .NET with [NuGet](https://www.nuget.org/):

```PowerShell
Install-Package Azure.ResourceManager.EventHubs -Version 1.0.0-beta.3
```dotnetcli
dotnet add package Azure.ResourceManager.EventHubs --prerelease
```

### Prerequisites
Expand Down
Loading

0 comments on commit 8b9ea1a

Please sign in to comment.