1# Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
2#
3# Licensed under the Apache License 2.0 (the "License").  You may not use
4# this file except in compliance with the License.  You can obtain a copy
5# in the file LICENSE in the source distribution or at
6# https://www.openssl.org/source/license.html
7
8name: Windows Compression GitHub CI
9
10on:
11  pull_request:
12    paths:
13      - 'crypto/comp/*.c'
14      - '.github/workflows/windows_comp.yml'
15  push:
16    paths:
17      - '**.c'
18
19permissions:
20  contents: read
21
22jobs:
23  zstd:
24    runs-on: windows-latest
25    steps:
26    - uses: actions/checkout@v4
27    - name: checkout fuzz/corpora submodule
28      run: git submodule update --init --depth 1 fuzz/corpora
29    - uses: ilammy/msvc-dev-cmd@v1
30    - uses: ilammy/setup-nasm@v1
31    - name: prepare the build directory
32      run: mkdir _build
33    - name: Get zstd
34      working-directory: _build
35      run: |
36        vcpkg install zstd:x64-windows
37    - name: config
38      working-directory: _build
39      run: |
40        perl ..\Configure enable-comp enable-zstd --with-zstd-include=C:\vcpkg\packages\zstd_x64-windows\include --with-zstd-lib=C:\vcpkg\packages\zstd_x64-windows\lib\zstd.lib no-makedepend -DOSSL_WINCTX=openssl VC-WIN64A
41        perl configdata.pm --dump
42    - name: build
43      working-directory: _build
44      run: nmake
45    - name: Gather openssl version info
46      working-directory: _build
47      run: |
48        $env:Path+=";C:\vcpkg\packages\zstd_x64-windows\bin"
49        apps/openssl.exe version -v
50        apps/openssl.exe version -v | %{($_ -split '\s+')[1]}
51        apps/openssl.exe version -v | %{($_ -split '\s+')[1] -replace '([0-9]+\.[0-9]+)(\..*)','$1'}
52        echo "OSSL_VERSION=$(apps/openssl.exe version -v | %{($_ -split '\s+')[1] -replace '([0-9]+\.[0-9]+)(\..*)','$1'})" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
53    - name: Set registry keys
54      working-directory: _build
55      run: |
56        echo ${Env:OSSL_VERSION}
57        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v OPENSSLDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
58        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v ENGINESDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
59        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v MODULESDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
60        reg.exe query HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v OPENSSLDIR /reg:32
61    - name: download coreinfo
62      uses: suisei-cn/actions-download-file@v1.6.0
63      with:
64        url: "https://download.sysinternals.com/files/Coreinfo.zip"
65        target: _build/coreinfo/
66    - name: get cpu info
67      working-directory: _build
68      continue-on-error: true
69      run: |
70        $env:Path+=";C:\vcpkg\packages\zstd_x64-windows\bin"
71        7z.exe x coreinfo/Coreinfo.zip
72        ./Coreinfo64.exe -accepteula -f
73        ./apps/openssl.exe version -c
74    - name: Check platform symbol usage
75      run: |
76        perl ./util/checkplatformsyms.pl ./util/platform_symbols/windows-symbols.txt libcrypto-3-x64.dll ./libssl-3-x64.dll
77    - name: test
78      working-directory: _build
79      run: |
80        $env:Path+=";C:\vcpkg\packages\zstd_x64-windows\bin"
81        nmake test VERBOSE_FAILURE=yes TESTS="-test_fuzz* -test_fipsload" HARNESS_JOBS=4
82  brotli:
83    runs-on: windows-latest
84    steps:
85    - uses: actions/checkout@v4
86    - name: checkout fuzz/corpora submodule
87      run: git submodule update --init --depth 1 fuzz/corpora
88    - uses: ilammy/msvc-dev-cmd@v1
89    - uses: ilammy/setup-nasm@v1
90    - name: prepare the build directory
91      run: mkdir _build
92    - name: Get brotli
93      working-directory: _build
94      run: |
95        vcpkg install brotli:x64-windows
96    - name: config
97      working-directory: _build
98      run: |
99        perl ..\Configure enable-comp enable-brotli --with-brotli-include=C:\vcpkg\packages\brotli_x64-windows\include --with-brotli-lib=C:\vcpkg\packages\brotli_x64-windows\lib no-makedepend -DOSSL_WINCTX=openssl VC-WIN64A
100        perl configdata.pm --dump
101    - name: build
102      working-directory: _build
103      run: nmake
104    - name: Gather openssl version info
105      working-directory: _build
106      run: |
107        $env:Path+=";C:\vcpkg\packages\brotli_x64-windows\bin"
108        apps/openssl.exe version -v
109        apps/openssl.exe version -v | %{($_ -split '\s+')[1]}
110        apps/openssl.exe version -v | %{($_ -split '\s+')[1] -replace '([0-9]+\.[0-9]+)(\..*)','$1'}
111        echo "OSSL_VERSION=$(apps/openssl.exe version -v | %{($_ -split '\s+')[1] -replace '([0-9]+\.[0-9]+)(\..*)','$1'})" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
112    - name: Set registry keys
113      working-directory: _build
114      run: |
115        echo ${Env:OSSL_VERSION}
116        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v OPENSSLDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
117        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v ENGINESDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
118        reg.exe add HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v MODULESDIR /t REG_EXPAND_SZ /d TESTOPENSSLDIR /reg:32
119        reg.exe query HKLM\SOFTWARE\OpenSSL-${Env:OSSL_VERSION}-openssl /v OPENSSLDIR /reg:32
120    - name: download coreinfo
121      uses: suisei-cn/actions-download-file@v1.6.0
122      with:
123        url: "https://download.sysinternals.com/files/Coreinfo.zip"
124        target: _build/coreinfo/
125    - name: get cpu info
126      working-directory: _build
127      continue-on-error: true
128      run: |
129        $env:Path+=";C:\vcpkg\packages\brotli_x64-windows\bin"
130        7z.exe x coreinfo/Coreinfo.zip
131        ./Coreinfo64.exe -accepteula -f
132        ./apps/openssl.exe version -c
133    - name: test
134      working-directory: _build
135      run: |
136        $env:Path+=";C:\vcpkg\packages\brotli_x64-windows\bin"
137        nmake test VERBOSE_FAILURE=yes TESTS="-test_fuzz* -test_fipsload" HARNESS_JOBS=4
138