Skip to content

Commit

Permalink
introduce bitmask support and std::format specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mguludag committed Jun 24, 2024
1 parent 0e5b19f commit c455494
Show file tree
Hide file tree
Showing 33 changed files with 2,673 additions and 820 deletions.
79 changes: 79 additions & 0 deletions .github/actions/build-docs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 'build-docs'
description: 'Builds documentation using Doxygen'
inputs:
cmake_target:
description: 'CMake documentation target'
required: true
docs_dir:
description: 'Path to documentation dir, relative to build_dir'
required: true
github_token:
description: 'GitHub token'
required: true
build_dir:
description: 'Build directory'
required: false
default: 'build'
cmake_configure_args:
description: 'Additional CMake configure arguments'
required: false
default: ''
destination_dir:
description: 'Directory name for deployed docs'
required: false
default: ''
docs_branch:
description: 'Documentation branch'
required: false
default: 'gh-pages'

outputs:
version:
description: 'Version of the generated docs'
value: ${{ steps.get-docs-version.outputs.version }}

runs:
using: "composite"
steps:
- name: Install deps
shell: bash
run: |
sudo apt install -y cmake
sudo apt install -y wget
cd ~
wget -nv https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz
tar -xzf doxygen-1.10.0.linux.bin.tar.gz
echo "$(pwd)/doxygen-1.10.0/bin" >> $GITHUB_PATH
- name: CMake configuration
shell: bash
run: cmake ${{ inputs.cmake_configure_args }} -B ${{ inputs.build_dir }} -DENUM_NAME_BUILD_DOCS=ON

- name: CMake build
shell: bash
run: cmake --build ${{ inputs.build_dir }} --target ${{ inputs.cmake_target }}

- name: Get docs version
id: get-docs-version
shell: bash
run: |
subdir=$(basename $(find ${{ inputs.build_dir }}/${{ inputs.docs_dir }} -mindepth 1 -maxdepth 1 -type d | head -n 1))
echo "version=$subdir" >> $GITHUB_OUTPUT
- name: Deploy docs
if: ${{ inputs.destination_dir != '' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ inputs.github_token }}
publish_dir: ${{ inputs.build_dir }}/${{ inputs.docs_dir }}/${{ steps.get-docs-version.outputs.version }}
destination_dir: ${{ inputs.destination_dir }}
publish_branch: ${{ inputs.docs_branch }}

- name: Deploy docs
if: ${{ inputs.destination_dir == '' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ inputs.github_token }}
publish_dir: ${{ inputs.build_dir }}/${{ inputs.docs_dir }}/${{ steps.get-docs-version.outputs.version }}
destination_dir: ${{ steps.get-docs-version.outputs.version }}
publish_branch: ${{ inputs.docs_branch }}
54 changes: 54 additions & 0 deletions .github/actions/update-redirect-page/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'update-redirect-page'
description: 'Updates redirect HTML page'
inputs:
github_token:
description: 'GitHub token'
required: true
target_url:
description: 'Redirect target URL'
temp_dir:
description: 'Directory where redirect file will be generated'
required: false
default: 'redirect-dir'
file_name:
description: 'Generated file name'
required: false
default: 'index.html'
destination_dir:
description: 'Redirect file destination directory'
required: false
default: ''
docs_branch:
description: 'Documentation branch'
required: false
default: 'gh-pages'

runs:
using: "composite"
steps:
- name: Generate redirect HTML
shell: bash
run: |
mkdir ${{ inputs.temp_dir }}
cat << EOF > ${{ inputs.temp_dir }}/${{ inputs.file_name }}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=${{ inputs.target_url }}">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="${{ inputs.target_url }}">click here</a>.</p>
</body>
</html>
EOF
- name: Deploy redirect page
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ inputs.github_token }}
publish_dir: ${{ inputs.temp_dir }}
destination_dir: ${{ inputs.destination_dir }}
publish_branch: ${{ inputs.docs_branch }}
keep_files: true
56 changes: 56 additions & 0 deletions .github/actions/update-version-selector/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'update-version-selector'
description: 'Updates version selector'
inputs:
github_token:
description: 'GitHub token'
required: true
temp_dir:
description: 'Directory where version selector file will be generated'
required: false
default: 'selector-dir'
file_name:
description: 'Selector file name'
required: false
default: 'version_selector.html'
selector_id:
description: 'select element id'
required: false
default: 'versionSelector'
docs_branch:
description: 'Documentation branch'
required: false
default: 'gh-pages'
outputs:
versions_counter:
description: "Number of existing versions"
value: ${{ steps.discover-versions.outputs.counter }}

