From 982988a2664151af8feaf1dd5a343ab8902df65c Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:07:12 +0100 Subject: [PATCH 1/8] Check whether versions are already published --- azure-pipelines.yml | 32 +++++++++++++++++++ .../checkpackages/Directory.Build.targets | 1 + .../FSharp.Compiler.Service_notshipped.fsproj | 8 +++++ .../FSharp.Core_notshipped.fsproj | 8 +++++ buildtools/checkpackages/check.ps1 | 15 +++++++++ 5 files changed, 64 insertions(+) create mode 100644 buildtools/checkpackages/check.ps1 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f53eb633ed..f4a78e5b2f7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -262,6 +262,38 @@ stages: DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 displayName: Check code formatting (run 'dotnet fantomas src -r' to fix) + # Checdk whether package with current version has been published to nuget.org + # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. + # NOTE: This CI check should only run on the release branch. + # Test trimming on Windows + - job: Check_Published_Package_Versions + pool: + vmImage: $(UbuntuMachineQueueName) + strategy: + maxParallel: 2 + matrix: + FCS: + _project: "FSharp.Compiler.Service_notshipped.fsproj" + FSCore: + _project: "FSharp.Core_notshipped.fsproj" + steps: + - checkout: self + clean: true + - task: UseDotNet@2 + displayName: install SDK + inputs: + packageType: sdk + useGlobalJson: true + includePreviewVersions: true + workingDirectory: $(Build.SourcesDirectory) + installationPath: $(Agent.ToolsDirectory)/dotnet + - pwsh: check.ps1 -project $(_project) + workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages + env: + DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 + displayName: Check published package version + + #-------------------------------------------------------------------------------------------------------------------# # PR builds # #-------------------------------------------------------------------------------------------------------------------# diff --git a/buildtools/checkpackages/Directory.Build.targets b/buildtools/checkpackages/Directory.Build.targets index 8c119d5413b..faf2349bae2 100644 --- a/buildtools/checkpackages/Directory.Build.targets +++ b/buildtools/checkpackages/Directory.Build.targets @@ -1,2 +1,3 @@ + diff --git a/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj b/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj index f5204fd5c67..a9166e35340 100644 --- a/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj +++ b/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj @@ -20,4 +20,12 @@ + + + + diff --git a/buildtools/checkpackages/FSharp.Core_notshipped.fsproj b/buildtools/checkpackages/FSharp.Core_notshipped.fsproj index 5942f999fd8..7299f5aec7a 100644 --- a/buildtools/checkpackages/FSharp.Core_notshipped.fsproj +++ b/buildtools/checkpackages/FSharp.Core_notshipped.fsproj @@ -14,4 +14,12 @@ + + + + diff --git a/buildtools/checkpackages/check.ps1 b/buildtools/checkpackages/check.ps1 new file mode 100644 index 00000000000..c416564786c --- /dev/null +++ b/buildtools/checkpackages/check.ps1 @@ -0,0 +1,15 @@ +# ENTRY POINT MAIN() +Param( + [Parameter(Mandatory=$True)] + [String] $project +) +& dotnet restore $project 2>$null + +if ($LASTEXITCODE -eq 0) +{ + $package = Get-Content -Path .\Version.txt + Write-Error " + Package restore succeded for '${package}', expected to fail. + This usually means that the package has been already published. + Please, bump the version to fix this failure." -ErrorAction Stop +} From 1668573fdb931a954ba15cde9a2732141335ea46 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:11:05 +0100 Subject: [PATCH 2/8] Guard by branch name --- azure-pipelines.yml | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f4a78e5b2f7..08795713d95 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -262,36 +262,36 @@ stages: DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 displayName: Check code formatting (run 'dotnet fantomas src -r' to fix) - # Checdk whether package with current version has been published to nuget.org + # Check whether package with current version has been published to nuget.org # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. # NOTE: This CI check should only run on the release branch. - # Test trimming on Windows - - job: Check_Published_Package_Versions - pool: - vmImage: $(UbuntuMachineQueueName) - strategy: - maxParallel: 2 - matrix: - FCS: - _project: "FSharp.Compiler.Service_notshipped.fsproj" - FSCore: - _project: "FSharp.Core_notshipped.fsproj" - steps: - - checkout: self - clean: true - - task: UseDotNet@2 - displayName: install SDK - inputs: - packageType: sdk - useGlobalJson: true - includePreviewVersions: true - workingDirectory: $(Build.SourcesDirectory) - installationPath: $(Agent.ToolsDirectory)/dotnet - - pwsh: check.ps1 -project $(_project) - workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages - env: - DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 - displayName: Check published package version + - ${{ if contains(variables['Build.SourceBranch'], 'refs/heads/release/') }}: + - job: Check_Published_Package_Versions + pool: + vmImage: $(UbuntuMachineQueueName) + strategy: + maxParallel: 2 + matrix: + FCS: + _project: "FSharp.Compiler.Service_notshipped.fsproj" + FSCore: + _project: "FSharp.Core_notshipped.fsproj" + steps: + - checkout: self + clean: true + - task: UseDotNet@2 + displayName: install SDK + inputs: + packageType: sdk + useGlobalJson: true + includePreviewVersions: true + workingDirectory: $(Build.SourcesDirectory) + installationPath: $(Agent.ToolsDirectory)/dotnet + - pwsh: check.ps1 -project $(_project) + workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages + env: + DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 + displayName: Check published package version #-------------------------------------------------------------------------------------------------------------------# From e6332a7145b5f77801763e9d393402022f1f6bbc Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:13:46 +0100 Subject: [PATCH 3/8] Guard by branch name --- azure-pipelines.yml | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 08795713d95..cfe705b59dc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -264,34 +264,34 @@ stages: # Check whether package with current version has been published to nuget.org # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. - # NOTE: This CI check should only run on the release branch. - - ${{ if contains(variables['Build.SourceBranch'], 'refs/heads/release/') }}: - - job: Check_Published_Package_Versions - pool: - vmImage: $(UbuntuMachineQueueName) - strategy: - maxParallel: 2 - matrix: - FCS: - _project: "FSharp.Compiler.Service_notshipped.fsproj" - FSCore: - _project: "FSharp.Core_notshipped.fsproj" - steps: - - checkout: self - clean: true - - task: UseDotNet@2 - displayName: install SDK - inputs: - packageType: sdk - useGlobalJson: true - includePreviewVersions: true - workingDirectory: $(Build.SourcesDirectory) - installationPath: $(Agent.ToolsDirectory)/dotnet - - pwsh: check.ps1 -project $(_project) - workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages - env: - DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 - displayName: Check published package version + # NOTE: This CI check should only run on the release branches. + - job: Check_Published_Package_Versions + condition: contains(variables['Build.SourceBranch'], 'refs/heads/release/dev17.4') + pool: + vmImage: $(UbuntuMachineQueueName) + strategy: + maxParallel: 2 + matrix: + FCS: + _project: "FSharp.Compiler.Service_notshipped.fsproj" + FSCore: + _project: "FSharp.Core_notshipped.fsproj" + steps: + - checkout: self + clean: true + - task: UseDotNet@2 + displayName: install SDK + inputs: + packageType: sdk + useGlobalJson: true + includePreviewVersions: true + workingDirectory: $(Build.SourcesDirectory) + installationPath: $(Agent.ToolsDirectory)/dotnet + - pwsh: check.ps1 -project $(_project) + workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages + env: + DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 + displayName: Check published package version #-------------------------------------------------------------------------------------------------------------------# From 619f7e6f60dbec902eaced1408a6c8a95e8d7411 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:16:02 +0100 Subject: [PATCH 4/8] Guard by branch name --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cfe705b59dc..47edcd00494 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -266,7 +266,7 @@ stages: # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. # NOTE: This CI check should only run on the release branches. - job: Check_Published_Package_Versions - condition: contains(variables['Build.SourceBranch'], 'refs/heads/release/dev17.4') + condition: or(contains(variables['Build.SourceBranch'], 'refs/heads/release/'), contains(variables['Build.TargetBranch'], 'refs/heads/release/')) pool: vmImage: $(UbuntuMachineQueueName) strategy: From fca4f19094094084efb1b8ee3b9fe35212dcb21c Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:18:52 +0100 Subject: [PATCH 5/8] Guard by branch name --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 47edcd00494..8687ea4d50c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -266,7 +266,7 @@ stages: # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. # NOTE: This CI check should only run on the release branches. - job: Check_Published_Package_Versions - condition: or(contains(variables['Build.SourceBranch'], 'refs/heads/release/'), contains(variables['Build.TargetBranch'], 'refs/heads/release/')) + condition: or(contains(variables['Build.SourceBranch'], 'refs/heads/release/'), or(contains(variables['system.pullRequest.sourceBranch'], 'refs/heads/release/'), contains(variables['system.pullRequest.targetBranch'], 'refs/heads/release/'))) pool: vmImage: $(UbuntuMachineQueueName) strategy: From 11ceb0b206fb35afe29c85c6fc24e5c7559a17e8 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 18:22:07 +0100 Subject: [PATCH 6/8] Guard by branch name --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8687ea4d50c..74994292dff 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -266,7 +266,7 @@ stages: # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. # NOTE: This CI check should only run on the release branches. - job: Check_Published_Package_Versions - condition: or(contains(variables['Build.SourceBranch'], 'refs/heads/release/'), or(contains(variables['system.pullRequest.sourceBranch'], 'refs/heads/release/'), contains(variables['system.pullRequest.targetBranch'], 'refs/heads/release/'))) + condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), or(startsWith(variables['System.PullRequest.SourceBranch'], 'release/dev'), startsWith(variables['System.PullRequest.TargetBranch'], 'release/dev'))) pool: vmImage: $(UbuntuMachineQueueName) strategy: From e32b08798f43d1e8fc18e477cb44bb6762f03a7b Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Jan 2023 19:14:28 +0100 Subject: [PATCH 7/8] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 74994292dff..cd22b05cf3b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -287,7 +287,7 @@ stages: includePreviewVersions: true workingDirectory: $(Build.SourcesDirectory) installationPath: $(Agent.ToolsDirectory)/dotnet - - pwsh: check.ps1 -project $(_project) + - pwsh: ./check.ps1 -project $(_project) workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages env: DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 From a9babad8b9f94056ebc89aa41fd37a9ff0a1e5f3 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 19 Jan 2023 12:04:18 +0100 Subject: [PATCH 8/8] Fix exit code --- buildtools/checkpackages/check.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildtools/checkpackages/check.ps1 b/buildtools/checkpackages/check.ps1 index c416564786c..d956de90789 100644 --- a/buildtools/checkpackages/check.ps1 +++ b/buildtools/checkpackages/check.ps1 @@ -12,4 +12,6 @@ if ($LASTEXITCODE -eq 0) Package restore succeded for '${package}', expected to fail. This usually means that the package has been already published. Please, bump the version to fix this failure." -ErrorAction Stop +} else { + exit 0 }