From 657a82ee9f70899eae04d21be382facf6deb950d Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 12:34:58 +0700 Subject: [PATCH 1/6] fix missing `CHECK_SUPASS_WARNING` in `additional-flags-uasage` job --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e51b54a..5fa73b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,6 +52,7 @@ jobs: targets: test_c test_cpp c-flags: -Wno-unused-variable cxx-flags: -Wno-unused-variable + args: -D CHECK_SURPASS_WARNING=ON - name: Run the build results run: build/test_c && build/test_cpp From 250f59da815a35529395041f2b62adf129cb4e81 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 12:46:36 +0700 Subject: [PATCH 2/6] run `additional-flags-usage` job on both GCC and MSVC --- .github/workflows/test.yml | 9 ++++++--- test/CMakeLists.txt | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5fa73b6..0a1ddd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,10 @@ jobs: run: test ! -d build additional-flags-usage: - runs-on: ubuntu-latest + runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest + strategy: + matrix: + compiler: [gcc, msvc] steps: - name: Check out this repository uses: actions/checkout@v3.3.0 @@ -50,8 +53,8 @@ jobs: with: source-dir: test targets: test_c test_cpp - c-flags: -Wno-unused-variable - cxx-flags: -Wno-unused-variable + c-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }} + cxx-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }} args: -D CHECK_SURPASS_WARNING=ON - name: Run the build results diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 434f472..1f6ccca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,8 +5,13 @@ option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF) option(CHECK_SURPASS_WARNING "check if target could surpass a compiler warning" OFF) if(CHECK_SURPASS_WARNING) - set(CMAKE_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}") + if(MSVC) + set(CMAKE_C_FLAGS "/WX /W4 ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "/WX /W4 ${CMAKE_CXX_FLAGS}") + else() + set(CMAKE_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}") + endif() endif() add_executable(hello_world hello_world.cpp) From 8da16854fcdc8f617ad5af70e31a0d2ccce1f1cf Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 12:51:31 +0700 Subject: [PATCH 3/6] guard most input values with single quotation --- action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 97eff0d..40d0287 100644 --- a/action.yml +++ b/action.yml @@ -41,25 +41,25 @@ runs: id: process_inputs shell: bash run: | - ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}" - BUILD_ARGS="--build ${{ inputs.build-dir }}" + ARGS="'${{ inputs.source-dir }}' -B '${{ inputs.build-dir }}'" + BUILD_ARGS="--build '${{ inputs.build-dir }}'" if [ -n '${{ inputs.targets }}' ]; then BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}" fi if [ -n '${{ inputs.generator }}' ]; then - ARGS="$ARGS -G ${{ inputs.generator }}" + ARGS="$ARGS -G '${{ inputs.generator }}'" fi if [ -n '${{ inputs.c-compiler }}' ]; then - ARGS="$ARGS -D CMAKE_C_COMPILER=${{ inputs.c-compiler }}" + ARGS="$ARGS -D CMAKE_C_COMPILER='${{ inputs.c-compiler }}'" fi if [ -n '${{ inputs.cxx-compiler }}' ]; then - ARGS="$ARGS -D CMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }}" + ARGS="$ARGS -D CMAKE_CXX_COMPILER='${{ inputs.cxx-compiler }}'" fi if [ -n '${{ inputs.c-flags }}' ]; then - ARGS="$ARGS -D CMAKE_C_FLAGS=${{ inputs.c-flags }}" + ARGS="$ARGS -D CMAKE_C_FLAGS='${{ inputs.c-flags }}'" fi if [ -n '${{ inputs.cxx-flags }}' ]; then - ARGS="$ARGS -D CMAKE_CXX_FLAGS=${{ inputs.cxx-flags }}" + ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'" fi if [ -n '${{ inputs.args }}' ]; then ARGS="$ARGS ${{ inputs.args }}" From 6548c2aab5d0d3af47595bd65cae5f76bbae704f Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 13:01:24 +0700 Subject: [PATCH 4/6] specify shell to use PowerShell on Windows --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 40d0287..af61157 100644 --- a/action.yml +++ b/action.yml @@ -78,9 +78,9 @@ runs: esac - name: Configure the CMake project - shell: bash + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: cmake ${{ steps.process_inputs.outputs.cmake_args }} - name: Build targets - shell: bash + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }} From 716f237b518d36f29c5c8aeae89fea02e34221bc Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 13:06:32 +0700 Subject: [PATCH 5/6] disable warning as error on MSVC test --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a1ddd0..664d181 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,8 +53,8 @@ jobs: with: source-dir: test targets: test_c test_cpp - c-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }} - cxx-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }} + c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }} + cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }} args: -D CHECK_SURPASS_WARNING=ON - name: Run the build results From c51d734eb9b1f820ee89c94ab6bef0254b085c99 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 13:07:40 +0700 Subject: [PATCH 6/6] fix build results location on MSVC test --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 664d181..442a728 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,7 +58,9 @@ jobs: args: -D CHECK_SURPASS_WARNING=ON - name: Run the build results - run: build/test_c && build/test_cpp + run: | + ${{ matrix.compiler == 'msvc' && 'build\Debug\test_c.exe' || 'build/test_c' }} + ${{ matrix.compiler == 'msvc' && 'build\Debug\test_cpp.exe' || 'build/test_cpp' }} specified-compiler-usage: runs-on: ${{ matrix.os }}-latest