refactor: simplify handlebars generators #2591
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: | |
push: | |
branches: | |
- develop | |
- master | |
- '*' | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- develop | |
concurrency: | |
group: ${{format('{0}:{1}', github.repository, github.ref)}} | |
cancel-in-progress: true | |
jobs: | |
cpp-matrix: | |
runs-on: ubuntu-latest | |
name: Generate Test Matrix | |
outputs: | |
matrix: ${{ steps.cpp-matrix.outputs.matrix }} | |
llvm-matrix: ${{ steps.llvm-matrix.outputs.llvm-matrix }} | |
releases-matrix: ${{ steps.releases-matrix.outputs.releases-matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Generate Test Matrix | |
uses: alandefreitas/cpp-actions/cpp-matrix@v1.8.7 | |
id: cpp-matrix | |
with: | |
compilers: | | |
gcc 14 | |
clang 18 | |
msvc >=14.40 | |
apple-clang * | |
standards: '20' | |
latest-factors: | | |
msvc Optimized-Debug | |
gcc Coverage | |
factors: '' | |
runs-on: | | |
apple-clang: macos-15 | |
build-types: | | |
gcc: Release | |
clang: Release | |
apple-clang: Release | |
msvc: RelWithDebInfo | |
msvc Optimized-Debug: Debug | |
ccflags: | | |
msvc Optimized-Debug: /Ob1 /O2 /Zi | |
cxxflags: | | |
msvc Optimized-Debug: /Ob1 /O2 /Zi | |
install: | | |
gcc: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev | |
gcc Coverage: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev lcov | |
clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev | |
msvc: '' | |
extra-values: | | |
llvm-hash: e1065370aaacb1b1cb48e77d37d376bf024f4a39 | |
llvm-id: {{ substr llvm-hash 0 7 }} | |
llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{lowercase build-type}}{{/if}} | |
llvm-build-preset-suffix: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}} | |
llvm-build-preset: {{ llvm-build-preset-prefix }}-{{ llvm-build-preset-suffix }} | |
llvm-compiler-key: {{ compiler }}-{{ version }} | |
llvm-cache-key: llvm-libcxx-{{ lowercase os }}-{{ llvm-compiler-key }}-{{ llvm-build-preset-prefix }}-{{ llvm-hash }} | |
llvm-root: ../third-party/llvm-project/install | |
llvm-archive-basename: llvm-{{ os }}-{{ llvm-build-preset-prefix }}-{{ llvm-id }} | |
llvm-archive-extension: {{#if (ieq os 'windows') }}7z{{else}}tar.bz2{{/if}} | |
llvm-archive-filename: {{ llvm-archive-basename }}.{{ llvm-archive-extension }} | |
libcxx-runtimes: libcxx;libcxxabi{{#if (ine os 'windows') }};libunwind{{/if}} | |
libcxx-targets: cxx {{#if (ine os 'windows') }}cxxabi unwind{{/if}} install-cxx {{#if (ine os 'windows') }}install-cxxabi install-unwind{{/if}} | |
libcxx-cxxflags: {{#if (ieq os 'windows') }}-D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_BIG_ENDIAN__=4321 -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__{{/if}} | |
libcxx-cmake-args: -D LLVM_ENABLE_RUNTIMES="{{ libcxx-runtimes }}" {{#if (ieq os 'windows') }}-D LIBCXXABI_USE_LLVM_UNWINDER=OFF -D LIBCXXABI_ENABLE_SHARED=OFF -D LIBCXXABI_ENABLE_STATIC=ON -D LIBCXX_ENABLE_SHARED=OFF -D LIBCXX_NO_VCRUNTIME=ON{{/if}} {{#if (ieq os 'macos') }}-D CMAKE_OSX_ARCHITECTURES=""{{/if}} | |
mrdocs-ccflags: {{ ccflags }} {{#if (eq compiler 'gcc') }}-static{{/if}} {{#if asan }}-static-libasan{{/if}} {{#if tsan }}-static-libtsan{{/if}} | |
mrdocs-cxxflags: {{ cxxflags }} {{#if (eq compiler 'gcc') }}-static{{/if}} {{#if asan }}-static-libasan{{/if}} {{#if tsan }}-static-libtsan{{/if}} | |
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}} | |
mrdocs-release-package-artifact: release-packages-{{ lowercase os }} | |
output-file: matrix.json | |
# Set up the version as expected by the LLVM matrix script and @actions/core | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Generate LLVM Test Matrix | |
id: llvm-matrix | |
run: | | |
set -x | |
cd .github | |
npm ci | |
cd .. | |
node .github/llvm-matrix.js | |
- name: Generate Releases Test Matrix | |
id: releases-matrix | |
run: | | |
set -x | |
cd .github | |
npm ci | |
cd .. | |
node .github/releases-matrix.js | |
build: | |
needs: cpp-matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }} | |
defaults: | |
run: | |
shell: bash | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.runs-on }} | |
container: ${{ matrix.container }} | |
env: ${{ matrix.env }} | |
permissions: | |
contents: write | |
steps: | |
- name: Clone MrDocs | |
uses: actions/checkout@v4 | |
- name: Setup CMake | |
uses: alandefreitas/cpp-actions/setup-cmake@v1.8.7 | |
id: setup-cmake | |
with: | |
version: '>=3.26' | |
check-latest: 'true' | |
update-environment: 'true' | |
trace-commands: 'true' | |
- name: Setup Ninja | |
uses: seanmiddleditch/gha-setup-ninja@v5 | |
- name: Setup C++ | |
uses: alandefreitas/cpp-actions/setup-cpp@v1.8.7 | |
id: setup-cpp | |
with: | |
compiler: ${{ matrix.compiler }} | |
version: ${{ matrix.version }} | |
# If apple-clang on macos, we run `clang -print-targets` to | |
# get the list of targets supported by the compiler. | |
- name: Print Clang Targets | |
if: matrix.compiler == 'apple-clang' | |
run: | | |
set -x | |
${{ steps.setup-cpp.outputs.cxx }} --print-targets | |
${{ steps.setup-cpp.outputs.cxx }} --print-target-triple | |
- name: Install System Packages | |
uses: alandefreitas/cpp-actions/package-install@v1.8.7 | |
if: matrix.compiler != 'msvc' | |
id: package-install | |
env: | |
DEBIAN_FRONTEND: 'noninteractive' | |
TZ: 'Etc/UTC' | |
with: | |
apt-get: ${{ matrix.install }} | |
- name: Install Duktape | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
with: | |
source-dir: ../third-party/duktape | |
url: https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz | |
patches: | | |
./third-party/duktape/CMakeLists.txt | |
./third-party/duktape/duktapeConfig.cmake.in | |
build-dir: ${sourceDir}/build | |
cc: ${{ steps.setup-cpp.outputs.cc }} | |
cxx: ${{ steps.setup-cpp.outputs.cxx }} | |
ccflags: ${{ matrix.ccflags }} | |
cxxflags: ${{ matrix.cxxflags }} | |
build-type: ${{ matrix.build-type }} | |
shared: false | |
install: true | |
install-prefix: ${sourceDir}/install | |
run-tests: false | |
trace-commands: true | |
- name: Install Fmt | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
with: | |
source-dir: ../third-party/fmt | |
git-repository: https://github.com/fmtlib/fmt | |
git-tag: 10.2.1 | |
build-dir: ${sourceDir}/build | |
cc: ${{ steps.setup-cpp.outputs.cc }} | |
cxx: ${{ steps.setup-cpp.outputs.cxx }} | |
ccflags: ${{ matrix.ccflags }} | |
cxxflags: ${{ matrix.cxxflags }} | |
build-type: ${{ matrix.build-type }} | |
extra-args: | | |
-D FMT_DOC=OFF | |
-D FMT_TEST=OFF | |
install: true | |
install-prefix: ${sourceDir}/install | |
run-tests: false | |
trace-commands: true | |
- name: Install Libxml2 | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
if: matrix.compiler == 'msvc' | |
with: | |
source-dir: ../third-party/libxml2 | |
git-repository: https://github.com/GNOME/libxml2 | |
git-tag: v2.12.6 | |
build-dir: ${sourceDir}/build | |
cc: ${{ steps.setup-cpp.outputs.cc }} | |
cxx: ${{ steps.setup-cpp.outputs.cxx }} | |
ccflags: ${{ matrix.ccflags }} | |
cxxflags: ${{ matrix.cxxflags }} | |
build-type: Release | |
extra-args: | | |
-D LIBXML2_WITH_PROGRAMS=ON | |
-D LIBXML2_WITH_FTP=OFF | |
-D LIBXML2_WITH_HTTP=OFF | |
-D LIBXML2_WITH_ICONV=OFF | |
-D LIBXML2_WITH_LEGACY=OFF | |
-D LIBXML2_WITH_LZMA=OFF | |
-D LIBXML2_WITH_ZLIB=OFF | |
-D LIBXML2_WITH_ICU=OFF | |
-D LIBXML2_WITH_TESTS=OFF | |
-D LIBXML2_WITH_HTML=ON | |
-D LIBXML2_WITH_C14N=ON | |
-D LIBXML2_WITH_CATALOG=ON | |
-D LIBXML2_WITH_DEBUG=ON | |
-D LIBXML2_WITH_ISO8859X=ON | |
-D LIBXML2_WITH_MEM_DEBUG=OFF | |
-D LIBXML2_WITH_MODULES=ON | |
-D LIBXML2_WITH_OUTPUT=ON | |
-D LIBXML2_WITH_PATTERN=ON | |
-D LIBXML2_WITH_PUSH=ON | |
-D LIBXML2_WITH_PYTHON=OFF | |
-D LIBXML2_WITH_READER=ON | |
-D LIBXML2_WITH_REGEXPS=ON | |
-D LIBXML2_WITH_SAX1=ON | |
-D LIBXML2_WITH_SCHEMAS=ON | |
-D LIBXML2_WITH_SCHEMATRON=ON | |
-D LIBXML2_WITH_THREADS=ON | |
-D LIBXML2_WITH_THREAD_ALLOC=OFF | |
-D LIBXML2_WITH_TREE=ON | |
-D LIBXML2_WITH_VALID=ON | |
-D LIBXML2_WITH_WRITER=ON | |
-D LIBXML2_WITH_XINCLUDE=ON | |
-D LIBXML2_WITH_XPATH=ON | |
-D LIBXML2_WITH_XPTR=ON | |
install: true | |
install-prefix: ${sourceDir}/install | |
run-tests: false | |
trace-commands: true | |
- name: Resolve LLVM Root | |
id: resolve-llvm-root | |
run: | | |
set -x | |
cd .. | |
llvm_root=$(pwd)/third-party/llvm-project/install | |
if [[ ${{ runner.os }} == 'Windows' ]]; then | |
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g') | |
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|') | |
echo "$llvm_root" | |
fi | |
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT | |
- name: Cached LLVM Binaries | |
id: llvm-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }} | |
key: ${{ matrix.llvm-cache-key }} | |
- name: Download LLVM Binaries | |
id: llvm-download | |
if: steps.llvm-cache.outputs.cache-hit != 'true' | |
run: | | |
set -x | |
url=https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }} | |
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$url") | |
if [ "$http_status" -eq 200 ]; then | |
found="true" | |
echo "found=$found" >> $GITHUB_OUTPUT | |
curl -L -o ${{ matrix.llvm-archive-filename }} "$url" | |
install_prefix=$(pwd)/../third-party/llvm-project/install | |
mkdir -p $install_prefix | |
if [[ ${{ matrix.llvm-archive-extension }} == '7z' ]]; then | |
7z x ${{ matrix.llvm-archive-filename }} -o$install_prefix | |
else | |
tar -xjf ${{ matrix.llvm-archive-filename }} -C $install_prefix | |
fi | |
if [[ $(ls -1 $install_prefix | wc -l) -eq 1 ]]; then | |
single_dir=$(ls -1 $install_prefix) | |
if [[ -d $install_prefix/$single_dir ]]; then | |
mv $install_prefix/$single_dir/* $install_prefix/ | |
rmdir $install_prefix/$single_dir | |
fi | |
fi | |
else | |
found="false" | |
echo "found=$found" >> $GITHUB_OUTPUT | |
fi | |
- name: Install LLVM | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true' | |
with: | |
cmake-version: '>=3.26' | |
source-dir: ../third-party/llvm-project/llvm | |
git-repository: https://github.com/llvm/llvm-project.git | |
git-tag: ${{ matrix.llvm-hash }} | |
download-dir: ../third-party/llvm-project | |
patches: | | |
./third-party/llvm/CMakePresets.json | |
./third-party/llvm/CMakeUserPresets.json | |
build-dir: ${sourceDir}/llvm/build | |
preset: ${{ matrix.llvm-build-preset }} | |
build-type: ${{ matrix.build-type }} | |
cc: ${{ steps.setup-cpp.outputs.cc }} | |
cxx: ${{ steps.setup-cpp.outputs.cxx }} | |
install: true | |
install-prefix: ${sourceDir}/../install | |
run-tests: false | |
trace-commands: true | |
- name: Install LibC++ | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true' | |
with: | |
cmake-version: '>=3.26' | |
source-dir: ../third-party/llvm-project/runtimes | |
build-dir: ${sourceDir}/build-libcxx | |
build-target: ${{ matrix.libcxx-targets }} | |
# MrDocs will only use the LibC++ headers: any compiler that works in this workflow will do | |
cc: ${{ runner.os == 'macOS' && steps.setup-cpp.outputs.cc || '../third-party/llvm-project/install/bin/clang' }} | |
cxx: ${{ runner.os == 'macOS' && steps.setup-cpp.outputs.cxx || '../third-party/llvm-project/install/bin/clang++' }} | |
cxxflags: ${{ matrix.libcxx-cxxflags }} | |
generator: Ninja | |
extra-args: ${{ matrix.libcxx-cmake-args }} | |
install: true | |
install-prefix: ${sourceDir}/../install | |
run-tests: false | |
trace-commands: true | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: CMake Workflow | |
uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.7 | |
with: | |
cmake-version: '>=3.26' | |
cxxstd: ${{ matrix.cxxstd }} | |
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} | |
ccflags: ${{ matrix.mrdocs-ccflags }} | |
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} | |
cxxflags: ${{ matrix.mrdocs-cxxflags }} | |
generator: Ninja | |
toolchain: ${{ steps.package-install.outputs.vcpkg_toolchain || steps.package-install.outputs.vcpkg-toolchain }} | |
build-type: ${{ matrix.build-type }} | |
install-prefix: .local | |
extra-args: | | |
-D MRDOCS_BUILD_DOCS=OFF | |
-D LLVM_ROOT=../third-party/llvm-project/install | |
-D Clang_ROOT=../third-party/llvm-project/install | |
-D duktape_ROOT=../third-party/duktape/install | |
-D Duktape_ROOT=../third-party/duktape/install | |
-D fmt_ROOT=../third-party/fmt/install | |
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }} | |
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }} | |
export-compile-commands: true | |
run-tests: true | |
install: true | |
package: ${{ matrix.is-main }} | |
package-dir: packages | |
package-generators: ${{ matrix.mrdocs-package-generators }} | |
package-artifact: false | |
- name: Check YAML schema | |
run: | | |
# Find python | |
python=$(command -v python3 || command -v python) | |
# The schema in this branch is up to date | |
"$python" ./util/generate-yaml-schema.py --check | |
# The schema in the docs folder is valid | |
npx -y -p ajv-cli -- ajv compile -s docs/mrdocs.schema.json | |
- name: Upload GitHub Release Artifacts | |
if: ${{ matrix.is-main && matrix.compiler != 'clang' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.mrdocs-release-package-artifact }} | |
path: | | |
build/packages | |
!build/packages/_CPack_Packages | |
retention-days: 1 | |
- name: FlameGraph | |
uses: alandefreitas/cpp-actions/flamegraph@v1.8.7 | |
if: matrix.time-trace | |
with: | |
build-dir: build | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Codecov | |
if: matrix.coverage | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
run: | | |
set -x | |
if [ -z "$CODECOV_TOKEN" ]; then | |
echo "CODECOV_TOKEN is not set. Skipping coverage report." | |
exit 0 | |
fi | |
# Find gcov | |
gcov_tool="gcov" | |
for version in "${{steps.setup-cpp.outputs.version-major}}.${{steps.setup-cpp.outputs.version-minor}}" "${{steps.setup-cpp.outputs.version-major}}"; do | |
if command -v "gcov-$version" &> /dev/null; then | |
gcov_tool="gcov-$version" | |
break | |
fi | |
done | |
for dir in "./build"; do | |
# Generate reports | |
echo "Generate report: $dir" | |
lcov --rc lcov_branch_coverage=0 --gcov-tool "$gcov_tool" --directory "$dir" --capture --output-file "$dir/all.info" | |
lcov --rc lcov_branch_coverage=0 --list "$dir/all.info" | |
# Upload to codecov | |
echo "Upload to codecov: $dir" | |
bash <(curl -s https://codecov.io/bash) -f "$dir/all.info" | |
done | |
# Summary | |
echo "# Coverage" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "[![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graphs/sunburst.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "Commit: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "Branch: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/branch/$GITHUB_REF_NAME/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
releases: | |
needs: [ cpp-matrix, build ] | |
if: ${{ needs.cpp-matrix.outputs.releases-matrix != '[]' && needs.cpp-matrix.outputs.releases-matrix != '' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJSON(needs.cpp-matrix.outputs.releases-matrix) }} | |
defaults: | |
run: | |
shell: bash | |
name: ${{ matrix.os }} MrDocs Releases | |
runs-on: ${{ matrix.runs-on }} | |
container: ${{ matrix.container }} | |
permissions: | |
contents: write | |
steps: | |
- name: Install packages | |
uses: alandefreitas/cpp-actions/package-install@v1.8.7 | |
id: package-install | |
with: | |
apt-get: build-essential asciidoctor cmake bzip2 git | |
- name: Clone MrDocs | |
uses: actions/checkout@v4 | |
- name: Set Repository Ownership | |
run: | | |
git config --global --add safe.directory "$(pwd)" | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Setup Ninja | |
uses: seanmiddleditch/gha-setup-ninja@v5 | |
if: ${{ runner.os == 'Windows' }} | |
- name: Download MrDocs package | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.mrdocs-release-package-artifact }} | |
path: packages | |
- name: Install MrDocs from Package | |
run: | | |
set -x | |
# Delete packages/_CPack_Packages files from previous runs | |
rm -rf packages/_CPack_Packages | |
# Print tree structure | |
find packages -print | sed 's;[^/]*/;|____;g;s;____|; |;g' | |
if [[ ${{ runner.os }} != 'Windows' ]]; then | |
dest_dir="$HOME/local" | |
mkdir -p "$dest_dir" | |
find packages -maxdepth 1 -name 'MrDocs-*.tar.gz' -exec tar -vxzf {} -C $dest_dir --strip-components=1 \; | |
else | |
dest_dir="$GITHUB_WORKSPACE/usr/local" | |
dest_dir=$(echo "$dest_dir" | sed 's/\\/\//g') | |
find packages -maxdepth 1 -name "MrDocs-*.7z" -exec 7z x {} -o$dest_dir \; | |
if [[ $(ls -1 $dest_dir | wc -l) -eq 1 ]]; then | |
single_dir=$(ls -1 $dest_dir) | |
if [[ -d $dest_dir/$single_dir ]]; then | |
mv $dest_dir/$single_dir/* $dest_dir/ | |
rmdir $dest_dir/$single_dir | |
fi | |
fi | |
fi | |
MRDOCS_ROOT="$dest_dir" | |
echo -e "MRDOCS_ROOT=$MRDOCS_ROOT" >> $GITHUB_ENV | |
echo -e "$MRDOCS_ROOT/bin" >> $GITHUB_PATH | |
$MRDOCS_ROOT/bin/mrdocs --version | |
- name: Clone Boost.URL | |
uses: alandefreitas/cpp-actions/boost-clone@v1.8.7 | |
id: boost-url-clone | |
with: | |
branch: develop | |
modules: url | |
boost-dir: boost | |
modules-scan-paths: '"test example"' | |
modules-exclude-paths: '' | |
trace-commands: true | |
- name: Set up llvm-symbolizer | |
if: ${{ runner.os == 'macOS' }} | |
run: | | |
set -x | |
# Step 1: Check if llvm-symbolizer is installed | |
if ! command -v llvm-symbolizer &> /dev/null; then | |
echo "llvm-symbolizer is not installed. Installing via Homebrew..." | |
# Step 2: Install llvm if not installed | |
if command -v brew &> /dev/null; then | |
brew install llvm | |
else | |
echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/" | |
exit 1 | |
fi | |
fi | |
# Step 3: Ensure llvm-symbolizer is in your PATH | |
llvm_bin_path=$(brew --prefix)/opt/llvm/bin | |
PATH="$PATH:$llvm_bin_path" | |
LLVM_SYMBOLIZER_PATH=$(which llvm-symbolizer) | |
if [ -z "$LLVM_SYMBOLIZER_PATH" ]; then | |
echo "llvm-symbolizer installation failed or it's not in the PATH." | |
exit 1 | |
else | |
echo "llvm-symbolizer found at: $LLVM_SYMBOLIZER_PATH" | |
fi | |
# Step 4: Export LLVM_SYMBOLIZER_PATH environment variable | |
export LLVM_SYMBOLIZER_PATH="$LLVM_SYMBOLIZER_PATH" | |
echo -e "LLVM_SYMBOLIZER_PATH=$LLVM_SYMBOLIZER_PATH" >> $GITHUB_ENV | |
echo "Environment variable LLVM_SYMBOLIZER_PATH set to: $LLVM_SYMBOLIZER_PATH" | |
- name: Generate Landing Page | |
working-directory: docs/website | |
run: | | |
npm ci | |
node render.js | |
mkdir -p ../../build/website | |
cp index.html ../../build/website/index.html | |
cp styles.css ../../build/website/styles.css | |
- name: Generate Remote Documentation | |
working-directory: docs | |
run: | | |
# This playbook renders the documentation | |
# content for the website. It includes | |
# master, develop, and tags. | |
GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" | |
export GH_TOKEN | |
npm ci | |
npx antora antora-playbook.yml | |
mkdir -p ../build/website/docs | |
cp -r build/site/* ../build/website/docs | |
- name: Upload Website as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Website ${{ runner.os }} | |
path: build/website | |
retention-days: 30 | |
- name: Generate Local Documentation | |
working-directory: docs | |
run: | | |
# This playbook allows us to render the | |
# documentation content and visualize it | |
# before a workflow that pushes to the | |
# website is triggered. | |
set -x | |
GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" | |
export GH_TOKEN | |
npx antora antora-playbook.yml --attribute branchesarray=HEAD --stacktrace | |
mkdir -p ../build/docs-local | |
cp -r build/site/* ../build/docs-local | |
- name: Generate Demos | |
run: | | |
declare -a generators=( | |
"adoc" | |
"xml" | |
) | |
# Generate the demos for each variant and generator | |
for variant in single multi; do | |
for generator in "${generators[@]}"; do | |
[[ $generator = xml && $variant = multi ]] && continue | |
[[ $variant = multi ]] && multipage="true" || multipage="false" | |
mrdocs --config="$(pwd)/boost/libs/url/doc/mrdocs.yml" "../CMakeLists.txt" --output="$(pwd)/demos/boost-url/$variant/$generator" --multipage=$multipage --generate="$generator" | |
echo "Number of files in demos/boost-url/$variant/$format: $(find demos/boost-url/$variant/$format -type f | wc -l)" | |
done | |
done | |
# Compress demos for the artifact | |
tar -cjf $(pwd)/demos.tar.gz -C $(pwd)/demos --strip-components 1 . | |
echo "demos_path=$(pwd)/demos.tar.gz" >> $GITHUB_ENV | |
- name: Upload Demos as Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: demos${{ (contains(fromJSON('["master", "develop"]'), github.ref_name ) && format('-{0}', github.ref_name)) || '' }}-${{ runner.os }} | |
path: demos.tar.gz | |
# develop and master are retained for longer so that they can be compared | |
retention-days: ${{ contains(fromJSON('["master", "develop"]'), github.ref_name) && '30' || '1' }} | |
- name: Download Previous Demos | |
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' | |
id: download-prev-demos | |
uses: actions/download-artifact@v4 | |
with: | |
name: demos-develop-${{ runner.os }} | |
path: demos-previous | |
- name: Compare demos | |
if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' && runner.os == 'Linux' | |
id: compare-demos | |
run: | | |
set -x | |
# Define URLs and directories | |
LOCAL_DEMOS_DIR="./demos/" | |
PREV_DEMOS_DIR="./demos-previous/" | |
DIFF_DIR="./demos-diff/" | |
# Create directories if they don't exist | |
mkdir -p $PREV_DEMOS_DIR $DIFF_DIR | |
# Iterate over the previous files and compare them with the corresponding local files | |
find $PREV_DEMOS_DIR -type f | while read previous_file; do | |
# Derive the corresponding local file path | |
local_file="${LOCAL_DEMOS_DIR}${previous_file#$PREV_DEMOS_DIR}" | |
diff_output="$DIFF_DIR${previous_file#$PREV_DEMOS_DIR}" | |
if [[ -f $local_file ]]; then | |
mkdir -p "$(dirname "$diff_output")" | |
diff "$previous_file" "$local_file" > "$diff_output" | |
if [[ ! -s $diff_output ]]; then | |
rm "$diff_output" | |
fi | |
else | |
echo "LOCAL FILE $local_file DOES NOT EXITS." > "$diff_output" | |
echo "PREVIOUS CONTENT OF THE FILE WAS:" >> "$diff_output" | |
cat "$previous_file" >> "$diff_output" | |
fi | |
done | |
# Iterate over the local files to find new files | |
find $LOCAL_DEMOS_DIR -type f | while read local_file; do | |
previous_file="${PREV_DEMOS_DIR}${local_file#$LOCAL_DEMOS_DIR}" | |
diff_output="$DIFF_DIR${local_file#$LOCAL_DEMOS_DIR}" | |
if [[ ! -f $previous_file ]]; then | |
echo "PREVIOUS $previous_file DOES NOT EXIST." > "$diff_output" | |
echo "IT HAS BEEN INCLUDED IN THIS VERSION." >> "$diff_output" | |
echo "NEW CONTENT OF THE FILE IS:" >> "$diff_output" | |
fi | |
done | |
# Check if the diff directory is empty | |
if [[ -z $(ls -A $DIFF_DIR) ]]; then | |
echo "No differences found." | |
# Store this as an output for the next step | |
echo "diff=false" >> $GITHUB_OUTPUT | |
else | |
# Calculate number of files in the diff directory | |
N_FILES=$(find $DIFF_DIR -type f | wc -l) | |
echo "Differences found in $N_FILES output files." | |
echo "diff=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload Demo Diff as Artifacts | |
if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' && steps.compare-demos.outputs.diff == 'true' && runner.os == 'Linux' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: demos-diff | |
path: demos-diff | |
retention-days: 30 | |
- name: Publish Website to GitHub Pages | |
if: github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) && runner.os == 'Linux' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: build/website | |
force_orphan: true | |
- name: Publish website | |
if: github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) && runner.os == 'Linux' | |
env: | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: | | |
# Add SSH key | |
mkdir -p /home/runner/.ssh | |
ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts | |
chmod 600 /home/runner/.ssh/known_hosts | |
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > /home/runner/.ssh/github_actions | |
chmod 600 /home/runner/.ssh/github_actions | |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
ssh-add /home/runner/.ssh/github_actions | |
# Copy files: This step will copy the landing page and the documentation to www.mrdocs.com | |
chmod 755 -R $(pwd)/build/website | |
scp -o StrictHostKeyChecking=no -r $(pwd)/build/website/* ubuntu@dev-websites.cpp.al:/var/www/mrdox.com/ | |
# Remove previous demos associated with this tag | |
demo_dir="/var/www/mrdox.com/demos/${{ github.ref_name }}" | |
ssh -o StrictHostKeyChecking=no ubuntu@dev-websites.cpp.al "rm -rf $demo_dir/boost-url; mkdir -p $demo_dir/boost-url" | |
# Copy demos: This step will copy the demos to www.mrdocs.com/demos | |
chmod 755 -R $(pwd)/demos | |
scp -o StrictHostKeyChecking=no -r $(pwd)/demos/* ubuntu@dev-websites.cpp.al:$demo_dir/ | |
- name: Create changelog | |
uses: alandefreitas/cpp-actions/create-changelog@v1.8.7 | |
with: | |
output-path: CHANGELOG.md | |
thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
limit: 150 | |
update-summary: ${{ runner.os == 'Linux' && 'true' || 'false' }} | |
- name: Create GitHub Package Release | |
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }} | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: packages/MrDocs-*.*.*-*.* | |
fail_on_unmatched_files: true | |
name: ${{ github.ref_name || github.ref }} | |
tag_name: ${{ github.ref_name || github.ref }}${{ ((!startsWith(github.ref, 'refs/tags/')) && '-release') || '' }} | |
body_path: CHANGELOG.md | |
prerelease: false | |
draft: false | |
token: ${{ github.token }} | |
llvm-releases: | |
needs: [ cpp-matrix, build ] | |
if: ${{ needs.cpp-matrix.outputs.llvm-matrix != '[]' && needs.cpp-matrix.outputs.llvm-matrix != '' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJSON(needs.cpp-matrix.outputs.llvm-matrix) }} | |
defaults: | |
run: | |
shell: bash | |
name: ${{ matrix.name }} LLVM Release | |
runs-on: ${{ matrix.runs-on }} | |
container: ${{ matrix.container }} | |
env: ${{ matrix.env }} | |
permissions: | |
contents: write | |
steps: | |
- name: Install packages | |
uses: alandefreitas/cpp-actions/package-install@v1.8.7 | |
id: package-install | |
with: | |
apt-get: ${{ matrix.install }} | |
- name: Check website releases | |
id: website-releases | |
run: | | |
set -x | |
archive_url="https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}" | |
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$archive_url") | |
if [ "$http_status" -eq 200 ]; then | |
exists="true" | |
else | |
exists="false" | |
fi | |
echo "exists=$exists" >> $GITHUB_OUTPUT | |
- name: Resolve LLVM Root | |
id: resolve-llvm-root | |
run: | | |
set -x | |
cd .. | |
llvm_root=$(pwd)/third-party/llvm-project/install | |
if [[ ${{ runner.os }} == 'Windows' ]]; then | |
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g') | |
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|') | |
echo "$llvm_root" | |
fi | |
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT | |
- name: LLVM Binaries | |
id: llvm-cache | |
if: steps.website-releases.outputs.exists != 'true' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }} | |
key: ${{ matrix.llvm-cache-key }} | |
- name: Compress LLVM | |
id: llvm-upload | |
if: steps.llvm-cache.outputs.cache-hit == 'true' | |
shell: bash | |
run: | | |
# LLVM is be installed with the default compiler | |
set -x | |
# Compress the LLVM installation | |
cd ../third-party/llvm-project | |
# Use 7z on windows | |
if [[ ${{ runner.os }} == 'Windows' ]]; then | |
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on ${{ matrix.llvm-archive-filename }} install | |
else | |
tar -cjf ${{ matrix.llvm-archive-filename }} -C install . | |
fi | |
- name: Website LLVM Releases | |
if: steps.llvm-cache.outputs.cache-hit == 'true' && github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) | |
working-directory: ../third-party/llvm-project | |
run: | | |
set -x | |
# Ensure required commands exist | |
for cmd in ssh-keyscan ssh-agent ssh-add scp; do | |
if ! command -v $cmd >/dev/null; then | |
echo "$cmd not found" | |
exit 1 | |
fi | |
done | |
# Add SSH key | |
mkdir -p ~/.ssh | |
ssh-keyscan dev-websites.cpp.al >> ~/.ssh/known_hosts | |
chmod 600 ~/.ssh/known_hosts | |
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > ~/.ssh/github_actions | |
chmod 600 ~/.ssh/github_actions | |
# Start ssh-agent and add the key | |
SSH_AUTH_SOCK="$RUNNER_TEMP/ssh_agent.sock" | |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
ssh-add ~/.ssh/github_actions | |
# Copy llvm archive: This step will copy the archive to www.mrdocs.com/llvm+clang | |
llvm_dir="/var/www/mrdox.com/llvm+clang" | |
chmod 755 ${{ matrix.llvm-archive-filename }} | |
scp -o StrictHostKeyChecking=no $(pwd)/${{ matrix.llvm-archive-filename }} ubuntu@dev-websites.cpp.al:$llvm_dir/ |