From 4e9aeec1364ad25f37db7bedaf0c37417842333f Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 7 Nov 2024 12:37:19 -0800 Subject: [PATCH] Add GitHub Actions to project to validate PRs (#145) --- .github/dependabot.yml | 6 +++ .github/workflows/codeql.yml | 57 +++++++++++++++++++++++++ .github/workflows/main.yml | 83 ++++++++++++++++++++++++++++++++++++ .github/workflows/msvc.yml | 53 +++++++++++++++++++++++ .github/workflows/wsl.yml | 42 ++++++++++++++++++ CMakeLists.txt | 4 +- CMakePresets.json | 35 ++++++++++++--- test/CMakeLists.txt | 8 ++++ test/feature_check_test.cpp | 2 + 9 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/msvc.yml create mode 100644 .github/workflows/wsl.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ca79ca5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..9895825 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,57 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + paths-ignore: + - '*.md' + - LICENSE + schedule: + - cron: '15 2 * * 4' + +permissions: + contents: read + +jobs: + analyze: + name: Analyze (C/C++) + runs-on: windows-latest + timeout-minutes: 360 + permissions: + actions: read # for github/codeql-action/init to get workflow details + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/autobuild to send a status report + packages: read + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: 'Install Ninja' + run: choco install ninja + + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + - name: Initialize CodeQL + uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + with: + languages: c-cpp + build-mode: manual + + - name: 'Configure CMake' + working-directory: ${{ github.workspace }} + run: cmake --preset=x64-Debug + + - name: 'Build' + working-directory: ${{ github.workspace }} + run: cmake --build out\build\x64-Debug + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + with: + category: "/language:c-cpp" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e3520d4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,83 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +name: 'CMake (Windows)' + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + paths-ignore: + - '*.md' + - LICENSE + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [windows-2019, windows-2022] + build_type: [x64-Debug, x64-Release] + arch: [amd64] + include: + - os: windows-2019 + build_type: x86-Debug + arch: amd64_x86 + - os: windows-2019 + build_type: x86-Release + arch: amd64_x86 + - os: windows-2022 + build_type: x86-Debug + arch: amd64_x86 + - os: windows-2022 + build_type: x86-Release + arch: amd64_x86 + - os: windows-2022 + build_type: x64-Debug-Clang + arch: amd64 + - os: windows-2022 + build_type: x64-Release-Clang + arch: amd64 + - os: windows-2022 + build_type: arm64-Debug + arch: amd64_arm64 + - os: windows-2022 + build_type: arm64-Release + arch: amd64_arm64 + - os: windows-2022 + build_type: arm64ec-Debug + arch: amd64_arm64 + - os: windows-2022 + build_type: arm64ec-Release + arch: amd64_arm64 + - os: windows-2022 + build_type: x64-Debug-MinGW + arch: amd64 + - os: windows-2022 + build_type: x64-Release-MinGW + arch: amd64 + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: 'Install Ninja' + run: choco install ninja + + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + with: + arch: ${{ matrix.arch }} + + - name: 'Configure CMake' + working-directory: ${{ github.workspace }} + run: cmake --preset=${{ matrix.build_type }} + + - name: 'Build' + working-directory: ${{ github.workspace }} + run: cmake --build out\build\${{ matrix.build_type }} diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml new file mode 100644 index 0000000..79ea0a5 --- /dev/null +++ b/.github/workflows/msvc.yml @@ -0,0 +1,53 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +name: Microsoft C++ Code Analysis + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + paths-ignore: + - '*.md' + - LICENSE + schedule: + - cron: '24 13 * * 4' + +permissions: + contents: read + +jobs: + analyze: + permissions: + contents: read + security-events: write + actions: read + name: Analyze + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + with: + arch: amd64 + + - name: Configure CMake + working-directory: ${{ github.workspace }} + run: cmake -B out + + - name: Initialize MSVC Code Analysis + uses: microsoft/msvc-code-analysis-action@24c285ab36952c9e9182f4b78dfafbac38a7e5ee # v0.1.1 + id: run-analysis + with: + cmakeBuildDirectory: ./out + buildConfiguration: Debug + ruleset: NativeRecommendedRules.ruleset + + # Upload SARIF file to GitHub Code Scanning Alerts + - name: Upload SARIF to GitHub + uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + with: + sarif_file: ${{ steps.run-analysis.outputs.sarif }} diff --git a/.github/workflows/wsl.yml b/.github/workflows/wsl.yml new file mode 100644 index 0000000..9beb4a8 --- /dev/null +++ b/.github/workflows/wsl.yml @@ -0,0 +1,42 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +name: 'CMake (WSL)' + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + paths-ignore: + - '*.md' + - LICENSE + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + build_type: [x64-Debug-Linux, x64-Release-Linux] + gcc: [10, 11, 12] + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # v5 + + - name: 'Configure CMake' + working-directory: ${{ github.workspace }} + run: > + cmake --preset=${{ matrix.build_type }} + + env: + CC: gcc-${{ matrix.gcc }} + CXX: g++-${{ matrix.gcc }} + + - name: 'Build' + working-directory: ${{ github.workspace }} + run: cmake --build out/build/${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 75944a2..37909af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,8 @@ elseif((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL # MinGW has RPC headers which define old versions, and complain if D3D # headers are included before the RPC headers, since D3D headers were # generated with new MIDL and "require" new RPC headers. - target_compile_options(DirectX-Headers PRIVATE "-D__REQUIRED_RPCNDR_H_VERSION__=475") - target_compile_options(DirectX-Guids PRIVATE "-D__REQUIRED_RPCNDR_H_VERSION__=475") + target_compile_definitions(DirectX-Headers PRIVATE "__REQUIRED_RPCNDR_H_VERSION__=475") + target_compile_definitions(DirectX-Guids PRIVATE "__REQUIRED_RPCNDR_H_VERSION__=475") endif() if (DXHEADERS_INSTALL) diff --git a/CMakePresets.json b/CMakePresets.json index c114cf7..6b8b588 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -44,6 +44,14 @@ }, "hidden": true }, + { + "name": "ARM64EC", + "architecture": { + "value": "arm64ec", + "strategy": "external" + }, + "hidden": true + }, { "name": "Debug", @@ -136,12 +144,14 @@ } }, - { "name": "x64-Debug" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC" ] }, - { "name": "x64-Release" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC" ] }, - { "name": "x86-Debug" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, - { "name": "x86-Release" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC" ] }, - { "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] }, - { "name": "arm64-Release", "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC" ] }, + { "name": "x64-Debug" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC" ] }, + { "name": "x64-Release" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC" ] }, + { "name": "x86-Debug" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, + { "name": "x86-Release" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC" ] }, + { "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] }, + { "name": "arm64-Release" , "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC" ] }, + { "name": "arm64ec-Debug" , "description": "MSVC for ARM64EC (Debug)", "inherits": [ "base", "ARM64EC", "Debug", "MSVC" ], "environment": { "CFLAGS": "/arm64EC", "CXXFLAGS": "/arm64EC" } }, + { "name": "arm64ec-Release" , "description": "MSVC for ARM64EC (Release)", "inherits": [ "base", "ARM64EC", "Release", "MSVC" ], "environment": { "CFLAGS": "/arm64EC", "CXXFLAGS": "/arm64EC" } }, { "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] }, { "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] }, @@ -183,5 +193,16 @@ { "name": "x64-Release-Linux" , "description": "Linux x64 (Release)", "inherits": [ "base", "x64", "Release", "NoTests" ] }, { "name": "arm64-Debug-Linux" , "description": "Linux AArch64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "NoTests" ] }, { "name": "arm64-Release-Linux", "description": "Linux AArch64 (Release)", "inherits": [ "base", "ARM64", "Release", "NoTests" ] } + ], + "testPresets": [ + { "name": "x64-Debug" , "configurePreset": "x64-Debug" }, + { "name": "x64-Release" , "configurePreset": "x64-Release" }, + { "name": "x86-Debug" , "configurePreset": "x86-Debug" }, + { "name": "x86-Release" , "configurePreset": "x86-Release" }, + + { "name": "arm64-Debug" , "configurePreset": "arm64-Debug" }, + { "name": "arm64-Release" , "configurePreset": "arm64-Release" }, + { "name": "arm64ec-Debug" , "configurePreset": "arm64ec-Debug" }, + { "name": "arm64ec-Release", "configurePreset": "arm64ec-Release" } ] -} \ No newline at end of file +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6eef15a..ba3bc8e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,6 +25,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +option(DXHEADERS_BUILD_COM_ATL "Build using ATL CComPtr" OFF) + set(TEST_EXES DirectX-Headers-Test DirectX-Headers-Check-Feature-Support-Test) add_executable(DirectX-Headers-Test test.cpp) @@ -36,6 +38,12 @@ foreach(t IN LISTS TEST_EXES) target_link_libraries(${t} DirectX-Headers DirectX-Guids ${dxlibs}) endforeach() +if(DXHEADERS_BUILD_COM_ATL) + foreach(t IN LISTS TEST_EXES) + target_compile_definitions(${t} PRIVATE D3DX12_USE_ATL) + endforeach() +endif() + if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM" ) target_compile_options(DirectX-Headers-Check-Feature-Support-Test PRIVATE -Wno-unused-variable) endif() diff --git a/test/feature_check_test.cpp b/test/feature_check_test.cpp index 6332a2b..fae16e8 100644 --- a/test/feature_check_test.cpp +++ b/test/feature_check_test.cpp @@ -9,6 +9,8 @@ #include #include "dxguids/dxguids.h" +#include + // ----------------------------------------------------------------------------------------------------------------- // Helper Macros for verifying feature check results // -----------------------------------------------------------------------------------------------------------------