Clean up modules direcotry in eng/common since they are no longer being used. (#1067)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2020-12-09 12:53:47 -08:00 committed by GitHub
parent 828bb4098a
commit fc7d82f6c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 527 deletions

View File

@ -1,124 +0,0 @@
$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+.*(?<version>\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s(?<releaseStatus>\(Unreleased\)|\(\d{4}-\d{2}-\d{2}\)))?)"
function Get-ChangeLogEntries {
param (
[Parameter(Mandatory = $true)]
[String]$ChangeLogLocation
)
$changeLogEntries = @{}
if (!(Test-Path $ChangeLogLocation)) {
Write-Error "ChangeLog[${ChangeLogLocation}] does not exist"
return $null
}
try {
$contents = Get-Content $ChangeLogLocation
# walk the document, finding where the version specifiers are and creating lists
$changeLogEntry = $null
foreach ($line in $contents) {
if ($line -match $RELEASE_TITLE_REGEX) {
$changeLogEntry = [pscustomobject]@{
ReleaseVersion = $matches["version"]
ReleaseStatus = $matches["releaseStatus"]
ReleaseTitle = $line
ReleaseContent = @() # Release content without the version title
}
$changeLogEntries[$changeLogEntry.ReleaseVersion] = $changeLogEntry
}
else {
if ($changeLogEntry) {
$changeLogEntry.ReleaseContent += $line
}
}
}
}
catch {
Write-Host "Error parsing $ChangeLogLocation."
Write-Host $_.Exception.Message
}
return $changeLogEntries
}
# Returns single changeLogEntry object containing the ChangeLog for a particular version
function Get-ChangeLogEntry {
param (
[Parameter(Mandatory = $true)]
[String]$ChangeLogLocation,
[Parameter(Mandatory = $true)]
[String]$VersionString
)
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
if ($changeLogEntries -and $changeLogEntries.ContainsKey($VersionString)) {
return $changeLogEntries[$VersionString]
}
return $null
}
#Returns the changelog for a particular version as string
function Get-ChangeLogEntryAsString {
param (
[Parameter(Mandatory = $true)]
[String]$ChangeLogLocation,
[Parameter(Mandatory = $true)]
[String]$VersionString
)
$changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString
return ChangeLogEntryAsString $changeLogEntry
}
function ChangeLogEntryAsString($changeLogEntry) {
if (!$changeLogEntry) {
return "[Missing change log entry]"
}
[string]$releaseTitle = $changeLogEntry.ReleaseTitle
[string]$releaseContent = $changeLogEntry.ReleaseContent -Join [Environment]::NewLine
return $releaseTitle, $releaseContent -Join [Environment]::NewLine
}
function Confirm-ChangeLogEntry {
param (
[Parameter(Mandatory = $true)]
[String]$ChangeLogLocation,
[Parameter(Mandatory = $true)]
[String]$VersionString,
[boolean]$ForRelease = $false
)
$changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString
if (!$changeLogEntry) {
Write-Error "ChangeLog[${ChangeLogLocation}] does not have an entry for version ${VersionString}."
return $false
}
Write-Host "Found the following change log entry for version '${VersionString}' in [${ChangeLogLocation}]."
Write-Host "-----"
Write-Host (ChangeLogEntryAsString $changeLogEntry)
Write-Host "-----"
if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus)) {
Write-Error "Entry does not have a correct release status. Please ensure the status is set to a date '(yyyy-MM-dd)' or '(Unreleased)' if not yet released."
return $false
}
if ($ForRelease -eq $True) {
if ($changeLogEntry.ReleaseStatus -eq "(Unreleased)") {
Write-Error "Entry has no release date set. Please ensure to set a release date with format 'yyyy-MM-dd'."
return $false
}
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
Write-Error "Entry has no content. Please ensure to provide some content of what changed in this version."
return $false
}
}
return $true
}
Export-ModuleMember -Function 'Get-ChangeLogEntries'
Export-ModuleMember -Function 'Get-ChangeLogEntry'
Export-ModuleMember -Function 'Get-ChangeLogEntryAsString'
Export-ModuleMember -Function 'Confirm-ChangeLogEntry'

View File

