44 push :
55 branches : [ "master" ]
66 pull_request :
7+ branches : [ "master" ]
78 types : [ "opened", "reopened", "synchronize", "ready_for_review" ]
89
910jobs :
1011 build :
1112 runs-on : ${{ matrix.os }}
1213
1314 strategy :
14- fail-fast : false # ensure we don't stop after 1 failure to always have a complete picture of what is failing
15+ # ensure we don't stop after 1 failure to always have a complete picture of what is failing
16+ fail-fast : false
1517
1618 # Set up a matrix to run the following configurations:
1719 # - ubuntu Debug/Release clang/gcc
1820 # - windows Debug/Release cl
1921 # - macos Debug/Release clang
2022 matrix :
21- os : [ubuntu-latest, macos-latest] # , windows-latest
23+ os : [ubuntu-latest, macos-latest, windows-latest]
2224 build_type : [Release, Debug]
2325 c_compiler : [gcc, clang, cl]
2426 include :
25- # - os: windows-latest
26- # c_compiler: cl
27- # cpp_compiler: cl
27+ - os : windows-latest
28+ c_compiler : cl
29+ cpp_compiler : cl
2830 - os : ubuntu-latest
2931 c_compiler : gcc
3032 cpp_compiler : g++
@@ -47,47 +49,82 @@ jobs:
4749 c_compiler : gcc
4850
4951 steps :
50- - uses : actions/checkout@v3
51-
52- - name : Set reusable strings
53- # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
54- id : strings
55- shell : bash
56- run : |
57- echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
58-
59- - name : Cache VCPKG (Windows)
60- if : runner.os == 'Windows'
61- uses : actions/cache@v3
62- with :
63- path : ${{ env.VCPKG_ROOT }}
64- key : ${{ runner.os }}-${{ matrix.build_type }}-${{ hashFiles('vcpkg.json') }}
65-
66- - name : Install OpenSSL (Windows)
67- if : runner.os == 'Windows'
68- shell : powershell
69- run : |
70- echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
71- echo "CMAKE_TOOLCHAIN_FILE=${env:VCPKG_INSTALLATION_ROOT}\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
72- vcpkg install
73-
74- - name : Configure CMake
75- # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
76- # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
77- run : >
78- cmake -B ${{ steps.strings.outputs.build-output-dir }}
79- -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
80- -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
81- -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
82- -DCPPSOCKETS_TESTS=TRUE
83- -S ${{ github.workspace }}
84-
85- - name : Build
86- # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
87- run : cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
88-
89- - name : Test
90- working-directory : ${{ steps.strings.outputs.build-output-dir }}
91- # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
92- # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
93- run : ctest --build-config ${{ matrix.build_type }} --test-dir tests
52+ - uses : actions/checkout@v3
53+
54+ - name : Set Env
55+ shell : bash
56+ run : |
57+ echo "VCPKG_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV"
58+ echo "BUILD_OUTPUT_DIR=${{ github.workspace }}/build" >> "$GITHUB_ENV"
59+
60+ - name : Fetch VCPKG Cache (Windows)
61+ id : fetch-vcpkg-cache
62+ if : runner.os == 'Windows'
63+ uses : actions/cache/restore@v4
64+ with :
65+ key : ${{ runner.os }}-${{ matrix.build_type }}-${{ hashFiles('vcpkg.json') }}
66+ path : ${{ env.VCPKG_ROOT }}
67+
68+ - name : Install OpenSSL (Windows)
69+ if : runner.os == 'Windows'
70+ shell : powershell
71+ run : |
72+ echo "CMAKE_TOOLCHAIN_FILE=${env:VCPKG_ROOT}\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
73+ vcpkg install
74+
75+ - name : Always Save VCPKG Cache (Windows)
76+ if : always() && runner.os == 'Windows' && steps.fetch-vcpkg-cache.outputs.cache-hit != 'true'
77+ uses : actions/cache/save@v4
78+ with :
79+ key : ${{ steps.fetch-vcpkg-cache.outputs.cache-primary-key }}
80+ path : ${{ env.VCPKG_ROOT }}
81+
82+ - name : Configure CMake
83+ # Configure CMake in a 'build' subdirectory.
84+ # `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
85+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
86+ run : >
87+ cmake -B ${{ env.BUILD_OUTPUT_DIR }}
88+ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
89+ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
90+ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
91+ -DCPPSOCKETS_TESTS=TRUE
92+ -S ${{ github.workspace }}
93+
94+ - name : Build
95+ # Build your program with the given configuration. Note that --config is needed
96+ # because the default Windows generator is a multi-config generator (Visual Studio generator).
97+ run : cmake --build ${{ env.BUILD_OUTPUT_DIR }} --config ${{ matrix.build_type }}
98+
99+ - uses : actions/upload-artifact@v4
100+ if : matrix.os == 'ubuntu-latest' && matrix.build_type == 'Release' && matrix.c_compiler == 'clang'
101+ with :
102+ name : compile_commands.json
103+ path : ${{ env.BUILD_OUTPUT_DIR }}/compile_commands.json
104+
105+ - name : Test
106+ working-directory : ${{ env.BUILD_OUTPUT_DIR }}
107+ # Execute tests defined by the CMake configuration. Note that --build-config is needed
108+ # because the default Windows generator is a multi-config generator (Visual Studio generator).
109+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
110+ run : ctest --build-config ${{ matrix.build_type }} --test-dir tests --output-on-failure
111+
112+ clang-tidy :
113+ needs : ' build'
114+ runs-on : ubuntu-latest
115+ if : always()
116+
117+ steps :
118+ - name : Checkout Code
119+ uses : actions/checkout@v4
120+
121+ - uses : actions/download-artifact@v4
122+ with :
123+ name : compile_commands.json
124+
125+ - name : clang-tidy review
126+ uses : ZedThree/clang-tidy-review@v0.21.0
127+
128+ # If there are any comments, fail the check
129+ - if : steps.review.outputs.total_comments > 0
130+ run : exit 1
0 commit comments