Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tail Recursive Package Resolution #2066

Merged
merged 12 commits into from
Dec 13, 2016
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ release.sh
localpackages/
paket-files
*.orig
.paket/paket.exe
docs/content/license.md
docs/content/release-notes.md
_NCrunch_Paket
Expand Down
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ language: csharp
env:
- HOME=/home/travis APPDATA=/home/travis LocalAppData=/home/travis # DISABLE_NETCORE=true

#sudo: false # use the new container-based Travis infrastructure
sudo: required
sudo: false # use the new container-based Travis infrastructure
#sudo: required
dist: trusty # Ubuntu 14.04
dotnet: 1.0.0-preview2-003121
env: DOTNET_SDK_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/1.0.0-preview3-004056/dotnet-dev-ubuntu-x64.1.0.0-preview3-004056.tar.gz

mono:
- latest
Expand All @@ -15,5 +16,12 @@ branches:
except:
- gh-pages

install:
# Download .NET Core SDK and add to PATH
- export DOTNET_INSTALL_DIR="$PWD/.dotnetsdk"
- mkdir -p "$DOTNET_INSTALL_DIR"
- curl -L "$DOTNET_SDK_URL" | tar -xzv -C "$DOTNET_INSTALL_DIR"
- export PATH="$DOTNET_INSTALL_DIR:$PATH"

script:
- ./build.sh RunIntegrationTests
1 change: 0 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
cls

