Supporting clang-cl in tests #123
This file contains hidden or 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: Test | |
| on: | |
| push: | |
| paths-ignore: | |
| - 'README.md' | |
| - '.gitignore' | |
| - 'LICENSE' | |
| - 'CHANGELOG.md' | |
| - 'doc/**' | |
| - 'tools/**' | |
| jobs: | |
| define-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| hosts: ${{ steps.matrix.outputs.hosts }} | |
| containers: ${{ steps.matrix.outputs.containers }} | |
| steps: | |
| - name: Define Matrix | |
| id: matrix | |
| shell: python | |
| run: | | |
| import json | |
| import os | |
| macos_map = { | |
| 'macos-13': "14.3.1", | |
| 'macos-14': "15.4", | |
| 'macos-15': "16.2" | |
| } | |
| win_paltforms = ["x64", "Win32"] | |
| win_clang_archs = ["x64", "x86"] | |
| gcc_map = { | |
| 11: 'ubuntu-latest', | |
| 12: 'ubuntu-latest', | |
| 13: 'ubuntu-latest', | |
| 14: 'ubuntu-24.04' | |
| } | |
| gcc_cont_map = { | |
| 15: 'gcc:15.1' | |
| } | |
| clang_map = { | |
| 13: 'ubuntu-22.04', | |
| 14: 'ubuntu-22.04', | |
| 15: 'ubuntu-22.04', | |
| 16: 'ubuntu-22.04', | |
| 17: 'ubuntu-latest', | |
| 18: 'ubuntu-latest', | |
| 19: 'ubuntu-latest', | |
| 20: 'ubuntu-latest' | |
| } | |
| hosts = [] | |
| containers=[] | |
| #macOS | |
| for runon, xcode in macos_map.items(): | |
| hosts.append({'os': runon, 'version': xcode, 'jobname': f'macOS - Xcode{xcode}'}) | |
| #windows | |
| for platform in win_paltforms: | |
| hosts.append({'os': 'windows-latest', 'platform': platform, 'module': true, 'jobname': f'Windows - {platform}'}) | |
| for arch in win_clang_archs: | |
| hosts.append({'os': 'windows-latest', 'arch': arch, 'compiler': 'clang-cl', 'module': false, 'jobname': f'Windows - clang - {arch}'}) | |
| #gcc hosts | |
| for gcc, runon in gcc_map.items(): | |
| hosts.append({'os': runon, 'compiler': 'gcc', 'version': gcc, 'module': gcc >= 14, | |
| 'jobname': f'Linux - GCC{gcc}'}) | |
| #gcc containers | |
| for gcc, container in gcc_cont_map.items(): | |
| containers.append({'container': container, 'module': gcc >= 14, | |
| 'jobname': f'Linux - GCC{gcc}'}) | |
| #clang | |
| for clang, runon in clang_map.items(): | |
| hosts.append({'os': runon, 'compiler': 'clang', 'version': clang, 'module': clang >= 18, | |
| 'jobname': f'Linux - Clang{clang}'}) | |
| with open(os.environ['GITHUB_OUTPUT'], 'w') as env: | |
| print('hosts=' + json.dumps(hosts), file=env) | |
| print('containers=' + json.dumps(containers), file=env) | |
| standard: | |
| needs: define-matrix | |
| name: ${{ matrix.jobname }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.define-matrix.outputs.hosts) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: System Setup | |
| shell: bash | |
| run: | | |
| if [[ '${{ matrix.os }}' == ubuntu-* ]]; then | |
| if [[ '${{ matrix.compiler }}' == 'clang' ]]; then | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod u+x llvm.sh | |
| sudo ./llvm.sh ${{ matrix.version }} | |
| sudo apt-get install -y clang-tools-${{ matrix.version }} | |
| echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV | |
| echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV | |
| fi | |
| if [[ '${{ matrix.compiler }}' == 'gcc' ]]; then | |
| sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-${{ matrix.version }} g++-${{ matrix.version }} | |
| echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV | |
| echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV | |
| fi | |
| mkdir bin | |
| wget -qO- https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip | \ | |
| gunzip > bin/ninja | |
| chmod a+x bin/ninja | |
| echo PATH=`pwd`/bin:$PATH >> $GITHUB_ENV | |
| echo "CMAKE_GENERATOR=-GNinja" >> $GITHUB_ENV | |
| fi | |
| if [[ '${{ matrix.os }}' == macos-* ]]; then | |
| echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.version }}.app" >> $GITHUB_ENV | |
| fi | |
| if [[ '${{ matrix.os }}' == windows-* ]]; then | |
| if [[ '${{ matrix.compiler }}' != '' ]]; then | |
| if [[ '${{ matrix.arch }}' == "x64" ]]; then | |
| VCPREFIX="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\Llvm\\x64\\bin" | |
| else | |
| VCPREFIX="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\Llvm\\bin" | |
| fi | |
| echo "CC=$VCPREFIX\\${{ matrix.compiler }}" >> $GITHUB_ENV | |
| echo "CXX=$VCPREFIX\\${{ matrix.compiler }}" >> $GITHUB_ENV | |
| echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV | |
| fi | |
| fi | |
| if [[ '${{ matrix.module}}' == 'true' ]]; then | |
| echo "CMAKE_ARGS=-DISPTR_ENABLE_MODULE=ON" >> $GITHUB_ENV | |
| fi | |
| - name: Configure | |
| shell: bash | |
| run: | | |
| if [[ '${{ matrix.platform }}' != "" ]]; then | |
| export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }}" | |
| fi | |
| cmake $CMAKE_GENERATOR -S . -B build $CMAKE_ARGS -DISPTR_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release | |
| - name: Build and Test | |
| shell: bash | |
| run: | | |
| cmake --build build --config Release --target run-test | |
| container: | |
| needs: define-matrix | |
| name: ${{ matrix.jobname }} | |
| runs-on: ubuntu-latest | |
| container: ${{ matrix.container }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.define-matrix.outputs.containers) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: System Setup | |
| shell: bash | |
| run: | | |
| apt-get update | |
| apt-get install -y python3-dev | |
| export CMAKE_VERSION=3.28.6 | |
| wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \ | |
| -q -O /tmp/cmake-install.sh \ | |
| && chmod u+x /tmp/cmake-install.sh \ | |
| && /tmp/cmake-install.sh --skip-license --prefix=/usr \ | |
| rm -f /tmp/cmake-install.sh | |
| wget -qO- https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip | \ | |
| gunzip > /usr/bin/ninja | |
| chmod a+x /usr/bin/ninja | |
| echo "CMAKE_GENERATOR=-GNinja" >> $GITHUB_ENV | |
| if [[ '${{ matrix.module}}' == 'true' ]]; then | |
| echo "CMAKE_ARGS=-DISPTR_ENABLE_MODULE=ON" >> $GITHUB_ENV | |
| fi | |
| - name: Configure | |
| shell: bash | |
| run: | | |
| cmake $CMAKE_GENERATOR -S . -B build $CMAKE_ARGS -DISPTR_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release | |
| - name: Build and Test | |
| shell: bash | |
| run: | | |
| cmake --build build --config Release --target run-test | |
| big-endian: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ninja-build gcc-powerpc-linux-gnu g++-powerpc-linux-gnu qemu-user-binfmt | |
| - name: Configure | |
| run: | | |
| export CC=powerpc-linux-gnu-gcc | |
| export CXX=powerpc-linux-gnu-g++ | |
| export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu/ | |
| cmake -GNinja -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=powerpc | |
| - name: Build and Test | |
| shell: bash | |
| run: | | |
| export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu/ | |
| cmake --build build --config Release --target run-test |