@ -1,280 +0,0 @@
# This Files has been retired
# Helper functions for retireving useful information from azure-sdk-for-* repo
# Example Use : Import-Module .\eng\common\scripts\modules
class PackageProps
{
[string]$pkgName
[string]$pkgVersion
[string]$pkgDirectoryPath
[string]$pkgServiceName
[string]$pkgReadMePath
[string]$pkgChangeLogPath
[string]$pkgGroup
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName)
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
}
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName,[string]$pkgGroup="")
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName, $pkgGroup)
}
hidden [void]Initialize(
[string]$pkgName,
[string]$pkgVersion,
[string]$pkgDirectoryPath,
[string]$pkgServiceName
)
{
$this.pkgName = $pkgName
$this.pkgVersion = $pkgVersion
$this.pkgDirectoryPath = $pkgDirectoryPath
$this.pkgServiceName = $pkgServiceName
if (Test-Path (Join-Path $pkgDirectoryPath "README.md"))
{
$this.pkgReadMePath = Join-Path $pkgDirectoryPath "README.md"
}
else
{
$this.pkgReadMePath = $null
}
if (Test-Path (Join-Path $pkgDirectoryPath "CHANGELOG.md"))
{
$this.pkgChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md"
}
else
{
$this.pkgChangeLogPath = $null
}
}
hidden [void]Initialize(
[string]$pkgName,
[string]$pkgVersion,
[string]$pkgDirectoryPath,
[string]$pkgServiceName,
[string]$pkgGroup
)
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
$this.pkgGroup = $pkgGroup
}
}
function Extract-PkgProps ($pkgPath, $serviceName, $pkgName, $lang)
{
if ($lang -eq "net")
{
return Extract-DotNetPkgProps -pkgPath $pkgPath -serviceName $serviceName -pkgName $pkgName
}
if ($lang -eq "java")
{
return Extract-JavaPkgProps -pkgPath $pkgPath -serviceName $serviceName -pkgName $pkgName
}
if ($lang -eq "js")
{
return Extract-JsPkgProps -pkgPath $pkgPath -serviceName $serviceName -pkgName $pkgName
}
if ($lang -eq "python")
{
return Extract-PythonPkgProps -pkgPath $pkgPath -serviceName $serviceName -pkgName $pkgName
}
}
function Extract-DotNetPkgProps ($pkgPath, $serviceName, $pkgName)
{
$projectPath = Join-Path $pkgPath "src" "$pkgName.csproj"
if (Test-Path $projectPath)
{
$projectData = New-Object -TypeName XML
$projectData.load($projectPath)
$pkgVersion = Select-XML -Xml $projectData -XPath '/Project/PropertyGroup/Version'
return [PackageProps]::new($pkgName, $pkgVersion, $pkgPath, $serviceName)
}
else
{
return $null
}
}
function Extract-JsPkgProps ($pkgPath, $serviceName, $pkgName)
{
$projectPath = Join-Path $pkgPath "package.json"
if (Test-Path $projectPath)
{
$projectJson = Get-Content $projectPath | ConvertFrom-Json
$jsStylePkgName = $pkgName.replace("azure-", "@azure/")
if ($projectJson.name -eq "$jsStylePkgName")
{
return [PackageProps]::new($projectJson.name, $projectJson.version, $pkgPath, $serviceName)
}
}
return $null
}
function Extract-PythonPkgProps ($pkgPath, $serviceName, $pkgName)
{
$pkgName = $pkgName.Replace('_', '-')
if (Test-Path (Join-Path $pkgPath "setup.py"))
{
$setupLocation = $pkgPath.Replace('\','/')
pushd $RepoRoot
$setupProps = (python -c "import sys; import os; sys.path.append(os.path.join('scripts', 'devops_tasks')); from common_tasks import parse_setup; obj=parse_setup('$setupLocation'); print('{0},{1}'.format(obj[0], obj[1]));") -split ","
popd
if (($setupProps -ne $null) -and ($setupProps[0] -eq $pkgName))
{
return [PackageProps]::new($setupProps[0], $setupProps[1], $pkgPath, $serviceName)
}
}
return $null
}
function Extract-JavaPkgProps ($pkgPath, $serviceName, $pkgName)
{
$projectPath = Join-Path $pkgPath "pom.xml"
if (Test-Path $projectPath)
{
$projectData = New-Object -TypeName XML
$projectData.load($projectPath)
$projectPkgName = $projectData.project.artifactId
$pkgVersion = $projectData.project.version
$pkgGroup = $projectData.project.groupId
if ($projectPkgName -eq $pkgName)
{
return [PackageProps]::new($pkgName, $pkgVersion.ToString(), $pkgPath, $serviceName, $pkgGroup)
}
}
return $null
}
# Takes package name and service Name
# Returns important properties of the package as related to the language repo
# Returns a PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
# Note: python is required for parsing python package properties.
function Get-PkgProperties
{
Param
(
[Parameter(Mandatory=$true)]
[string]$PackageName,
[Parameter(Mandatory=$true)]
[string]$ServiceName,
[Parameter(Mandatory=$true)]
[ValidateSet("net","java","js","python")]
[string]$Language,
[string]$RepoRoot="${PSScriptRoot}/../../../.."
)
$pkgDirectoryName = $null
$pkgDirectoryPath = $null
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceName
if (!(Test-Path $serviceDirectoryPath))
{
Write-Error "Service Directory $ServiceName does not exist"
exit 1
}
$directoriesPresent = Get-ChildItem $serviceDirectoryPath -Directory
foreach ($directory in $directoriesPresent)
{
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
$pkgProps = Extract-PkgProps -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName -lang $Language
if ($pkgProps -ne $null)
{
return $pkgProps
}
}
Write-Error "Failed to retrive Properties for $PackageName"
}
# Takes ServiceName, Language, and Repo Root Directory
# Returns important properties for each package in the specified service, or entire repo if the serviceName is not specified
# Returns an Table of service key to array values of PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
function Get-AllPkgProperties
{
Param
(
[Parameter(Mandatory=$true)]
[ValidateSet("net","java","js","python")]
[string]$Language,
[string]$RepoRoot="${PSScriptRoot}/../../../..",
[string]$ServiceName=$null
)
$pkgPropsResult = @()
if ([string]::IsNullOrEmpty($ServiceName))
{
$searchDir = Join-Path $RepoRoot "sdk"
foreach ($dir in (Get-ChildItem $searchDir -Directory))
{
$serviceDir = Join-Path $searchDir $dir.Name
if (Test-Path (Join-Path $serviceDir "ci.yml"))
{
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
if ($activePkgList -ne $null)
{
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -serviceName $dir.Name -language $Language -repoRoot $RepoRoot -pkgPropsResult $pkgPropsResult
}
}
}
}
else
{
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceName
if (Test-Path (Join-Path $serviceDir "ci.yml"))
{
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
if ($activePkgList -ne $null)
{
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -serviceName $ServiceName -language $Language -repoRoot $RepoRoot -pkgPropsResult $pkgPropsResult
}
}
}
return $pkgPropsResult
}
function Operate-OnPackages ($activePkgList, $serviceName, $language, $repoRoot, [Array]$pkgPropsResult)
{
foreach ($pkg in $activePkgList)
{
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceName $serviceName -Language $language -RepoRoot $repoRoot
$pkgPropsResult += $pkgProps
}
return $pkgPropsResult
}
function Get-PkgListFromYml ($ciYmlPath)
{
$ProgressPreference = "SilentlyContinue"
Register-PSRepository -Default -ErrorAction:SilentlyContinue
Install-Module -Name powershell-yaml -RequiredVersion 0.4.1 -Force -Scope CurrentUser
$ciYmlContent = Get-Content $ciYmlPath -Raw
$ciYmlObj = ConvertFrom-Yaml $ciYmlContent -Ordered
if ($ciYmlObj.Contains("stages"))
{
$artifactsInCI = $ciYmlObj["stages"][0]["parameters"]["Artifacts"]
}
elseif ($ciYmlObj.Contains("extends"))
{
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
}
if ($artifactsInCI -eq $null)
{
Write-Error "Failed to retrive package names in ci $ciYmlPath"
}
return $artifactsInCI
}
Export-ModuleMember -Function 'Get-PkgProperties'
Export-ModuleMember -Function 'Get-AllPkgProperties'

View File

@ -1,123 +0,0 @@
#
# Module manifest for module 'Common Modules'
#
# Generated by: azure-sdk
#
# Generated on: 5/19/2020
#
@{
# Script module or binary module file associated with this manifest.
# RootModule = ''
# Version number of this module.
ModuleVersion = '1.0'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '552cdcff-1f53-4f68-87a6-54490af6e94a'
# Author of this module
Author = 'azure-sdk'
# Company or vendor of this module
CompanyName = 'Unknown'
# Copyright statement for this module
Copyright = '(c) azure-sdk. All rights reserved.'
# Description of the functionality provided by this module
# Description = ''
# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
ScriptsToProcess = @("${PSScriptRoot}\..\SemVer.ps1")
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @("${PSScriptRoot}\Package-Properties.psm1", "${PSScriptRoot}\ChangeLog-Operations.psm1")
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
# FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}