Skip to content

Commit

Permalink
Added GitHub Actions for build and security analysis (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Jul 30, 2024
1 parent 0260a8f commit d31c76a
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 113 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561

name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.yml
schedule:
- cron: '19 7 * * 1'

jobs:
analyze:
name: Analyze (C/C++)
runs-on: windows-latest
timeout-minutes: 360
permissions:
security-events: write
packages: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: 'Install Ninja'
run: choco install ninja

- uses: ilammy/msvc-dev-cmd@v1

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
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@v3
with:
category: "/language:c-cpp"
99 changes: 99 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561

name: 'CMake (Windows)'

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.yml

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false

matrix:
os: [windows-2019, windows-2022]
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
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-2019
build_type: x86-Debug-Clang
arch: amd64_x86
- os: windows-2019
build_type: x86-Release-Clang
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: x86-Debug-Clang
arch: amd64_x86
- os: windows-2022
build_type: x86-Release-Clang
arch: amd64_x86
- 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

steps:
- uses: actions/checkout@v4

- name: 'Install Ninja'
run: choco install ninja

- uses: ilammy/msvc-dev-cmd@v1
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 }}

- if: matrix.arch != 'amd64_arm64'
name: 'Configure CMake (Spectre)'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }} -DENABLE_SPECTRE_MITIGATION=ON

- if: matrix.arch != 'amd64_arm64'
name: 'Build (Spectre)'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}
52 changes: 52 additions & 0 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561

name: MSBuild

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- '.nuget/*'
- build/*

permissions:
contents: read

jobs:
build:
runs-on: windows-${{ matrix.vs }}

strategy:
fail-fast: false

matrix:
vs: [2019, 2022]
build_type: [Debug, Release]
platform: [x86, x64, ARM64]

steps:
- uses: actions/checkout@v4

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2

- name: 'Build'
working-directory: ${{ github.workspace }}
run: msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }} ./DirectXTK_Desktop_${{ matrix.vs }}_Win10.sln

- if: matrix.vs == '2022'
name: 'Build (UWP)'
working-directory: ${{ github.workspace }}
run: msbuild /m /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }} ./DirectXTK_Windows10_2022.sln

- if: matrix.platform != 'ARM64'
name: 'Build (Spectre Windows 10)'
working-directory: ${{ github.workspace }}
run: msbuild /m /p:SpectreMitigation=Spectre /p:Configuration=${{ matrix.build_type }} /p:Platform=${{ matrix.platform }} ./DirectXTK_Desktop_${{ matrix.vs }}_Win10.sln
69 changes: 69 additions & 0 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561

name: Microsoft C++ Code Analysis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.yml
schedule:
- cron: '20 21 * * 2'

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@v4

- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64

- name: Configure CMake
working-directory: ${{ github.workspace }}
run: cmake -B out -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON

- name: 'Build Shaders'
shell: cmd
working-directory: ./Src/Shaders
run: CompileShaders.cmd dxil
env:
CompileShadersOutput: ${{ github.workspace }}/out/Shaders/Compiled

- name: Initialize MSVC Code Analysis
uses: microsoft/msvc-code-analysis-action@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@v3
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}
103 changes: 103 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561

name: 'CTest (Windows)'

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- LICENSE
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/*.props
- build/*.ps1
- build/*.targets
- build/*.yml

jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 20

strategy:
fail-fast: false

matrix:
os: [windows-2019, windows-2022]
build_type: [x64-Debug, x64-Release, x64-Debug-Clang, x64-Release-Clang]
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-2019
build_type: x86-Debug-Clang
arch: amd64_x86
- os: windows-2019
build_type: x86-Release-Clang
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: x86-Debug-Clang
arch: amd64_x86
- os: windows-2022
build_type: x86-Release-Clang
arch: amd64_x86
- 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

steps:
- uses: actions/checkout@v4

- name: Clone test repository
uses: actions/checkout@v4
with:
repository: walbourn/directxtk12test
path: Tests
ref: main

- name: 'Install Ninja'
run: choco install ninja

- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}

- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
run: cmake --preset=${{ matrix.build_type }} -DBUILD_TESTING=ON

- name: 'Build'
working-directory: ${{ github.workspace }}
run: cmake --build out\build\${{ matrix.build_type }}

- if: (matrix.build_type == 'x64-Release') || (matrix.build_type == 'x86-Release')
timeout-minutes: 10
name: 'Test (Math only)'
working-directory: ${{ github.workspace }}
run: ctest --preset=${{ matrix.build_type }} -L Math
Loading

0 comments on commit d31c76a

Please sign in to comment.