Skip to content

Commit

Permalink
ci: add CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Feb 19, 2025
1 parent 12f0bb6 commit 348873e
Show file tree
Hide file tree
Showing 19 changed files with 623 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Set up dependencies
description: Set up dependencies for the project
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libgtest-dev valgrind llvm gcovr graphviz
54 changes: 54 additions & 0 deletions .github/workflows/apidocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy API Docs to Pages

on:
push:
branches:
- master
workflow_dispatch:

permissions:
contents: read

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
name: Deploy
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Install Doxygen
uses: ssciwr/doxygen-install@527824132256e685f03ec80c0851fe79937eb1d6 # v1.6.3
with:
version: "1.12.0"

- name: Generate API Docs
run: |
cmake -B build
cmake --build build --target docs
- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0

- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: apidocs

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
67 changes: 67 additions & 0 deletions .github/workflows/ci-vcpkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and Test (vcpkg)

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build and Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
triplet: x64-windows-release
- os: macos-latest
triplet: arm64-osx-release
- os: ubuntu-latest
triplet: x64-linux-release
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_DEFAULT_HOST_TRIPLET: ${{ matrix.triplet }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit

- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
fetch-depth: 0

- name: Set up cmake and ninja
uses: lukka/get-cmake@5f6e04f5267c8133f1273bf2103583fc72c46b17 # v3.31.5

- name: Set up vcpkg
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5

# - name: Fix for AppleClang
# run: |
# sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
# if: runner.os == 'macOS'

- name: Build and test
run: |
cmake --preset debug-vcpkg -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF
cmake --build --preset debug-vcpkg
ctest --preset debug-vcpkg
- name: Install
run: sudo cmake --install build
if: runner.os != 'Windows'

- name: Install (Windows)
run: cmake --install build --config Debug
if: runner.os == 'Windows'
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build and Test

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
prepare:
name: Prepare list of configurations
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
presets: ${{ steps.set-matrix.outputs.presets }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
github.com:443
- name: Check out the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set matrix
id: set-matrix
run: echo presets="$(jq '.configurePresets[] | select(.hidden == false) | {name, description}' CMakePresets.json | jq --slurp -c .)" >> "${GITHUB_OUTPUT}"

build:
needs: prepare
name: Build and Test (${{ matrix.preset.description }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
preset: ${{ fromJson(needs.prepare.outputs.presets) }}
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
allowed-endpoints: >
api.github.com:443
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
fetch-depth: 0

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Build and test
run: |
cmake --preset ${{ matrix.preset.name }} -DBUILD_DOCS=OFF
cmake --build --preset ${{ matrix.preset.name }} -j $(nproc)
ctest --preset ${{ matrix.preset.name }}
build-ext:
name: Build and Test (external dependencies)
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: block
allowed-endpoints: >
github.com:443
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Build and test
run: |
cmake --preset default -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF
cmake --build --preset default -j $(nproc)
ctest --preset default
sudo cmake --install build
43 changes: 43 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: clang-tidy

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
clang-tidy:
name: Run clang-tidy
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
- name: Check out the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Configure
run: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run clang-tidy
run: clang-tidy -p build $(jq -r '.[].file' build/compile_commands.json) --warnings-as-errors='*'
60 changes: 60 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CodeQL

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '1 23 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
security-events: write
actions: read
contents: read
strategy:
fail-fast: false
matrix:
language:
- c-cpp
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Initialize CodeQL
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
languages: ${{ matrix.language }}

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Build
run: |
cmake -B build -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF
cmake --build build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
category: "/language:${{ matrix.language }}"
Loading

0 comments on commit 348873e

Please sign in to comment.