diff --git a/.github/matrix.json b/.github/matrix.json new file mode 100644 index 00000000..8be64b25 --- /dev/null +++ b/.github/matrix.json @@ -0,0 +1,29 @@ +{ + "config": [ + { + "name": "Linux GCC 11", + "compiler": "gcc", + "version": "11", + "os": "ubuntu-22.04" + }, + { + "name": "Linux Clang 14", + "compiler": "clang", + "version": "14", + "os": "ubuntu-22.04" + }, + { + "name": "macOS apple-clang 13.0.1", + "compiler": "apple-clang", + "version": "13.0.1", + "os": "macos-11" + }, + { + "name": "Windows VS2019", + "compiler": "Visual Studio", + "version": "16", + "os": "windows-2019", + "cmake_toolset": "Visual Studio 16 2019" + } + ] +} diff --git a/.github/workflows/adobe_source_libraries.yml b/.github/workflows/adobe_source_libraries.yml new file mode 100644 index 00000000..bbe3c057 --- /dev/null +++ b/.github/workflows/adobe_source_libraries.yml @@ -0,0 +1,112 @@ +name: Build and Tests + +on: + pull_request: + push: + branches: + - main + +jobs: + generate-matrix: + name: Generate job matrix + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + + - name: Generate job matrix + id: set-matrix + # Note: The json in this variable must be a single line for parsing to succeed. + run: echo "::set-output name=matrix::$(cat .github/matrix.json | scripts/flatten_json.py)" + + builds: + needs: generate-matrix + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}} + name: ${{ matrix.config.name }} + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies (macos) + if: ${{ startsWith(matrix.config.os, 'macos') }} + run: | + brew install ninja + shell: bash + + - name: Install dependencies (ubuntu) + if: ${{ startsWith(matrix.config.os, 'ubuntu') }} + run: | + sudo apt-get install -y ninja-build + shell: bash + + - name: Install dependencies (Windows) + if: ${{ startsWith(matrix.config.os, 'windows') }} + run: | + choco install --yes ninja + shell: cmd + + - name: Set enviroment variables (Linux+GCC) + if: ${{ matrix.config.compiler == 'gcc' }} + shell: bash + run: | + echo "CC=gcc-${{matrix.config.version}}" >> $GITHUB_ENV + echo "CXX=g++-${{matrix.config.version}}" >> $GITHUB_ENV + + - name: Set enviroment variables (Linux+Clang) + if: ${{ matrix.config.compiler == 'clang' }} + shell: bash + run: | + echo "CC=clang-${{matrix.config.version}}" >> $GITHUB_ENV + echo "CXX=clang++-${{matrix.config.version}}" >> $GITHUB_ENV + + - name: Set enviroment variables (MacOS) + if: ${{ matrix.config.compiler == 'apple-clang' }} + shell: bash + run: | + echo "CC=$(brew --prefix llvm@13)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@13)/bin/clang++" >> $GITHUB_ENV + + - name: Configure (Ubuntu) + if: ${{ startsWith(matrix.config.os, 'ubuntu') }} + shell: bash + run: | + mkdir ../build + cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 + + - name: Configure (MacOS) + if: ${{ startsWith(matrix.config.os, 'macos') }} + shell: bash + run: | + mkdir ../build + cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 + + - name: Configure (Windows) + if: ${{ startsWith(matrix.config.os, 'windows') }} + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + mkdir ..\build + cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 + + - name: Build (Unix) + if: ${{ startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos') }} + shell: bash + run: | + cmake --build ../build/ + + - name: Build (windows) + if: ${{ startsWith(matrix.config.os, 'windows') }} + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + cmake --build ../build/ + + - name: Test + shell: bash + run: | + cd ../build/ + ctest diff --git a/scripts/flatten_json.py b/scripts/flatten_json.py new file mode 100755 index 00000000..a419bda8 --- /dev/null +++ b/scripts/flatten_json.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +import functools as ft +import json +import sys + +input = ft.reduce(lambda acc, i: acc + i, sys.stdin, "") +print(json.dumps(json.loads(input), separators=(',', ':')))