runs:
using: "composite"
steps:
- name: Discover versions
id: discover-versions
shell: bash
run: |
git fetch origin ${{ inputs.docs_branch }}
dirs=$(git ls-tree --name-only -d origin/${{ inputs.docs_branch }} | sort -rV)
echo "counter=$(echo "$dirs" | wc -l | xargs)" >> $GITHUB_OUTPUT
mkdir ${{ inputs.temp_dir }}
# Create HTML
echo '<select id="${{ inputs.selector_id }}">' > ${{ inputs.temp_dir }}/${{ inputs.file_name }}
for dir in $dirs; do
if [[ "$(basename "$dir")" != .* ]]; then
version=$(basename "$dir")
echo " <option value=\"$version\">$version</option>" >> ${{ inputs.temp_dir }}/${{ inputs.file_name }}
fi
done
echo '</select>' >> ${{ inputs.temp_dir }}/${{ inputs.file_name }}
- name: Deploy version selector
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ inputs.github_token }}
publish_dir: ${{ inputs.temp_dir }}
publish_branch: ${{ inputs.docs_branch }}
keep_files: true
38 changes: 38 additions & 0 deletions .github/workflows/create-git-main-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create git-main docs

permissions:
contents: write

on:
push:
branches:
- main

jobs:
create-git-main-docs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Build docs
id: build-docs
uses: ./.github/actions/build-docs
with:
cmake_target: 'doc'
docs_dir: 'doc/docs'
destination_dir: git-main
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update version selector
id: update-version-selector
uses: ./.github/actions/update-version-selector
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create redirect page if there are no releases
if: ${{ steps.update-version-selector.outputs.versions_counter == 1}}
uses: ./.github/actions/update-redirect-page
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
target_url: git-main/index.html
24 changes: 24 additions & 0 deletions .github/workflows/trunk-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Push
on: [push]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions: read-all

jobs:
trunk_check:
name: Trunk Check Runner
runs-on: ubuntu-latest
permissions:
checks: write # For trunk to post annotations
contents: read # For repo checkout

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Trunk Check
uses: trunk-io/trunk-action@v1
with:
check-mode: all
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
39 changes: 39 additions & 0 deletions .trunk/configs/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Checks: >-
bugprone-*,
cppcoreguidelines-*,
google-*,
misc-*,
modernize-*,
performance-*,
readability-*,
-bugprone-lambda-function-name,
-bugprone-reserved-identifier,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-vararg,
-google-readability-braces-around-statements,
-google-readability-function-size,
-misc-no-recursion,
-modernize-return-braced-init-list,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-unnecessary-value-param,
-readability-magic-numbers,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 100
- key: readability-function-cognitive-complexity.IgnoreMacros
value: true
# Set naming conventions for your style below (there are dozens of naming settings possible):
# See https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html
# - key: readability-identifier-naming.ClassCase
# value: CamelCase
# - key: readability-identifier-naming.NamespaceCase
# value: lower_case
# - key: readability-identifier-naming.PrivateMemberSuffix
# value: _
# - key: readability-identifier-naming.StructCase
# value: CamelCase
2 changes: 2 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
11 changes: 11 additions & 0 deletions .trunk/setup-ci/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Trunk Check setup
description: Set up dependencies for Trunk Check
runs:
using: composite
steps:
- name: Configure Project
uses: threeal/cmake-action@main
with:
run-build: false
generator: Unix Makefiles
options: CMAKE_EXPORT_COMPILE_COMMANDS ON
40 changes: 40 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.1
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.5.0
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
Loading

0 comments on commit c455494

Please sign in to comment.