Skip to content

Commit

Permalink
Feature/release verify (#7386)
Browse files Browse the repository at this point in the history
* Build system updates to prep for automatic version bump and pre-release verifications (#7281)
  • Loading branch information
JimSuplizio authored Jan 15, 2020
1 parent f819bb4 commit 7232b92
Show file tree
Hide file tree
Showing 27 changed files with 262 additions and 77 deletions.
13 changes: 6 additions & 7 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
SDKType: not-specified # Set a default that breaks in obvious ways.
ServiceDirectory: not-specified # Set a default that breaks in obvious ways.
PreTestSteps: []
TestOptions: '$(DefaultOptions)'
Expand Down Expand Up @@ -72,15 +73,13 @@ jobs:
- ${{ each artifact in parameters.Artifacts }}:
- script: |
python3 --version
python3 eng/versioning/set_versions.py --update-type all --build-type client --build-qualifier dev.$(Build.BuildNumber) --artifact-id ${{artifact.name}}
python3 eng/versioning/set_versions.py --update-type all --build-type data --build-qualifier dev.$(Build.BuildNumber) --artifact-id ${{artifact.name}}
python3 eng/versioning/set_versions.py --build-type ${{parameters.SDKType}} --build-qualifier dev.$(Build.BuildNumber) --artifact-id ${{artifact.name}} --group-id ${{artifact.groupId}}

This comment has been minimized.

Copy link
@mitchdenny

mitchdenny Jan 16, 2020

Contributor

@JimSuplizio I think this might have inadvertantly introduced a problem that impacts the dev package releases. The core build not only gets its dev package versions updated, but it also needs to have the dev package used as a dependency on all the other libraries in the repo because they are build by the core build.

Notice in my previous implientation I set --update-type all which we lost with this latest change.

Adding @conniey since she raised and issue with me today which made me start digging around in this.

condition: eq(variables['SetDevVersion'],'true')
displayName: Append dev package version suffix for ${{artifact.name}}
- script: |
python3 --version
python3 eng/versioning/update_versions.py --update-type all --build-type client
python3 eng/versioning/update_versions.py --update-type all --build-type data
python3 eng/versioning/update_versions.py --update-type library --build-type ${{parameters.SDKType}}
condition: eq(variables['SetDevVersion'],'true')
displayName: Apply version settings to repository
Expand Down Expand Up @@ -254,7 +253,7 @@ jobs:

- task: Maven@3
displayName: 'Start Jetty'
condition: ne(variables['SdkType'], 'client')
condition: ne('${{ parameters.SDKType }}', 'client')
inputs:
mavenPomFile: pom.client.xml
options: '$(DefaultOptions)'
Expand All @@ -271,7 +270,7 @@ jobs:
displayName: 'Use Python 3.6'
inputs:
versionSpec: '3.6'
condition: and(ne(variables['SdkType'], 'data'), eq(variables['TestFromSource'],'true'))
condition: and(eq('${{ parameters.SDKType }}', 'client'), eq(variables['TestFromSource'],'true'))

- pwsh: |
python --version
Expand All @@ -288,7 +287,7 @@ jobs:
exit 1
}
displayName: 'Set versions for source build'
condition: and(ne(variables['SdkType'], 'data'), eq(variables['TestFromSource'],'true'))
condition: and(eq('${{ parameters.SDKType }}', 'client'), eq(variables['TestFromSource'],'true'))
- script: |
python --version
Expand Down
5 changes: 4 additions & 1 deletion eng/pipelines/templates/stages/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ stages:
- template: ../jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: ${{parameters.ServiceDirectory}}
SDKType: ${{parameters.SDKType}}
Artifacts: ${{parameters.Artifacts}}

# The Prerelease and Release stages are conditioned on whether we are building a pull request and the branch.
- ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}:
- template: pipelines/stages/archetype-java-release.yml@azure-sdk-build-tools
parameters:
DependsOn: Build
ServiceDirectory: ${{parameters.ServiceDirectory}}
SDKType: ${{parameters.SDKType}}
Artifacts: ${{parameters.Artifacts}}
ArtifactName: packages
ArtifactName: packages
3 changes: 3 additions & 0 deletions eng/pipelines/templates/stages/cosmos-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ stages:
- template: ../jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: ${{parameters.ServiceDirectory}}
SDKType: ${{parameters.SDKType}}
Artifacts: ${{parameters.Artifacts}}
TestMatrix:
Windows - java8:
Expand Down Expand Up @@ -114,6 +115,8 @@ stages:
- template: pipelines/stages/archetype-java-release.yml@azure-sdk-build-tools
parameters:
DependsOn: Build
ServiceDirectory: ${{parameters.ServiceDirectory}}
SDKType: ${{parameters.SDKType}}
Artifacts: ${{parameters.Artifacts}}
ArtifactName: packages