.paket\paket.exe restore
if errorlevel 1 (
Expand Down
110 changes: 78 additions & 32 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Target "AssemblyInfo" (fun _ ->
let dotnetExePath = if isWindows then "dotnetcore/dotnet.exe" else "dotnetcore/dotnet" |> FullName

Target "InstallDotNetCore" (fun _ ->
if isLinux then () else
let correctVersionInstalled =
try
if FileInfo(Path.Combine(dotnetCliPath.FullName,"dotnet.exe")).Exists then
Expand All @@ -147,16 +148,30 @@ Target "InstallDotNetCore" (fun _ ->
tracefn "dotnetcli %s already installed" dotnetcliVersion
else
CleanDir dotnetCliPath.FullName
let zipFileName = sprintf "dotnet-dev-win-x64.%s.zip" dotnetcliVersion
let downloadPath = sprintf "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/%s/%s" dotnetcliVersion zipFileName
let localPath = Path.Combine(dotnetCliPath.FullName, zipFileName)
let archiveFileName =
if isLinux then
sprintf "dotnet-dev-ubuntu-x64.%s.tar.gz" dotnetcliVersion
else
sprintf "dotnet-dev-win-x64.%s.zip" dotnetcliVersion
let downloadPath =
sprintf "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/%s/%s" dotnetcliVersion archiveFileName
let localPath = Path.Combine(dotnetCliPath.FullName, archiveFileName)

tracefn "Installing '%s' to '%s" downloadPath localPath

use webclient = new Net.WebClient()
webclient.DownloadFile(downloadPath, localPath)

System.IO.Compression.ZipFile.ExtractToDirectory(localPath, dotnetCliPath.FullName)

if isLinux then
ArchiveHelper.Tar.Extract (DirectoryInfo localPath) (FileInfo dotnetCliPath.FullName)
else
System.IO.Compression.ZipFile.ExtractToDirectory(localPath, dotnetCliPath.FullName)

tracefn "dotnet cli path - %s" dotnetCliPath.FullName
System.IO.Directory.EnumerateFiles dotnetCliPath.FullName
|> Seq.iter (fun path -> tracefn " - %s" path)
System.IO.Directory.EnumerateDirectories dotnetCliPath.FullName
|> Seq.iter (fun path -> tracefn " - %s%c" path System.IO.Path.DirectorySeparatorChar)

let oldPath = System.Environment.GetEnvironmentVariable("PATH")
System.Environment.SetEnvironmentVariable("PATH", sprintf "%s%s%s" dotnetCliPath.FullName (System.IO.Path.PathSeparator.ToString()) oldPath)
Expand All @@ -183,40 +198,71 @@ Target "Build" (fun _ ->
)


let assertExitCodeZero x =
if x = 0 then () else
failwithf "Command failed with exit code %i" x

let runCmdIn workDir exe =
Printf.ksprintf (fun args ->
Shell.Exec(exe, args, workDir) |> assertExitCodeZero)

/// Execute a dotnet cli command
let dotnet workDir = runCmdIn workDir "dotnet"

Target "DotnetRestore" (fun _ ->
netcoreFiles
|> Seq.iter (fun proj ->
DotNetCli.Restore (fun c ->
{ c with
Project = proj
ToolPath = dotnetExePath
})
)
if isLinux then
netcoreFiles
|> Seq.iter (fun proj ->
let dir = Path.GetDirectoryName proj
dotnet dir "--info"
dotnet dir "--verbose restore"
)
else
netcoreFiles
|> Seq.iter (fun proj ->
DotNetCli.Restore (fun c ->
{ c with
Project = proj
ToolPath = dotnetExePath
})
)
)

Target "DotnetBuild" (fun _ ->
if isLinux then
netcoreFiles
|> Seq.iter (fun proj ->
let dir = Path.GetDirectoryName proj
dotnet dir "--verbose build"
)
else
netcoreFiles
|> Seq.iter (fun proj ->
DotNetCli.Build (fun c ->
{ c with
Project = proj
ToolPath = dotnetExePath
})
|> Seq.iter (fun proj ->
DotNetCli.Build (fun c ->
{ c with
Project = proj
ToolPath = dotnetExePath
})
)
)
)

Target "DotnetPackage" (fun _ ->
// netcoreFiles
// |> Seq.iter (fun proj ->
// DotNetCli.Pack (fun c ->
// { c with
// Project = proj
// ToolPath = dotnetExePath
// AdditionalArgs = ["/p:RuntimeIdentifier=win7-x64"]
// })
// )

()
if isLinux then
netcoreFiles
|> Seq.iter (fun proj ->
let dir = Path.GetDirectoryName proj
dotnet dir "--verbose pack"
)
else
netcoreFiles
|> Seq.iter (fun proj ->
DotNetCli.Pack (fun c ->
{ c with
Project = proj
ToolPath = dotnetExePath
AdditionalArgs = ["/p:RuntimeIdentifier=win7-x64"]
})
)
)


Expand Down Expand Up @@ -546,7 +592,7 @@ Target "All" DoNothing
=?> ("DotnetRestore", not <| hasBuildParam "DISABLE_NETCORE")
=?> ("DotnetBuild", not <| hasBuildParam "DISABLE_NETCORE")
==> "Build"
=?> ("DotnetPackage", not <| hasBuildParam "DISABLE_NETCORE")
// =?> ("DotnetPackage", not <| hasBuildParam "DISABLE_NETCORE")
=?> ("BuildPowerShell", not isMono)
==> "RunTests"
=?> ("GenerateReferenceDocs",isLocalBuild && not isMono)
Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
if test "$OS" = "Windows_NT"
then
# use .Net

.paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
Expand Down
16 changes: 14 additions & 2 deletions integrationtests/Paket.IntegrationTests/TestHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ let prepare scenario =
|> Seq.iter (fun f -> File.Move(f, Path.ChangeExtension(f, "json")))

let directPaketInPath command scenarioPath =
#if INTERACTIVE
let result =
ExecProcessWithLambdas (fun info ->
info.FileName <- paketToolPath
info.WorkingDirectory <- scenarioPath
info.Arguments <- command)
(System.TimeSpan.FromMinutes 5.)
false
(printfn "%s")
(printfn "%s")
string result
#else
let result =
ExecProcessAndReturnMessages (fun info ->
info.FileName <- paketToolPath
Expand All @@ -54,9 +66,9 @@ let directPaketInPath command scenarioPath =
if result.ExitCode <> 0 then
let errors = String.Join(Environment.NewLine,result.Errors)
printfn "%s" <| String.Join(Environment.NewLine,result.Messages)
failwith errors
failwith errors
String.Join(Environment.NewLine,result.Messages)

#endif
let directPaket command scenario =
directPaketInPath command (scenarioTempPath scenario)

Expand Down
28 changes: 24 additions & 4 deletions integrationtests/Paket.IntegrationTests/UpdatePackageSpecs.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
module Paket.IntegrationTests.UpdatePackageSpecs

#if INTERACTIVE
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
#r "../../packages/test/NUnit/lib/net45/nunit.framework.dll"
#r "../../packages/build/FAKE/tools/Fakelib.dll"
#r "../../packages/Chessie/lib/net40/Chessie.dll"
#r "../../bin/paket.core.dll"
#load "../../paket-files/test/forki/FsUnit/FsUnit.fs"
#load "TestHelper.fs"
open Paket.IntegrationTests.TestHelpers
#else
module Paket.IntegrationTests.UpdatePackageSpecs
#endif
open Fake
open System
open NUnit.Framework
Expand Down Expand Up @@ -144,7 +154,7 @@ let ``#1579 update allows unpinned``() =

prepare scenario
directPaket "pack templatefile paket.A.template version 1.0.0-prerelease output bin" scenario |> ignore
directPaket "update" scenario|> ignore
directPaket "update -v" scenario|> ignore

[<Test>]
let ``#1501 download succeeds``() =
Expand All @@ -165,4 +175,14 @@ let ``#1635 should tell about auth issue``() =
update "i001635-wrong-pw" |> ignore
failwith "error expected"
with
| exn when exn.Message.Contains("Could not find versions for package Argu") -> ()
| exn when exn.Message.Contains("Could not find versions for package Argu") -> ()


#if INTERACTIVE
;;
let scenario = "i001579-unlisted"

prepare scenario
directPaket "pack templatefile paket.A.template version 1.0.0-prerelease output bin" scenario
directPaket "update -v" scenario
#endif
4 changes: 2 additions & 2 deletions src/Paket.Core/GitCommandHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let mutable monoArguments = ""

/// Modifies the ProcessStartInfo according to the platform semantics
let platformInfoAction (psi : ProcessStartInfo) =
if isMono && psi.FileName.EndsWith ".exe" then
if isMonoRuntime && psi.FileName.EndsWith ".exe" then
psi.Arguments <- monoArguments + " " + psi.FileName + " " + psi.Arguments
psi.FileName <- monoPath
/// Specifies a global timeout for git.exe - default is *no timeout*
Expand Down Expand Up @@ -134,7 +134,7 @@ let startedProcesses = HashSet()

/// [omit]
let start (proc : Process) =
if isMono && proc.StartInfo.FileName.ToLowerInvariant().EndsWith(".exe") then
if isMonoRuntime && proc.StartInfo.FileName.ToLowerInvariant().EndsWith(".exe") then
proc.StartInfo.Arguments <- "--debug \"" + proc.StartInfo.FileName + "\" " + proc.StartInfo.Arguments
proc.StartInfo.FileName <- monoPath

Expand Down
Loading