Skip to content

Commit

Permalink
(#29) CI: use Dependencies instead of dumpbin
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed May 10, 2022
1 parent cc7ba62 commit 1738f1d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ jobs:
name: tdlib.windows
path: ./artifacts

- name: Cache downloads for Windows
uses: actions/cache@v2
with:
path: build/downloads
key: ${{ hashFiles('windows/install.ps1') }}

- name: Install dependencies
shell: pwsh
run: ./windows/install.ps1

- name: Windows-specific testing
shell: pwsh
run: ./windows/test.ps1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.idea/
/build/

*.temp.txt
49 changes: 49 additions & 0 deletions windows/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# NOTE: Only used in tests right now.
param (
$DependenciesLink = 'https://github.com/lucasg/Dependencies/releases/download/v1.11.1/Dependencies_x64_Release_.without.peview.exe.zip',
$DependenciesHash = '7D22DC00F1C09FD4415D48AD74D1CF801893E83B9A39944B0FCE6DEA7CEAEA99',
$DownloadStorage = "$PSScriptRoot/../build/downloads",
$DependenciesInstallPath = "$PSScriptRoot/../build/tools/dependencies"
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

if (!(Test-Path $DownloadStorage)) {
New-Item -Type Directory $DownloadStorage | Out-Null
}

$dependenciesFileName = [Uri]::new($DependenciesLink).Segments | Select-Object -Last 1
$dependenciesDownloadPath = "$DownloadStorage/$dependenciesFileName"
if (Test-Path $dependenciesDownloadPath) {
Write-Output "File `"$dependenciesDownloadPath`" already exists; checking its hash…"
$actualHash = Get-FileHash -Algorithm SHA256 $dependenciesDownloadPath
if ($actualHash.Hash -eq $DependenciesHash) {
Write-Output 'Hash check succeeded; reusing the downloaded item.'
} else {
Write-Output "Actual hash: $($actualHash.Hash)."
Write-Output "Expected hash: $DependenciesHash."
Write-Output "Deleting file for re-download…"
Remove-Item $dependenciesDownloadPath
}
}

if (!(Test-Path $dependenciesDownloadPath)) {
Write-Output "Downloading `"$DependenciesLink`""
Invoke-WebRequest $DependenciesLink -OutFile $dependenciesDownloadPath
}

$actualHash = Get-FileHash -Algorithm SHA256 $dependenciesDownloadPath
if ($actualHash.Hash -ne $DependenciesHash) {
Write-Output "Actual hash: $($actualHash.Hash)."
Write-Output "Expected hash: $DependenciesHash."
Write-Output "Hashes don't match."
throw 'Cannot download Dependencies tool.'
}

if (Test-Path $DependenciesInstallPath) {
Remove-Item -Recurse $DependenciesInstallPath
}

Expand-Archive $dependenciesDownloadPath $DependenciesInstallPath
Write-Output "Dependencies tool installed to directory `"$DependenciesInstallPath`"."
12 changes: 6 additions & 6 deletions windows/libraries.gold.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libcrypto-1_1-x64.dll
libcrypto-3-x64.dll
ADVAPI32.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
Expand All @@ -15,15 +15,15 @@ libcrypto-1_1-x64.dll
USER32.dll
VCRUNTIME140.dll
WS2_32.dll
libssl-1_1-x64.dll
libssl-3-x64.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
KERNEL32.dll
libcrypto-1_1-x64.dll
libcrypto-3-x64.dll
VCRUNTIME140.dll
tdjson.dll
api-ms-win-crt-convert-l1-1-0.dll
Expand All @@ -35,12 +35,12 @@ tdjson.dll
api-ms-win-crt-time-l1-1-0.dll
CRYPT32.dll
KERNEL32.dll
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
libcrypto-3-x64.dll
libssl-3-x64.dll
MSVCP140.dll
Normaliz.dll
VCRUNTIME140_1.dll
VCRUNTIME140.dll
VCRUNTIME140_1.dll
WS2_32.dll
zlib1.dll
zlib1.dll
Expand Down
10 changes: 6 additions & 4 deletions windows/test.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
param (
[string] $Dependencies = "$PSScriptRoot/../build/tools/dependencies/Dependencies.exe",

[string] $Artifacts = "$PSScriptRoot/../artifacts",
[string] $GoldFile = "$PSScriptRoot/../windows/libraries.gold.txt",
[string] $ResultFile = "$PSScriptRoot/../windows/libraries.temp.txt",
Expand All @@ -17,13 +19,13 @@ if (Test-Path $ResultFile) {
Get-ChildItem "$Artifacts/*.dll" | Sort-Object -Property Name | ForEach-Object {
$libraryPath = $_.FullName

Write-Output "Checking file $libraryPath"
$output = dumpbin /DEPENDENTS $libraryPath
Write-Output "Checking file `"$libraryPath`""
$output = & $Dependencies -json -imports $libraryPath | ConvertFrom-Json
if (!$?) {
throw "dumpbin /DEPENDENTS $libraryPath returned an exit code $LASTEXITCODE; output: $output"
throw "Dependencies.exe returned an exit code $LASTEXITCODE."
}

$libraryNames = $output | Where-Object { $_ -match '^ [^ ]' } | ForEach-Object { $_.TrimStart() } | Sort-Object
$libraryNames = $output.Imports | Select-Object -ExpandProperty Name | Sort-Object
$_.Name >> $ResultFile
$libraryNames | ForEach-Object { " $_" >> $ResultFile }
}
Expand Down

0 comments on commit 1738f1d

Please sign in to comment.