-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC][registries] Allow pattern matching in packages declarations (#778)
* Resolve prefix patterns in packages declarations * Allow prefixes in configuration parser * A few more test cases * Add warning for ignored patterns/packages * Print warnings on vcpkg configuration * Localize warning messages * Clean up * Test registry parsing * Apply Billy's patch * Apply Billy's suggestions from code review Co-authored-by: Billy O'Neal <[email protected]> * Format * Collect all package pattern warnings into one * Improve warning message * Format messages * Disallow period separated segments in port names * Error messages on invalid patterns/names * Cleanup * Disallow registries without setting a baseline * Fix for artifact registries * Billy's PR comments * Add e2e test registry * End-to-end tests * Fix e2e tests * Make tests success case silent * Accept prefixes ending in '-' Co-authored-by: Billy O'Neal <[email protected]>
- Loading branch information
1 parent
dc7706f
commit 02abc66
Showing
32 changed files
with
993 additions
and
103 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
azure-pipelines/e2e_projects/registries-package-patterns/no-patterns.json.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"vcpkg-configuration": { | ||
"default-registry": null, | ||
"registries": [ | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"foo", | ||
"bar" | ||
] | ||
}, | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
}, | ||
"dependencies": [ | ||
"bar", | ||
"baz", | ||
"foo" | ||
] | ||
} |
28 changes: 28 additions & 0 deletions
28
azure-pipelines/e2e_projects/registries-package-patterns/only-patterns.json.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"vcpkg-configuration": { | ||
"default-registry": null, | ||
"registries": [ | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"*" | ||
] | ||
}, | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"b*" | ||
] | ||
} | ||
] | ||
}, | ||
"dependencies": [ | ||
"bar", | ||
"baz", | ||
"foo" | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
azure-pipelines/e2e_projects/registries-package-patterns/with-default.json.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"vcpkg-configuration": { | ||
"default-registry": { | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"b*" | ||
] | ||
} | ||
] | ||
}, | ||
"dependencies": [ | ||
"bar", | ||
"baz", | ||
"foo" | ||
] | ||
} |
32 changes: 32 additions & 0 deletions
32
azure-pipelines/e2e_projects/registries-package-patterns/with-redeclaration.json.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"vcpkg-configuration": { | ||
"default-registry": { | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"b*" | ||
] | ||
}, | ||
{ | ||
"kind": "git", | ||
"repository": "$E2ERegistryPath", | ||
"baseline": "$E2ERegistryBaseline", | ||
"packages": [ | ||
"b*" | ||
] | ||
} | ||
] | ||
}, | ||
"dependencies": [ | ||
"bar", | ||
"baz", | ||
"foo" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "foo", | ||
"version": "1.1.0", | ||
"description": "e2e test port" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "bar", | ||
"version": "1.0.0", | ||
"description": "e2e test port" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "baz", | ||
"version": "1.0.0", | ||
"description": "e2e test port" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "foo", | ||
"version": "1.0.0", | ||
"description": "e2e test port" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "51562fff2b6db21a115564871c7174d59e77e637", | ||
"version": "1.0.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "85462e55644fe3c9cb42928545e01784dda3e8d7", | ||
"version": "1.0.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"default": { | ||
"bar": { | ||
"baseline": "1.0.0", | ||
"port-version": 0 | ||
}, | ||
"baz": { | ||
"baseline": "1.0.0", | ||
"port-version": 0 | ||
}, | ||
"foo": { | ||
"baseline": "1.1.0", | ||
"port-version": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "a1626920f5bbc6a6ccd007ba5a194f38eb8e6222", | ||
"version": "1.1.0", | ||
"port-version": 0 | ||
}, | ||
{ | ||
"git-tree": "011346ce22c43b3312e32a18c751ca6dd35c4578", | ||
"version": "1.0.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
. $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||
|
||
### <Initialize registry> | ||
# Creates a git registry to run the e2e tests on | ||
$e2eProjects = "$PSScriptRoot/../e2e_projects" | ||
$manifestRoot = "$e2eProjects/registries-package-patterns" | ||
$e2eRegistryPath = "$PSScriptRoot/../e2e_registry".Replace('\', '\\') | ||
Push-Location $e2eRegistryPath | ||
try | ||
{ | ||
Write-Host "Initializing test registry" | ||
if (Test-Path "$e2eRegistryPath/.git") | ||
{ | ||
Remove-Item -Recurse -Force "$e2eRegistryPath/.git" | ||
} | ||
|
||
|
||
$gitConfig = @( | ||
'-c', 'user.name=Nobody', | ||
'-c', '[email protected]', | ||
'-c', 'core.autocrlf=false' | ||
) | ||
|
||
git @gitConfig init . | Out-Null | ||
Throw-IfFailed | ||
git @gitConfig add -A | Out-Null | ||
Throw-IfFailed | ||
git @gitConfig commit -m "initial commit" | Out-Null | ||
Throw-IfFailed | ||
$e2eRegistryBaseline = git rev-parse HEAD | ||
Throw-IfFailed | ||
} | ||
finally | ||
{ | ||
Pop-Location | ||
} | ||
### </Initialize Registry> | ||
|
||
$commonArgs += @("--x-manifest-root=$manifestRoot") | ||
|
||
# [patterns] No patterns (no default) | ||
Write-Host "[patterns] No patterns (no default)" | ||
$inFile = "$manifestRoot/no-patterns.json.in" | ||
(Get-Content -Path "$inFile").Replace("`$E2ERegistryPath", $e2eRegistryPath).Replace("`$E2ERegistryBaseline", $e2eRegistryBaseline) ` | ||
| Out-File "$manifestRoot/vcpkg.json" | ||
|
||
Run-Vcpkg -EndToEndTestSilent @commonArgs install | Out-Null | ||
Throw-IfFailed | ||
Refresh-TestRoot | ||
|
||
# [patterns] Patterns only (no default) | ||
Write-Host "[patterns] Patterns only (no default)" | ||
$inFile = "$manifestRoot/only-patterns.json.in" | ||
(Get-Content -Path "$inFile").Replace("`$E2ERegistryPath", $e2eRegistryPath).Replace("`$E2ERegistryBaseline", $e2eRegistryBaseline) ` | ||
| Out-File "$manifestRoot/vcpkg.json" | ||
|
||
Run-Vcpkg -EndToEndTestSilent @commonArgs install | Out-Null | ||
Throw-IfFailed | ||
Refresh-TestRoot | ||
|
||
# [patterns] Patterns with default | ||
Write-Host "[patterns] Patterns with default" | ||
$inFile = "$manifestRoot/with-default.json.in" | ||
(Get-Content -Path "$inFile").Replace("`$E2ERegistryPath", $e2eRegistryPath).Replace("`$E2ERegistryBaseline", $e2eRegistryBaseline) ` | ||
| Out-File "$manifestRoot/vcpkg.json" | ||
|
||
Run-Vcpkg -EndToEndTestSilent @commonArgs install | Out-Null | ||
Throw-IfFailed | ||
Refresh-TestRoot | ||
|
||
# [patterns] Repeated patterns | ||
Write-Host "[patterns] Repeated patterns" | ||
$inFile = "$manifestRoot/with-redeclaration.json.in" | ||
(Get-Content -Path "$inFile").Replace("`$E2ERegistryPath", $e2eRegistryPath).Replace("`$E2ERegistryBaseline", $e2eRegistryBaseline) ` | ||
| Out-File "$manifestRoot/vcpkg.json" | ||
|
||
$out = Run-VcpkgAndCaptureOutput -EndToEndTestSilent @commonArgs install | ||
Throw-IfFailed | ||
if ($out -notmatch "redeclarations will be ignored") | ||
{ | ||
$out | ||
throw "Expected warning about redeclaration" | ||
} | ||
Refresh-TestRoot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.