Skip to content

Commit eb3a040

Browse files
committed
Added windows 22
1 parent 69d8718 commit eb3a040

File tree

3 files changed

+106
-7
lines changed

3 files changed

+106
-7
lines changed

.github/workflows/build-test-windows.yml

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,76 @@ name: build-test-windows
33
on:
44
push:
55
paths:
6-
- "**/windows/Dockerfile"
6+
- "**/windows-2019/Dockerfile"
7+
- "**/windows-2022/Dockerfile"
78
- ".github/workflows/build-test-windows.yml"
89

910
pull_request:
1011
paths:
11-
- "**/windows/Dockerfile"
12-
- genMatrix.js
12+
- "**/windows-2019/Dockerfile"
13+
- "**/windows-2022/Dockerfile"
1314
- ".github/workflows/build-test-windows.yml"
1415

1516
jobs:
16-
build:
17-
name: build
17+
build-windows-2019:
18+
name: build-windows-2019
1819
runs-on: windows-2019
1920
timeout-minutes: 60
2021
strategy:
2122
fail-fast: false
2223
matrix:
23-
version: [ 22 ]
24-
variant: [ "windows" ]
24+
version: [ "22.7.0" ]
25+
variant: [ "windows-2019" ]
26+
27+
steps:
28+
- name: Get short node version
29+
uses: actions/github-script@v7
30+
id: short-version
31+
with:
32+
result-encoding: string
33+
script: return "${{ matrix.version }}".split('.')[0]
34+
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Build image
39+
run: |
40+
docker build --file ./${{ steps.short-version.outputs.result }}/${{ matrix.variant }}/Dockerfile --tag node:${{ matrix.version }}-${{ matrix.variant }} .
41+
42+
- name: Test for node version
43+
shell: pwsh
44+
run: |
45+
$image_node_version = (docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} node --print "process.versions.node")
46+
Write-Host "Expected: '${{ matrix.version }}', Got: '$image_node_version'"
47+
if ($image_node_version -ne ${{ matrix.version }}) {
48+
exit 1
49+
}
50+
51+
- name: Verify entrypoint runs regular, non-executable files with node
52+
shell: pwsh
53+
run: |
54+
$tmp_file = New-TemporaryFile
55+
"console.log('success')" | Out-File -FilePath $tmp_file -Encoding utf8
56+
$output = (docker run --rm -v "${{ github.workspace }}\$tmp_file:/app/index.js" node:${{ matrix.version }}-${{ matrix.variant }} app/index.js)
57+
if ($output -ne 'success') {
58+
exit 1
59+
}
60+
61+
- name: Test for npm
62+
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version
63+
64+
- name: Test for yarn
65+
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version
66+
67+
build-windows-2022:
68+
name: build-windows-2022
69+
runs-on: windows-2022
70+
timeout-minutes: 60
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
version: [ "22.7.0" ]
75+
variant: [ "windows-2022" ]
2576

2677
steps:
2778
- name: Get short node version
File renamed without changes.

22/windows-2022/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM mcr.microsoft.com/windows/servercore:ltsc2022
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
4+
5+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6+
RUN $newPath = ('C:\nodejs;{0}\Yarn\bin;{1}' -f $env:LOCALAPPDATA, $env:PATH); \
7+
Write-Host ('Updating PATH: {0}' -f $newPath); \
8+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
9+
# doing this first to share cache across versions more aggressively
10+
11+
ENV NODE_VERSION 22.7.0
12+
ENV NODE_SHA256 3fc638727974262b4f65a6b1b43c22fb2d80671cdcb50e1237e0b05d1330aaf7
13+
14+
RUN $url = ('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION); \
15+
Write-Host ('Downloading {0} ...' -f $url); \
16+
Invoke-WebRequest -Uri $url -OutFile 'node.zip'; \
17+
\
18+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:NODE_SHA256); \
19+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_SHA256) { throw 'SHA256 mismatch' }; \
20+
\
21+
Write-Host 'Expanding ...'; \
22+
Expand-Archive node.zip -DestinationPath C:\; \
23+
\
24+
Write-Host 'Renaming ...'; \
25+
Rename-Item -Path ('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; \
26+
\
27+
Write-Host 'Removing ...'; \
28+
Remove-Item node.zip -Force; \
29+
\
30+
Write-Host 'Verifying ("node --version") ...'; \
31+
node --version; \
32+
Write-Host 'Verifying ("npm --version") ...'; \
33+
npm --version; \
34+
\
35+
Write-Host 'Complete.'
36+
37+
ENV YARN_VERSION 1.22.17
38+
39+
# "It is recommended to install Yarn through the npm package manager" (https://classic.yarnpkg.com/en/docs/install)
40+
RUN Write-Host 'Installing "yarn" ...'; \
41+
npm install --global ('yarn@{0}' -f $env:YARN_VERSION); \
42+
\
43+
Write-Host 'Verifying ("yarn --version") ...'; \
44+
yarn --version; \
45+
\
46+
Write-Host 'Complete.'
47+
48+
CMD [ "node" ]

0 commit comments

Comments
 (0)