# Copyright (c) 2023 Ribose Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. name: windows-native on: push: branches: - main - 'release/**' paths-ignore: - '/*.sh' - '/.*' - '/_*' - 'Brewfile' - 'docs/**' - '**.adoc' - '**.md' - '**.nix' - 'flake.lock' - '.github/workflows/*.yml' - '!.github/workflows/windows-native.yml' pull_request: paths-ignore: - '/*.sh' - '/.*' - '/_*' - 'Brewfile' - 'docs/**' - '**.adoc' - '**.md' - '**.nix' - 'flake.lock' concurrency: group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}' cancel-in-progress: true env: VCPKG_DIR: C:/vcpkg VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}\cache RNP_TEST_DATA: ${{github.workspace}}\src\tests\data jobs: build_and_test: name: Windows-2019 [arch ${{ matrix.arch.name }}, toolset ${{ matrix.toolset }}, backend ${{ matrix.backend }}, build shared libs ${{ matrix.shared_libs }}, use CMake prefix path ${{ matrix.use_cmake_prefix_path }}] runs-on: windows-2019 if: "!contains(github.event.head_commit.message, 'skip ci')" strategy: fail-fast: false matrix: arch: [ { name: 'x64', triplet: 'x64-windows' } ] toolset: [ 'v142', 'ClangCL' ] backend: [ 'botan', 'openssl' ] shared_libs: [ 'on', 'off'] use_cmake_prefix_path: [ 'off' ] include: - arch: { name: 'x64', triplet: 'x64-windows' } toolset: 'ClangCL' backend: 'openssl' use_cmake_prefix_path: 'on' shared_libs: 'on' - arch: { name: 'x64', triplet: 'x64-windows' } toolset: 'ClangCL' backend: 'openssl' use_cmake_prefix_path: 'on' shared_libs: 'off' - arch: { name: 'Win32', triplet: 'x86-windows' } toolset: 'ClangCL' backend: 'botan' use_cmake_prefix_path: 'off' shared_libs: 'on' - arch: { name: 'Win32', triplet: 'x86-windows' } toolset: 'v142' backend: 'openssl' use_cmake_prefix_path: 'off' shared_libs: 'off' steps: - name: Checkout uses: actions/checkout@v3 with: submodules: true lfs: true fetch-depth: 1 - name: vcpkg parameters run: | vcpkg version >> vcpkg.version mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - name: vcpkg cache uses: actions/cache@v3 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} key: vcpkg-${{ hashFiles('vcpkg.version') }}-${{ matrix.arch.triplet }}-${{ matrix.toolset }}-${{ matrix.backend }} - name: vcpkg packages shell: bash run: vcpkg install --triplet ${{ matrix.arch.triplet }} bzip2 zlib json-c getopt dirent ${{ matrix.backend }} - name: Set OPENSSL_ROOT_DIR # Ensure consistent access to openssl installation for test_backend_version test # There is another one instance of ssl at /mingw and /mingw/bin is always at the first position at PATH if: matrix.backend == 'openssl' shell: bash run: echo OPENSSL_ROOT_DIR=${{ env.VCPKG_DIR }}/installed >> $GITHUB_ENV - name: Adjust settings for s2k_iteration_tuning test # This step adjusts s2k_iteration_tuning threshold for # s2k_iteration_tuning test (src/tests/cipher.cpp) # It looks like cl on Win32 does not provide robust response if: matrix.arch.name == 'Win32' && matrix.toolset == 'ClangCL' shell: bash run: echo CXXFLAGS="-DS2K_MINIMUM_TUNING_RATIO=4" >> $GITHUB_ENV - name: Configure using vpkg toolchain file if: matrix.use_cmake_prefix_path != 'on' shell: bash run: | echo CORES="$(nproc --all)" >> $GITHUB_ENV cmake -B build -G "Visual Studio 16 2019" \ -A ${{ matrix.arch.name }} \ -T ${{ matrix.toolset }} \ -DBUILD_SHARED_LIBS=${{ matrix.shared_lib}} \ -DCRYPTO_BACKEND=${{ matrix.backend }} \ -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_DIR }}/scripts/buildsystems/vcpkg.cmake . - name: Configure using CMake prefix path if: matrix.use_cmake_prefix_path == 'on' shell: bash run: | echo CORES="$(nproc --all)" >> $GITHUB_ENV cmake -B build -G "Visual Studio 16 2019" \ -A ${{ matrix.arch.name }} \ -T ${{ matrix.toolset }} \ -DBUILD_SHARED_LIBS=${{ matrix.shared_lib}} \ -DCRYPTO_BACKEND=${{ matrix.backend }} \ -DCMAKE_PREFIX_PATH=${{ env.VCPKG_DIR }}/installed/${{ matrix.arch.triplet }} . echo ${{ env.VCPKG_DIR }}/installed/${{ matrix.arch.triplet }}/bin >> $GITHUB_PATH - name: Compile shell: bash run: cmake --build build --config "Release" --parallel ${{ env.CORES }} - name: Test shell: bash # Sometimes running cli_tests in parallel causes instability [???] # ctest --test-dir build -R cli_tests -C Debug --output-on-failure # ctest --parallel ${{ env.CORES }} --test-dir build -R rnp_tests -C Debug --output-on-failure run: | mkdir -p "build/Testing/Temporary" cp "cmake/CTestCostData.txt" "build/Testing/Temporary" ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure