]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Run OSB tests with readonly source directory.
authorVladislav Shchapov <vladislav@shchapov.ru>
Sun, 26 Nov 2023 17:48:31 +0000 (22:48 +0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 11 Dec 2023 22:24:23 +0000 (23:24 +0100)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
.github/workflows/cmake.yml
test/cmake/compress-and-verify.cmake

index 80dc4bb3a9d7c06fe6812bd0d2b2619c6d99c60a..dfda736770848cd019020c3e7484f14488a79dcc 100644 (file)
@@ -51,6 +51,8 @@ jobs:
             cxx-compiler: g++
             build-dir: ../build
             build-src-dir: ../zlib-ng
+            # Build with readonly project directory require CMake 3.19+
+            readonly-project-dir: true
             codecov: ubuntu_gcc_osb
             cflags: -O3
 
@@ -60,6 +62,7 @@ jobs:
             cxx-compiler: g++
             build-dir: ../build
             build-src-dir: ../zlib-ng/test/add-subdirectory-project
+            readonly-project-dir: true
 
           - name: Ubuntu GCC -O1 No Unaligned UBSAN
             os: ubuntu-latest
@@ -598,6 +601,11 @@ jobs:
         CC: ${{ matrix.compiler }}
         CXX: ${{ matrix.cxx-compiler }}
 
+    - name: Make source tree read-only
+      shell: bash
+      run: chmod -R a-w .
+      if: matrix.readonly-project-dir
+
     - name: Generate project files
       shell: bash
       # Shared libraries turned off for qemu ppc* and sparc & reduce code coverage sources
@@ -630,6 +638,11 @@ jobs:
         LSAN_OPTIONS: ${{ matrix.lsan-options || 'verbosity=0' }}:abort_on_error=1:halt_on_error=1
         UBSAN_OPTIONS: ${{ matrix.ubsan-options || 'verbosity=0' }}:print_stacktrace=1:abort_on_error=1:halt_on_error=1
 
+    - name: Make source tree writable
+      shell: bash
+      run: chmod -R +w .
+      if: matrix.readonly-project-dir
+
     - name: Generate coverage report
       if: matrix.codecov
       shell: bash
index d2d9917a93fe9e99004acb6d18c191d8c4282fa0..2e6c37f145117365d8f2dda782f2ff39d3f118cb 100644 (file)
@@ -138,7 +138,11 @@ set(COMPRESS_COMMAND ${COMPRESS_TARGET} ${COMPRESS_ARGS})
 set(INPUT_FILE ${OUTPUT_BASE})
 
 # Make CMake copy and rename file in one operation
-configure_file(${INPUT} ${INPUT_FILE} COPYONLY)
+# The copied file permissions is standard 644 (-rw-r--r--)
+if(NOT CMAKE_VERSION VERSION_LESS "3.19")
+    set(CONFIGURE_NO_SOURCE_PERMISSIONS NO_SOURCE_PERMISSIONS)
+endif()
+configure_file(${INPUT} ${INPUT_FILE} COPYONLY ${CONFIGURE_NO_SOURCE_PERMISSIONS})
 
 message(STATUS "Compress ${COMPRESS_COMMAND}")
 message(STATUS "  Source file: ${INPUT}")