Skip to content

Commit 4cfee0b

Browse files
committed
Move installation of deps to powershell scripts
Take inspiration from the Swift Dockerfiles
1 parent fce6569 commit 4cfee0b

File tree

6 files changed

+124
-18
lines changed

6 files changed

+124
-18
lines changed

.github/workflows/pull_request.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,20 @@ jobs:
4848
steps:
4949
- name: Checkout repository
5050
uses: actions/checkout@v4
51-
- name: Install winget
52-
uses: Cyberboss/install-winget@main
51+
- name: Install node.js
52+
if: ${{ !vars.skip_nodejs_install }}
53+
run: powershell.exe -NoLogo -File $env:GITHUB_WORKSPACE\.github\workflows\scripts\windows\install-nodejs.ps1
54+
- name: Install Visual Studio Build Tools
55+
if: ${{ !vars.skip_vsb_install }}
56+
run: powershell.exe -NoLogo -File $env:GITHUB_WORKSPACE\.github\workflows\scripts\windows\install-vsb.ps1
57+
- name: Install Swift
58+
if: ${{ !vars.skip_swift_install }}
59+
run: powershell.exe -NoLogo -File $env:GITHUB_WORKSPACE\.github\workflows\scripts\windows\swift\install-swift-${{ matrix.swift_version }}.ps1
60+
- name: Check dependencies
61+
run: |
62+
swift --version
63+
node --version
5364
- name: Create test script
5465
run: |
55-
mkdir $env:TEMP\test-script
56-
echo 'Set-PSDebug -Trace 1' >> $env:TEMP\test-script\run.ps1
57-
echo '$ErrorActionPreference = "Stop"' >> $env:TEMP\test-script\run.ps1
58-
echo 'winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" --disable-interactivity --accept-source-agreements' >> $env:TEMP\test-script\run.ps1
59-
echo 'winget install --id Swift.Toolchain -e --disable-interactivity --accept-source-agreements' >> $env:TEMP\test-script\run.ps1
60-
echo 'winget install --id Schniz.fnm -e --disable-interactivity --accept-source-agreements' >> $env:TEMP\test-script\run.ps1
61-
echo 'Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1' >> $env:TEMP\test-script\run.ps1
62-
echo 'refreshenv' >> $env:TEMP\test-script\run.ps1
63-
echo 'fnm env --use-on-cd | Out-String | Invoke-Expression' >> $env:TEMP\test-script\run.ps1
64-
echo 'fnm use --install-if-missing 18.19.0' >> $env:TEMP\test-script\run.ps1
65-
echo 'swift --version' >> $env:TEMP\test-script\run.ps1
66-
echo 'node --version' >> $env:TEMP\test-script\run.ps1
67-
echo 'cd $env:GITHUB_WORKSPACE' >> $env:TEMP\test-script\run.ps1
68-
echo 'docker\test-windows.ps1' >> $env:TEMP\test-script\run.ps1
69-
powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1
66+
cd $env:GITHUB_WORKSPACE
67+
powershell.exe -NoLogo -File docker\test-windows.ps1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$NODEJS='https://nodejs.org/dist/v18.20.4/node-v18.20.4-x64.msi'
2+
$NODEJS_SHA256='c2654d3557abd59de08474c6dd009b1d358f420b8e4010e4debbf130b1dfb90a'
3+
Write-Host -NoNewLine ('Downloading {0} ... ' -f ${NODEJS})
4+
Invoke-WebRequest -Uri ${NODEJS} -OutFile $env:TEMP\node.msi
5+
Write-Host 'SUCCESS'
6+
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${NODEJS_SHA256})
7+
$Hash = Get-FileHash $env:TEMP\node.msi -Algorithm sha256
8+
if ($Hash.Hash -eq ${NODEJS_SHA256}) {
9+
Write-Host 'SUCCESS'
10+
} else {
11+
Write-Host ('FAILED ({0})' -f $Hash.Hash)
12+
exit 1
13+
}
14+
Write-Host -NoNewLine 'Installing node.js for Windows ... '
15+
$Process = Start-Process msiexec "/i $env:TEMP\node.msi /norestart /qn" -Wait -PassThru
16+
if ($Process.ExitCode -eq 0) {
17+
Write-Host 'SUCCESS'
18+
} else {
19+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
20+
exit 1
21+
}
22+
Remove-Item -Force $env:TEMP\node.msi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$VSB='https://aka.ms/vs/17/release/vs_buildtools.exe'
2+
$VSB_SHA256='99C7677154366062A43082921F40F3CE00EF2614DBF94DB23B244DD13DC9443D'
3+
Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB})
4+
Invoke-WebRequest -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe
5+
Write-Host 'SUCCESS'
6+
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256)
7+
$Hash = Get-FileHash $env:TEMP\vs_buildtools.exe -Algorithm sha256
8+
if ($Hash.Hash -eq $VSB_SHA256) {
9+
Write-Host 'SUCCESS'
10+
} else {
11+
Write-Host ('FAILED ({0})' -f $Hash.Hash)
12+
exit 1
13+
}
14+
Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... '
15+
$Process =
16+
Start-Process $env:TEMP\vs_buildtools.exe -Wait -PassThru -NoNewWindow -ArgumentList @(
17+
'--quiet',
18+
'--wait',
19+
'--norestart',
20+
'--nocache',
21+
'--add', 'Microsoft.VisualStudio.Component.Windows11SDK.22000',
22+
'--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64'
23+
)
24+
if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010) {
25+
Write-Host 'SUCCESS'
26+
} else {
27+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
28+
exit 1
29+
}
30+
Remove-Item -Force $env:TEMP\vs_buildtools.exe
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$SWIFT='https://download.swift.org/swift-5.10.1-release/windows10/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-windows10.exe'
2+
$SWIFT_SHA256='3027762138ACFA1BBE3050FF6613BBE754332E84C9EFA5C23984646009297286'
3+
Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:SWIFT})
4+
Invoke-WebRequest -Uri ${env:SWIFT} -OutFile installer.exe
5+
Write-Host 'SUCCESS'
6+
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:SWIFT_SHA256})
7+
$Hash = Get-FileHash installer.exe -Algorithm sha256
8+
if ($Hash.Hash -eq ${env:SWIFT_SHA256}) {
9+
Write-Host 'SUCCESS'
10+
} else {
11+
Write-Host ('FAILED ({0})' -f $Hash.Hash)
12+
exit 1
13+
}
14+
Write-Host -NoNewLine 'Installing Swift ... '
15+
$Process = Start-Process installer.exe -Wait -PassThru -NoNewWindow -ArgumentList @(
16+
'/quiet',
17+
'/norestart'
18+
)
19+
if ($Process.ExitCode -eq 0) {
20+
Write-Host 'SUCCESS'
21+
} else {
22+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
23+
exit 1
24+
}
25+
Remove-Item -Force installer.exe
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$SWIFT='https://download.swift.org/swift-6.0.2-release/windows10/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE-windows10.exe'
2+
$SWIFT_SHA256='516FE8E64713BD92F03C01E5198011B74A27F8C1C88627607A2F421718636126'
3+
Write-Host -NoNewLine ('Downloading {0} ... ' -f $SWIFT)
4+
Invoke-WebRequest -Uri $SWIFT -OutFile installer.exe
5+
Write-Host 'SUCCESS'
6+
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $SWIFT_SHA256)
7+
$Hash = Get-FileHash installer.exe -Algorithm sha256
8+
if ($Hash.Hash -eq $SWIFT_SHA256) {
9+
Write-Host 'SUCCESS'
10+
} else {
11+
Write-Host ('FAILED ({0})' -f $Hash.Hash)
12+
exit 1
13+
}
14+
Write-Host -NoNewLine 'Installing Swift ... '
15+
$Process = Start-Process installer.exe -Wait -PassThru -NoNewWindow -ArgumentList @(
16+
'/quiet',
17+
'/norestart'
18+
)
19+
if ($Process.ExitCode -eq 0) {
20+
Write-Host 'SUCCESS'
21+
} else {
22+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
23+
exit 1
24+
}
25+
Remove-Item -Force installer.exe

docker/test-windows.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ npm ci -ignore-script node-pty
44
npm run lint
55
npm run format
66
npm run package
7-
npm run integration-test
7+
$Process = Start-Process npm "run integration-test" -Wait -PassThru -NoNewWindow
8+
if ($Process.ExitCode -eq 0) {
9+
Write-Host 'SUCCESS'
10+
} else {
11+
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
12+
exit 1
13+
}

0 commit comments

Comments
 (0)