refactor: templatize fitness value type and fix edge cases #16
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| VCPKG_COMMIT: "d7112d1a4fb50410d3639f5f586972591d848beb" | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: cachix/install-nix-action@v30 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - name: Lint | |
| run: nix develop --command cmake -P cmake/lint.cmake | |
| - name: Spell check | |
| if: always() | |
| run: | | |
| nix run nixpkgs#codespell -- \ | |
| --config .codespellrc | |
| sanitize: | |
| needs: [lint] | |
| runs-on: ubuntu-24.04 | |
| env: { CXX: clang++-18 } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install vcpkg | |
| uses: friendlyanon/setup-vcpkg@v1 | |
| with: { committish: "${{ env.VCPKG_COMMIT }}" } | |
| - name: Configure | |
| run: cmake --preset=ci-sanitize | |
| - name: Build | |
| run: cmake --build build/sanitize -j 2 | |
| - name: Test | |
| working-directory: build/sanitize | |
| env: | |
| ASAN_OPTIONS: "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1:halt_on_error=1" | |
| UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1" | |
| run: ctest --output-on-failure --no-tests=error -j 2 | |
| test: | |
| needs: [lint] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-14, ubuntu-24.04, windows-2022] | |
| type: [shared, static] | |
| include: | |
| - { type: shared, shared: YES } | |
| - { type: static, shared: NO } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install static analyzers | |
| if: matrix.os == 'ubuntu-24.04' | |
| run: | | |
| sudo apt-get install clang-tidy-18 cppcheck -y -q | |
| sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 180 | |
| - name: Install vcpkg | |
| uses: friendlyanon/setup-vcpkg@v1 | |
| with: { committish: "${{ env.VCPKG_COMMIT }}" } | |
| - name: Setup MultiToolTask | |
| if: matrix.os == 'windows-2022' | |
| run: | | |
| Add-Content "$env:GITHUB_ENV" 'UseMultiToolTask=true' | |
| Add-Content "$env:GITHUB_ENV" 'EnforceProcessCountAcrossBuilds=true' | |
| - name: Configure | |
| shell: pwsh | |
| run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])" -D BUILD_SHARED_LIBS=${{ matrix.shared }} | |
| - name: Setup PATH | |
| if: matrix.os == 'windows-2022' && matrix.type == 'shared' | |
| run: Add-Content "$env:GITHUB_PATH" "$(Get-Location)\build\Release" | |
| - name: Build | |
| run: cmake --build build --config Release -j 2 | |
| - name: Install | |
| run: cmake --install build --config Release --prefix prefix | |
| - name: Test | |
| working-directory: build | |
| shell: pwsh | |
| run: | | |
| if ($IsWindows) { chcp 65001 | Out-Null } | |
| ctest --output-on-failure --no-tests=error -C Release -j 2 | |
| python: | |
| needs: [lint] | |
| runs-on: ubuntu-24.04 | |
| env: { CXX: clang++-18 } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: { python-version: "3.12" } | |
| - name: Install static analyzers | |
| run: | | |
| sudo apt-get install clang-tidy-18 cppcheck -y -q | |
| sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 180 | |
| - name: Install vcpkg | |
| uses: friendlyanon/setup-vcpkg@v1 | |
| with: { committish: "${{ env.VCPKG_COMMIT }}" } | |
| - name: Configure | |
| run: cmake --preset=ci-ubuntu -D VCPKG_MANIFEST_FEATURES="test;python" | |
| - name: Build | |
| run: cmake --build build --config Release -j 2 | |
| - name: Test C++ | |
| working-directory: build | |
| run: ctest --output-on-failure --no-tests=error -C Release -j 2 | |
| - name: Test Python bindings | |
| run: | | |
| python3 -c " | |
| import sys, glob | |
| # Find the built _ndsort extension | |
| exts = glob.glob('build/**/_ndsort*', recursive=True) | |
| if not exts: | |
| print('ERROR: _ndsort extension not found') | |
| sys.exit(1) | |
| ext_dir = '/'.join(exts[0].split('/')[:-1]) | |
| sys.path.insert(0, ext_dir) | |
| sys.path.insert(0, 'python') | |
| import ndsort | |
| import numpy as np | |
| pop = np.array([[0.0, 1.0], [1.0, 0.0], [0.5, 0.5], [2.0, 2.0]]) | |
| fronts = ndsort.rank_intersect(pop) | |
| assert len(fronts) == 2 | |
| assert len(fronts[0]) == 3 | |
| print('Python bindings OK') | |
| " |