version: '{build}.{branch}'
skip_branch_with_pr: true
clone_folder: c:\denoclone_depth: 1
environment: APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 DENO_BUILD_MODE: release DENO_BUILD_PATH: $(APPVEYOR_BUILD_FOLDER)\out\release DENO_THIRD_PARTY_PATH: $(APPVEYOR_BUILD_FOLDER)\third_party MTIME_CACHE_DB: $(APPVEYOR_BUILD_FOLDER)\mtime_cache.xml CARGO_HOME: $(USERPROFILE)\.cargo RUSTUP_HOME: $(USERPROFILE)\.rustup RELEASE_ARTIFACT: deno_win_x64.zip
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -snl -mtc -mx=1
PYTHONUNBUFFERED: 1
PS_UTILS: |- function Exec([ScriptBlock] $Command, [switch] $NoNewLines) { "$Command".TrimStart(" &") | Write-Host & $Command 2>&1 | Write-Host -NoNewLine:$NoNewLines if ($NoNewLines) { Write-Host } if ($LastExitCode -ne 0) { throw "Failure. Exit code: $LastExitCode" } }
function Get-Tree([string[]] $Path, [switch] $Recurse, [switch] $Force) { function Get-SubDirs([string[]] $Path) { Get-ChildItem $Path -Force:$Force ` -Attributes Directory+!ReparsePoint | foreach { $_.FullName } | foreach { $_; Get-SubDirs $_ } } if ($Recurse) { $Path += Get-SubDirs $Path } Get-ChildItem $Path -Force:$Force @args }
function Delete-Tree([string[]] $Path) { $Path | foreach { "Deleting '$_'" | Write-Host -NoNewLine if (Test-Path $_) { Remove-Item $_ -Recurse -Force -ErrorAction Ignore $(if ($?) { " - ok" } else { " - failed" }) | Write-Host } else { " - not found" | Write-Host } } }
$FILE_NOT_NEEDED = Get-Date -Date "1984-04-11T00:00:00Z" $not_needed = @{} $atime_enabled = $false
function Start-TraceFilesNeeded([string[]] $Path, [switch] $Recurse) { if (-not (Get-SaveCache)) { return } $files = $Path | where { Test-Path $_ } | foreach { Get-Tree $_ -Recurse:$Recurse -File } | where { -not $not_needed.ContainsKey($_.FullName) } $files | foreach { $_.LastAccessTime = $FILE_NOT_NEEDED } $files | foreach { $not_needed.Add($_.FullName, $true) } if ($files -and -not $atime_enabled) { Exec { fsutil behavior set DisableLastAccess 0 } Set-Variable -Name atime_enabled -Value $true -Scope 1 } Write-Host "Tracing file access for $($files.Count) files." }
function Set-FilesNeeded([switch] $Auto, [string[]] $Path, [switch] $Recurse, [string] $Reason) { function Mark([System.IO.FileSystemInfo[]] $Files, [string] $How) { $keys = $Files.FullName | where { $_ -and $not_needed.ContainsKey($_) } $keys | foreach { $not_needed.Remove($_) } if ($keys.Count -gt 0) { Write-Host ("$Reason$(if ($Reason) { ': ' })" + "$($keys.Count) files $How marked 'needed'.") } } if ($not_needed.Count -eq 0) { return } if ($Auto) { $files = $not_needed.Keys | where { Test-Path $_ -PathType Leaf } | foreach { Get-Item $_ -Force } | where { $_.LastAccessTime -ne $FILE_NOT_NEEDED } Mark -Files $files -How "automatically" } if ($Path) { $files = $Path | where { Test-Path $_ } | foreach { Get-Tree $_ -Recurse:$Recurse -Force -File } Mark -Files $files -How "explicitly" } }
function Stop-TraceFilesNeeded { Set-FilesNeeded -Auto $files = $not_needed.Keys | where { Test-Path $_ -PathType Leaf } | foreach { Get-Item $_ -Force } $size_info = $files | measure -Property Length -Sum $size_mb = "{0:N1}" -f ($size_info.Sum / (1024 * 1024)) $files | Remove-Item -Force $dirs = $files | foreach { try { while ($_ = $_.Directory) { $_.Delete(); $_ } } catch {} } $not_needed.Clear() if ($files.Count -gt 0) { Write-Host "Deleted $($files.Count) unnecessary files and", "$($dirs.Count) directories ($size_mb MB)." } }
function Sync-MTimeCache([string] $DatabasePath) { try { $old_cache = Import-CliXml -Path $DatabasePath -ErrorAction Stop } catch { $old_cache = @{} } $new_cache = @{} $now = (Get-Date).ToFileTimeUtc() $dirty = git status -z --ignore-submodules=all --untracked-files=no if ($dirty) { throw "Work tree dirty." } (git ls-files -z --stage --eol --full-name) -split "\0" | foreach { if ($_ -notmatch "^100") { return } $mtime = $old_cache[$_] if (-not $mtime -or $mtime -gt $now) { $mtime = $now } $path = ($_ -split "\t", 3)[2] $lwt = [DateTime]::FromFileTimeUtc($mtime) Set-ItemProperty -Path $path -Name LastWriteTime -Value $lwt -Force $new_cache[$_] = $mtime } if (Get-SaveCache) { $new_cache | Export-CliXml -Path $DatabasePath -ErrorAction Stop } $rows = [ordered]@{ Valid = "=="; New = "=>" Stale = "<="; Total = "*" } $keys = @{ old = @($old_cache.Keys); new = @($new_cache.Keys) } $diff = Compare-Object $keys.old $keys.new -IncludeEqual $rows.GetEnumerator() | foreach { $keyset = ($diff | where SideIndicator -like $_.Value).InputObject New-Object -TypeName PSObject -Property ([ordered]@{ "Status" = $_.Name "Old Cache "New Cache }) } | Format-Table | Out-String -Stream | where { $_ } }
function Get-SaveCache { -not $env:APPVEYOR_PULL_REQUEST_NUMBER -and -not $env:APPVEYOR_CACHE_SKIP_SAVE -eq "true" }
for: - branches: except: - master environment: APPVEYOR_CACHE_SKIP_SAVE: true
cache: - $(APPDATA)\Python - $(CARGO_HOME) - $(RUSTUP_HOME) - $(APPVEYOR_BUILD_FOLDER)\.git\modules\third_party - $(APPVEYOR_BUILD_FOLDER)\third_party - $(MTIME_CACHE_DB) - $(DENO_BUILD_PATH)
init: - ps: Invoke-Expression $env:PS_UTILS
- git config --global core.symlinks true
install: - ps: |- try { Exec { & git submodule update --init --force --depth 1 } } catch { Delete-Tree $env:DENO_THIRD_PARTY_PATH Exec -NoNewLines { & git submodule update --init --force --depth 1 } }
- ps: if (Get-SaveCache) { git -C $env:DENO_THIRD_PARTY_PATH gc --prune=all }
- ps: Sync-MTimeCache -DatabasePath $env:MTIME_CACHE_DB
- ps: |- $env:PATH = "$env:DENO_THIRD_PARTY_PATH\depot_tools;$env:PATH" $env:DEPOT_TOOLS_WIN_TOOLCHAIN = "0"
- ps: Install-Product -Product node -Version 10 -Platform x64
- ps: |- $p = $env:PATH -split ";" | where { -not (Test-Path "$_\python.exe") -and -not (Test-Path "$_\pip.exe") } $p += "$env:APPDATA\Python\Scripts" $p += "c:\Python27-x64" $p += "c:\Python27-x64\Scripts" $env:PATH = $p -join ";"
- python -m pip install --upgrade --user --no-cache-dir pip
- pip install --upgrade --user --no-cache-dir pywin32 yapf
- ps: $env:PATH += ";$env:CARGO_HOME\bin"
- ps: |- if (Get-SaveCache -and (Test-Path $env:CARGO_HOME)) { try { Exec -NoNewLines { & rustup update stable-x86_64-pc-windows-msvc } } catch { Delete-Tree $env:CARGO_HOME, $env:RUSTUP_HOME } }
- ps: |- if (-not (Test-Path $env:CARGO_HOME)) { Invoke-WebRequest -Uri "https://win.rustup.rs" ` -OutFile "$env:TEMP\rustup-init.exe" Exec -NoNewLines { & "$env:TEMP\rustup-init.exe" -y } Delete-Tree @( "$env:RUSTUP_HOME\downloads", "$env:RUSTUP_HOME\tmp", "$env:RUSTUP_HOME\toolchains\stable-x86_64-pc-windows-msvc\share\doc" ) }
- node -p "`Node ${process.version} ${process.arch}`"
- ps: |- @("from sys import version", "print 'Python', version") -join "`n" | & python -
- pip --version - rustc --version - cargo --version
before_build: - ps: Start-TraceFilesNeeded $env:DENO_BUILD_PATH -Recurse
- python tools\setup.py - ps: Set-FilesNeeded -Auto -Reason "Setup finished"
- ps: |- $outputs = ninja -C $env:DENO_BUILD_PATH -n -t clean -g | where { $_ -match "^Remove (.*)$" } | foreach { "$env:DENO_BUILD_PATH\$($Matches[1])" } Set-FilesNeeded -Auto -Path $outputs -Reason "Build dependency graph"
build_script: - python tools\build.py - ps: Set-FilesNeeded -Auto -Reason "Build finished"
test_script: - python tools\lint.py - ps: Exec { & python tools\test.py $env:DENO_BUILD_PATH }
after_test: - ps: if (Get-SaveCache) { Delete-Tree "$env:DENO_BUILD_PATH\.rpt2_cache" }
- ps: Stop-TraceFilesNeeded
- ps: |- $out = ninja -C $env:DENO_BUILD_PATH -n -d explain if ($out -notcontains "ninja: no work to do.") { throw "Build should be up-to-date but isn't." }
- ps: |- $ignore = "test_util.ts", "unit_tests.ts", "*_test.ts" Get-ChildItem "js" -File -Force -Name | where { $name = $_; -not ($ignore | where { $name -like $_ }) } | where { -not (Select-String -Pattern $_ -Path BUILD.gn ` -SimpleMatch -CaseSensitive) } | foreach { throw "$_ should be listed in BUILD.gn but isn't." }
- ps: |- $trap = "NO_ABS_PATH_PLS" $dir = "$env:APPVEYOR_BUILD_FOLDER\out\$trap" Exec { gn gen $dir | Out-Null } $files = Get-Tree $dir -File -Force -Recurse | where Extension -ne ".dll" Select-String $trap -Path $files -SimpleMatch | tee -Variable line_matches if ($line_matches) { $ctx = $line_matches.Line | Select-String "[^\s;,]*[\s=]*[^\s;,=]*$trap[^\s;,]*" -AllMatches | foreach { $_.Matches.Value -replace '\$(.)', '$1' } | sort -Unique throw @("Absolute path(s) found in build script:") + $ctx -join "`n " }
- ps: |- if ($env:APPVEYOR_REPO_TAG -eq "true") { Compress-Archive -CompressionLevel Optimal -Force ` -Path "$env:DENO_BUILD_PATH\deno.exe" ` -DestinationPath "$env:APPVEYOR_BUILD_FOLDER\$env:RELEASE_ARTIFACT" }
artifacts: path: $(RELEASE_ARTIFACT)
deploy: provider: GitHub auth_token: secure: HQIIUEOtep3yRiBacZCtX8hVmgtdNvt6Hx7u9fP4Wj2ZYp+eBFP2OLf67RKVa5VZ on: APPVEYOR_REPO_NAME: denoland/deno APPVEYOR_REPO_TAG: true