Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci/packages.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ Describe 'the real packages.json' {
$ipi.Count | Should -Be 5
$ipi.FirstVersion | Select-Object -Unique | Should -Be '4.5.0'
}

It 'has every tox.ini install the packages its package depends on' {
Get-ToxGaps (Split-Path $PSScriptRoot) $script:Real |
Should -BeNullOrEmpty
}
}

}
45 changes: 45 additions & 0 deletions ci/packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,51 @@ function Test-PathUnder([string]$Path, [string]$Folder) {
return $Path -eq $Folder -or $Path.StartsWith("$Folder/")
}

# Each tox.ini that does not install every package its package depends on,
# directly or through another, from this checkout, as a line naming what is
# missing. Taken from a package index instead, a dependency is tested at its
# last release rather than with the code it is released with.
function Get-ToxGaps([string]$RepoPath, $Packages = $null) {
if ($null -eq $Packages) {
$Packages = Get-Packages $RepoPath
}
$byName = @{}
foreach ($package in $Packages) {
$byName[$package.Name] = $package
}
$gaps = @()
foreach ($package in $Packages) {
$tox = Join-Path $RepoPath $package.Path 'tox.ini'
if ((Test-Path $tox) -eq $false) {
continue
}
$text = Get-Content -Raw $tox
$needed = [Collections.Generic.HashSet[string]]::new()
$queue = [Collections.Generic.Queue[string]]::new()
foreach ($name in $package.DependsOn) {
$queue.Enqueue($name)
}
while ($queue.Count -gt 0) {
$name = $queue.Dequeue()
if ($needed.Add($name) -eq $true) {
foreach ($next in $byName[$name].DependsOn) {
$queue.Enqueue($next)
}
}
}
foreach ($name in $needed) {
$relative = [IO.Path]::GetRelativePath(
(Join-Path $RepoPath $package.Path),
(Join-Path $RepoPath $byName[$name].Path)).Replace('\', '/')
$pattern = '(?m)^\s*-e\s*' + [regex]::Escape($relative) + '/?\s*$'
if ($text -notmatch $pattern) {
$gaps += "$($package.Path)/tox.ini does not install $name from $relative"
}
}
}
return $gaps
}

# The names of the given packages and of every package that depends on one of
# them, directly or through another.
function Get-DependentClosure($Packages, [string[]]$Names) {
Expand Down
10 changes: 10 additions & 0 deletions ci/run-unit-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@ param (
)
$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot 'dispatch.ps1')
. (Join-Path $PSScriptRoot 'packages.ps1')

# Each package's tests take the packages it depends on from this checkout, so
# they test the code those packages are released with. A tox.ini that takes
# one from PyPI instead stops the tests before they run.
$gaps = @(Get-ToxGaps (Split-Path $PSScriptRoot))
if ($gaps.Count -gt 0) {
throw "A tox.ini takes a package from PyPI that this checkout has:`n" +
($gaps -join "`n")
}

Invoke-ProductStep 'run-unit-tests' $RepoName $PSBoundParameters
6 changes: 6 additions & 0 deletions device-detection/fiftyone_devicedetection_cloud/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ package = wheel
wheel_build_env = .pkg
deps =
{[common]deps}
# The packages it depends on come from this checkout rather than a
# package index, so the tests run with the code they are released with.
-e../fiftyone_devicedetection_shared/
-e../../pipeline/fiftyone_pipeline_core/
-e../../pipeline/fiftyone_pipeline_engines/
-e../../pipeline/fiftyone_pipeline_engines_fiftyone/
-e../../pipeline/fiftyone_pipeline_cloudrequestengine/
commands =
pytest --cov={envsitepackagesdir}/fiftyone_devicedetection_cloud {tty:--color=yes} {posargs}
pass_env =
Expand Down
6 changes: 6 additions & 0 deletions ip-intelligence/fiftyone_ipintelligence_cloud/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ package = wheel
wheel_build_env = .pkg
deps =
{[common]deps}
# The packages it depends on come from this checkout rather than a
# package index, so the tests run with the code they are released with.
-e../fiftyone_ipintelligence_shared/
-e../../pipeline/fiftyone_pipeline_core/
-e../../pipeline/fiftyone_pipeline_engines/
-e../../pipeline/fiftyone_pipeline_engines_fiftyone/
-e../../pipeline/fiftyone_pipeline_cloudrequestengine/
commands =
pytest --cov={envsitepackagesdir}/fiftyone_ipintelligence_cloud {tty:--color=yes} {posargs}
pass_env =
Expand Down
6 changes: 6 additions & 0 deletions ip-intelligence/fiftyone_ipintelligence_shared/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ package = wheel
wheel_build_env = .pkg
deps =
{[common]deps}
# The packages it depends on come from this checkout rather than a
# package index, so the tests run with the code they are released with.
-e../../pipeline/fiftyone_pipeline_core/
-e../../pipeline/fiftyone_pipeline_engines/
-e../../pipeline/fiftyone_pipeline_engines_fiftyone/
-e../../pipeline/fiftyone_pipeline_cloudrequestengine/
commands =
pytest --cov={envsitepackagesdir}/fiftyone_ipintelligence_shared {tty:--color=yes} {posargs}
pass_env =
Expand Down
4 changes: 4 additions & 0 deletions ip-intelligence/fiftyone_ipintelligence_translation/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ package = wheel
wheel_build_env = .pkg
deps =
{[common]deps}
# The packages it depends on come from this checkout rather than a
# package index, so the tests run with the code they are released with.
-e../../pipeline/fiftyone_pipeline_core/
-e../../pipeline/fiftyone_pipeline_translation/
commands =
pytest --cov={envsitepackagesdir}/fiftyone_ipintelligence_translation {tty:--color=yes} {posargs}
pass_env =
Expand Down
5 changes: 5 additions & 0 deletions location/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ wheel_build_env = .pkg
deps =
pytest>=6
pytest-cov
# The packages it depends on come from this checkout rather than a
# package index, so the tests run with the code they are released with.
-e../pipeline/fiftyone_pipeline_core/
-e../pipeline/fiftyone_pipeline_engines/
-e../pipeline/fiftyone_pipeline_cloudrequestengine/
commands =
pytest --cov={envsitepackagesdir}/fiftyone_location {tty:--color=yes} {posargs}
pass_env =
Expand Down
Loading