Expand Down
80 changes: 80 additions & 0 deletions eng/versioning/scan_for_unreleased_dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
param(
[Parameter(Mandatory=$true, Position=0)]
[System.String] $inputGroupId,
[Parameter(Mandatory=$true, Position=1)]
[System.String] $inputArtifactId,
[Parameter(Mandatory=$true, Position=2)]
[System.String] $serviceDirectory
)

# Given an input groupId, artifactId and root service directory, scan the service directory for the
# POM file that matches the group/artifact. If the POM file is found, scan for any unreleased_ dependency
# tags otherwise report an error. If there are unreleased dependency tags then report them and return an
# error, otherwise report success and allow the release to continue.

$script:FoundPomFile = $false
$script:FoundError = $false
function Write-Error-With-Color([string]$msg)
{
Write-Host "$($msg)" -ForegroundColor Red
}

Write-Host "inputGroupId=$($inputGroupId)"
Write-Host "inputArtifactId=$($inputArtifactId)"
Write-Host "serviceDirectory=$($serviceDirectory)"

# Scan each pom file under the service directory until we find the pom file for the input groupId/artifactId. If
# found then scan that pomfile for any unreleased dependency tags.
Get-ChildItem -Path $serviceDirectory -Filter pom*.xml -Recurse -File | ForEach-Object {
$pomFile = $_.FullName
$xmlPomFile = New-Object xml
$xmlPomFile.Load($pomFile)
if (($xmlPomFile.project.groupId -eq $inputGroupId) -and ($xmlPomFile.project.artifactId -eq $inputArtifactId)) {
$script:FoundPomFile = $true
Write-Host "Found pom file with matching groupId($($inputGroupId))/artifactId($($inputArtifactId)), pomFile=$($pomFile)"

# Verify there are no unreleased dependencies
foreach($dependencyNode in $xmlPomFile.GetElementsByTagName("dependency"))
{
$artifactId = $dependencyNode.artifactId
$groupId = $dependencyNode.groupId
$versionNode = $dependencyNode.GetElementsByTagName("version")[0]
if (!$versionNode)
{
$script:FoundError = $true
Write-Error-With-Color "Error: dependency is missing version element for groupId=$($groupId), artifactId=$($artifactId) should be <version></version> <!-- {x-version-update;$($groupId):$($artifactId);current|dependency|external_dependency<select one>} -->"
continue
}
# if there is no version update tag for the dependency then fail
if ($versionNode.NextSibling -and $versionNode.NextSibling.NodeType -eq "Comment")
{
$versionUpdateTag = $versionNode.NextSibling.Value.Trim()
if ($versionUpdateTag -match "{x-version-update;unreleased_$($groupId)")
{
$script:FoundError = $true
Write-Error-With-Color "Error: Cannot release libraries with unreleased dependencies. dependency=$($versionUpdateTag)"
continue
}
}
else
{
$script:FoundError = $true
Write-Error-With-Color "Error: Missing dependency version update tag for groupId=$($groupId), artifactId=$($artifactId). The tag should be <!-- {x-version-update;$($groupId):$($artifactId);current|dependency|external_dependency<select one>} -->"
continue
}
}
} else {
return
}
}

if (-Not $script:FoundPomFile) {
Write-Error-With-Color "Did not find pom file with matching groupId=$($groupId) and artifactId=$($artifactId) under serviceDirectory=$($serviceDirectory)"
exit(1)
}
if ($script:FoundError) {
Write-Error-With-Color "Libaries with unreleased dependencies cannot be released."
exit(1)
}

Write-Host "$($inputGroupId):$($inputArtifactId) looks goood to release" -ForegroundColor Green
Loading

0 comments on commit 7232b92

Please sign in to comment.