]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
CI: Add VS2019 build jobs (#757)
authorNicholas Hutchinson <nshutchinson@gmail.com>
Wed, 6 Jan 2021 18:53:16 +0000 (18:53 +0000)
committerGitHub <noreply@github.com>
Wed, 6 Jan 2021 18:53:16 +0000 (19:53 +0100)
Add VS2019 build jobs that use clang for the test suite. There are many
test failures on Windows, but these are ignored for now.

Tweak CMake build scripts:
- Fix CI build type handling for MSVC (recognise `/NDEBUG` and not just
  `-DNDEBUG`)
- Fix incorrect warnings-as-errors flag for MSVC
- Suppress an additional conversion warning on MSVC

.github/workflows/build.yaml
cmake/CIBuildType.cmake
cmake/DevModeWarnings.cmake

index 5e5ee8ae2e8f82a4bd57d705e375fd70d7863ace..a5cbadd6dd19940d1e4e07baac87a7475114f1a3 100644 (file)
@@ -7,6 +7,10 @@ env:
   CTEST_OUTPUT_ON_FAILURE: ON
   VERBOSE: 1
 
+defaults:
+  run:
+    shell: bash
+
 jobs:
   build_and_test:
     env:
@@ -191,6 +195,30 @@ jobs:
             RUN_TESTS: unittest-in-wine
             apt_get: elfutils mingw-w64 wine
 
+          - name: Windows VS2019 32-bit
+            os: windows-2019
+            msvc_arch: x64_x86
+            allow_test_failures: true  # For now, don't fail the build on failure
+            CC: cl
+            CXX: cl
+            ENABLE_CACHE_CLEANUP_TESTS: 1
+            CMAKE_GENERATOR: Ninja
+            CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=CI -DZSTD_FROM_INTERNET=ON
+            # -mno-incremental-linker-compatible: reproducible object files
+            TEST_CC: clang -target i686-pc-windows-msvc -mno-incremental-linker-compatible
+
+          - name: Windows VS2019 64-bit
+            os: windows-2019
+            msvc_arch: x64
+            allow_test_failures: true  # For now, don't fail the build on failure
+            CC: cl
+            CXX: cl
+            ENABLE_CACHE_CLEANUP_TESTS: 1
+            CMAKE_GENERATOR: Ninja
+            CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=CI -DZSTD_FROM_INTERNET=ON
+            # -mno-incremental-linker-compatible: reproducible object files
+            TEST_CC: clang -target x86_64-pc-windows-msvc -mno-incremental-linker-compatible
+
           - name: Clang address & UB sanitizer
             os: ubuntu-20.04
             CC: clang
@@ -258,13 +286,38 @@ jobs:
         if: matrix.config.apt_get != ''
         run: sudo apt-get update && sudo apt-get install ${{ matrix.config.apt_get }}
 
+      - name: Prepare Windows Environment (Visual Studio)
+        if: runner.os == 'Windows'
+        uses: ilammy/msvc-dev-cmd@v1.5.0
+        with:
+          arch: ${{ matrix.config.msvc_arch }}
+
+      - name: Prepare Windows Environment (Clang)
+        if: runner.os == 'Windows'
+        shell: powershell
+        run: |
+          $ErrorActionPreference = 'Stop'
+
+          # The test suite currently requires that the compiler specified by the "CC"
+          # env variable is on a path without spaces. Provide that by creating a
+          # junction from ~/opt/llvm to the Visual Studio path.
+          $null = New-Item `
+            -Path "${HOME}\opt\llvm" `
+            -ItemType Junction `
+            -Target "${env:VCINSTALLDIR}\Tools\Llvm\x64" `
+            -Force
+          "Path=${HOME}\opt\llvm\bin;${env:Path}" | `
+            Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+
       - name: Build and test
+        id: build-and-test
         env:
           ASAN_OPTIONS: ${{ matrix.config.ASAN_OPTIONS }}
           BUILDDIR: ${{ matrix.config.BUILDDIR }}
           CC: ${{ matrix.config.CC }}
           CCACHE_LOC: ${{ matrix.config.CCACHE_LOC }}
           CFLAGS: ${{ matrix.config.CFLAGS }}
+          CMAKE_GENERATOR: ${{ matrix.config.CMAKE_GENERATOR }}
           CMAKE_PARAMS: ${{ matrix.config.CMAKE_PARAMS }}
           CXX: ${{ matrix.config.CXX }}
           CXXFLAGS: ${{ matrix.config.CXXFLAGS }}
@@ -273,15 +326,23 @@ jobs:
           LDFLAGS: ${{ matrix.config.LDFLAGS }}
           RUN_TESTS: ${{ matrix.config.RUN_TESTS }}
           SPECIAL: ${{ matrix.config.SPECIAL }}
-        run: ci/build
+          TEST_CC: ${{ matrix.config.TEST_CC }}
+        run: |
+          rc=0
+          ci/build || rc=$?
+          echo "::set-output name=exit_status::$rc"
+          exit $rc
+        # Ctest exits with a return code of `8` on test failure.
+        continue-on-error: ${{ matrix.config.allow_test_failures == true &&
+          steps.build-and-test.outputs.exit_status == 8 }}
 
       - name: Collect testdir from failed tests
-        if: failure()
+        if: failure() || steps.build-and-test.outcome == 'failure'
         run: ci/collect-testdir
         # TODO: in case of build-and-verify-*package the BUILDDIR is set within those scripts.
 
       - name: Upload testdir from failed tests
-        if: failure()
+        if: failure() || steps.build-and-test.outcome == 'failure'
         uses: actions/upload-artifact@v2
         with:
           name: ${{ matrix.config.name }} - testdir.tar.xz
index 963bc5007b13c323a429b437cac7f68e73a8ce0c..e72161414d2c95058c973ebc55b2029c0e7d9b18 100644 (file)
@@ -25,7 +25,7 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
   "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel CI."
   FORCE)
 
-string(REPLACE -DNDEBUG "" CMAKE_CXX_FLAGS_CI ${CMAKE_CXX_FLAGS_CI})
-string(REPLACE -DNDEBUG "" CMAKE_C_FLAGS_CI ${CMAKE_C_FLAGS_CI})
+string(REGEX REPLACE "[/-]DNDEBUG" "" CMAKE_CXX_FLAGS_CI ${CMAKE_CXX_FLAGS_CI})
+string(REGEX REPLACE "[/-]DNDEBUG" "" CMAKE_C_FLAGS_CI ${CMAKE_C_FLAGS_CI})
 string(STRIP ${CMAKE_CXX_FLAGS_CI} CMAKE_CXX_FLAGS_CI)
 string(STRIP ${CMAKE_C_FLAGS_CI} CMAKE_C_FLAGS_CI)
index f578a9bcb7bd63738b959efd6c745bc6c5295ae1..7ff5411b89acd3ff7f47026b557c8d758f27323b 100644 (file)
@@ -115,7 +115,7 @@ elseif(MSVC)
   string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 
   if(WARNINGS_AS_ERRORS)
-    list(APPEND CCACHE_COMPILER_WARNINGS /WE)
+    list(APPEND CCACHE_COMPILER_WARNINGS /WX)
   endif()
 
   list(
@@ -126,6 +126,7 @@ elseif(MSVC)
     /wd5105
     # Conversion warnings:
     /wd4244
+    /wd4245
     /wd4267
     # Assignment in conditional:
     /wd4706