Skip to content

Commit 0ce6541

Browse files
committed
Add fudge
1 parent 4af3380 commit 0ce6541

13 files changed

+934
-37
lines changed

.ci/FudgeAppVeyor.ps1

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
. $env:FudgeCI/FudgeGenerateFake.ps1
2+
. $env:FudgeCI/PrepareAVVM.ps1
3+
4+
Set-StrictMode -Version latest
5+
6+
function Fix-MinGW {
7+
# TODO: Handle versions other than 8.1.0
8+
Move-Item C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 C:\MinGW81-x64
9+
}
10+
11+
function Choose-Preinstalled-Products {
12+
param(
13+
[array]
14+
$Packages
15+
)
16+
17+
foreach ($pkg in $Packages) {
18+
try {
19+
$product = $pkg.AppVeyor
20+
} catch {
21+
continue
22+
}
23+
24+
$version = $pkg.Version
25+
26+
$version_parts = ($version.Split('.'))
27+
28+
if ($product -eq 'jdk') {
29+
# 8 -> 1.8.0
30+
$version = "1." + $version_parts[0] + ".0"
31+
} elseif ($product -eq 'MinGW') {
32+
Fix-MinGW
33+
} elseif ($product -eq 'miniconda') {
34+
# TODO improve translation of real miniconda versions
35+
# into AppVeyor versions which are the python version
36+
if ($version -eq '4.5.12') {
37+
$version = '3.7'
38+
}
39+
40+
if ($version[0] -eq '2') {
41+
Fix-Miniconda27
42+
}
43+
}
44+
45+
# Allow the installed version of python to be over
46+
if ($product -eq 'python') {
47+
if ($env:PYTHON_VERSION) {
48+
$version = $env:PYTHON_VERSION
49+
}
50+
}
51+
52+
Add-Product $product $version $env:PLATFORM
53+
if (Test-Path "C:\avvm\$product\$version\$env:PLATFORM") {
54+
Install-Product $product $version $env:PLATFORM
55+
} elseif (Test-Path "C:\avvm\$product\$version") {
56+
if ($env:PLATFORM -eq 'x86') {
57+
$platform = 'x64'
58+
} else {
59+
$platform = 'x86'
60+
}
61+
Install-Product $product $version $platform
62+
}
63+
}
64+
}
65+
66+
function Fix-AppVeyor {
67+
# Special case, so the generated file isnt in mobans repository assets
68+
if (Test-Path assets/fudge) {
69+
$config = Get-FudgefileContent .ci/Fudgefile.appveyor
70+
} else {
71+
$config = Get-FudgefileContent $env:FudgeCI/Fudgefile.appveyor
72+
}
73+
74+
PackFakeNupkgs $config.packages
75+
76+
SetDefaultVersions
77+
78+
Choose-Preinstalled-Products $config.packages
79+
}
80+
81+
Export-ModuleMember -Function Fix-AppVeyor

.ci/FudgeGenerateFake.ps1

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
Set-StrictMode -Version latest
2+
3+
$template = @'
4+
<?xml version="1.0"?>
5+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
6+
<metadata>
7+
<id>{name}</id>
8+
<version>{version}</version>
9+
<title>{name} {version}</title>
10+
<authors>AppVeyor</authors>
11+
<description>Fake generated {name} package to fulfil dependencies.</description>
12+
<dependencies>
13+
<dependency id="chocolatey"/>
14+
</dependencies>
15+
</metadata>
16+
</package>
17+
'@
18+
19+
function GenerateFakeNuspec {
20+
param(
21+
[Parameter(Mandatory = $true)]
22+
[ValidateNotNullOrEmpty()]
23+
[string]
24+
$name,
25+
26+
[Parameter(Mandatory = $true)]
27+
[ValidateNotNullOrEmpty()]
28+
[string]
29+
$version
30+
)
31+
32+
$content = $template -replace '{name}', $name
33+
$content = $content -replace '{version}', $version
34+
35+
$nuspec = ($env:FudgeCI + '\nuspecs\' + $name + '.nuspec')
36+
37+
Set-Content $nuspec $content
38+
39+
Write-Output "Created $nuspec"
40+
}
41+
42+
function GenerateFakeNuspecs {
43+
param(
44+
[array]
45+
$Packages
46+
)
47+
48+
foreach ($pkg in $Packages) {
49+
GenerateFakeNuspec $pkg.Name $pkg.version
50+
}
51+
}
52+
53+
function PackFakeNupkgs {
54+
param(
55+
[array]
56+
$Packages
57+
)
58+
59+
mkdir -Force $env:FudgeCI\nuspecs\ > $null
60+
61+
GenerateFakeNuspecs $Packages
62+
63+
# This should work, but is failing
64+
# fudge pack -FudgefilePath .ci/Fudgefile.appveyor
65+
foreach ($pkg in $Packages) {
66+
$filename = ($pkg.Name + '.nuspec')
67+
choco pack "$env:FudgeCI\nuspecs\$filename" > $null
68+
}
69+
mv *.nupkg $env:FudgeCI\nuspecs\
70+
71+
Write-Output 'Packed!'
72+
}

.ci/FudgePostInstall.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
. $env:ChocolateyInstall\helpers\functions\Write-FunctionCallLogMessage.ps1
2+
. $env:ChocolateyInstall\helpers\functions\Get-EnvironmentVariable.ps1
3+
. $env:ChocolateyInstall\helpers\functions\Get-EnvironmentVariableNames.ps1
4+
. $env:ChocolateyInstall\helpers\functions\Start-ChocolateyProcessAsAdmin.ps1
5+
. $env:ChocolateyInstall\helpers\functions\Set-EnvironmentVariable.ps1
6+
. $env:ChocolateyInstall\helpers\functions\Set-PowerShellExitCode.ps1
7+
. $env:ChocolateyInstall\helpers\functions\Update-SessionEnvironment.ps1
8+
. $env:ChocolateyInstall\helpers\functions\Write-FunctionCallLogMessage.ps1
9+
. $env:ChocolateyInstall\helpers\functions\Install-ChocolateyPath.ps1
10+
11+
Set-StrictMode -Version latest
12+
13+
$deps_base = $env:FudgeCI
14+
15+
function Run-PostInstall {
16+
choco list --local-only
17+
18+
Update-SessionEnvironment
19+
20+
Write-Host "PATH = $env:PATH"
21+
22+
$config = Get-FudgefileContent Fudgefile
23+
24+
foreach ($pkg in $config.Packages) {
25+
$name = $pkg.Name
26+
27+
$glob = "$deps_base/deps.$name.ps1"
28+
29+
if (Test-Path $glob) {
30+
Write-Host "Running post-install for $name"
31+
32+
. $glob
33+
Do-PostInstall
34+
}
35+
}
36+
37+
Update-SessionEnvironment
38+
39+
Write-Host "PATH = $env:PATH"
40+
41+
foreach ($pkg in $config.Packages) {
42+
$name = $pkg.Name
43+
44+
$glob = "$deps_base/deps.$name-packages.ps1"
45+
if (Test-Path $glob) {
46+
Write-Host "Running $name package installation"
47+
48+
. $glob
49+
Do-Install-Packages
50+
}
51+
}
52+
}
53+
54+
Export-ModuleMember -Function Run-PostInstall

.ci/Fudgefile.appveyor

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scripts": {
3+
"pre": {
4+
"install": ". $env:FudgeCI/FudgeAppVeyor.ps1; Fix-AppVeyor"
5+
}
6+
},
7+
"source": ".ci/nuspecs",
8+
"packages": [
9+
{ "name": "hg", "version": "5.0" },
10+
{ "name": "python", "version": "3.6.8", "appveyor": "python" },
11+
{ "name": "nodejs", "version": "11.13.0", "appveyor": "node" }
12+
],
13+
"pack": {
14+
"hg": ".ci/nuspecs/hg.nuspec",
15+
"python": ".ci/nuspecs/python.nuspec",
16+
"nodejs": ".ci/nuspecs/nodejs.nuspec"
17+
}
18+
}

0 commit comments

Comments
 (0)