Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/ccache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Setup Compiler Cache
description: Prepare and restore compiler cache using ccache
inputs:
key_segment:
description: "Segment identifying the run for use in the cache key"
required: true

runs:
using: "composite"
steps:
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache-ccache
with:
path: ${{ steps.prep-ccache.outputs.dir }}
key: ccache-v0-${{ inputs.key_segment }}-${{ steps.prep-ccache.outputs.timestamp }}
restore-keys: ccache-v0-${{ inputs.key_segment }}
- name: Install Pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.77.0
run-install: false
cache: false
- name: Reset ccache stats
shell: bash
run: |
# Restoring the cache also restored the stats from the previous run
pixi exec ccache --zero-stats
# Invoking `setup-pixi` again expects `pixi` to not already be there
# ref. https://github.com/prefix-dev/setup-pixi/issues/281
rm $HOME/.pixi/bin/pixi
11 changes: 2 additions & 9 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on: [ push, pull_request ]
permissions:
contents: read # to fetch code (actions/checkout)

env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand All @@ -16,17 +13,13 @@ jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
environment: [lint]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.75.0
pixi-version: v0.76.1
cache: true
environments: ${{ matrix.environment }}
environments: lint
- name: Check for formatting violations
run: |
pixi run format-dry-error
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/gpu_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ jobs:

- uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.75.0
pixi-version: v0.76.1
manifest-path: pixi.toml
cache: true
cache-key: gpu-pixi-
environments: cupy-tests

- name: Run CuPy tests
run: pixi run test-cupy
122 changes: 45 additions & 77 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on: [ push, pull_request ]
permissions:
contents: read # to fetch code (actions/checkout)

env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand All @@ -20,28 +17,24 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
environment: [coverage]
env:
CCACHE_DIR: ${{ github.workspace }}/packages/coverage/.ccache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- uses: ./.github/ccache
with:
key_segment: ${{ github.workflow }}-${{ matrix.environment }}-${{ matrix.runs-on }}
- name: Setup ${{ matrix.environment }} environment
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.75.0
pixi-version: v0.77.0
cache: true
environments: coverage
- name: Prepare compiler cache
id: prep-ccache
cache-key: pixi-v0-${{ github.job }}
environments: ${{ matrix.environment }}
- name: Ccache performance
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache-ccache
with:
path: ${{ steps.prep-ccache.outputs.dir }}
key: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-release-${{ steps.prep-ccache.outputs.timestamp }}
restore-keys: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-release-
run: pixi exec ccache -s
- name: Determine number of workers
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
Expand All @@ -52,53 +45,42 @@ jobs:
echo "NUM_WORKERS=$NUMBER_OF_PROCESSORS" >> "$GITHUB_ENV"
fi
shell: bash
- name: Build xsf
run: pixi run build-tests-cov
- name: Run tests
run: pixi run --skip-deps tests-only $NUM_WORKERS
run: pixi run --environment=coverage tests $NUM_WORKERS
- name: Generate coverage report
if: runner.os != 'Windows'
run: pixi run --skip-deps coverage $NUM_WORKERS
run: pixi run --skip-deps coverage
- name: Upload HTML coverage report
if: runner.os != 'Windows'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cov-html-${{ matrix.runs-on }}
path: build/coverage_report/**
- name: Ccache performance
shell: bash -l {0}
run: pixi run ccache -s
path: .pixi/envs/coverage/share/xsf/cov/coverage_report/**

release:
tests-release:
# for platforms without coverage support
name: Release
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [windows-latest]
environment: [tests-release]
env:
CCACHE_DIR: ${{ github.workspace }}/packages/tests-release/.ccache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- uses: ./.github/ccache
with:
pixi-version: v0.75.0
key_segment: ${{ github.workflow }}-${{ matrix.environment }}-${{ matrix.runs-on }}
- name: Setup ${{ matrix.environment }} environment
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.77.0
cache: true
environments: default
- name: Prepare compiler cache
id: prep-ccache
cache-key: pixi-v0-${{ github.job }}
environments: ${{ matrix.environment }}
- name: Ccache performance
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache-ccache
with:
path: ${{ steps.prep-ccache.outputs.dir }}
key: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-release-${{ steps.prep-ccache.outputs.timestamp }}
restore-keys: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-release-
run: pixi exec ccache -s
- name: Determine number of workers
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
Expand All @@ -109,13 +91,8 @@ jobs:
echo "NUM_WORKERS=$NUMBER_OF_PROCESSORS" >> "$GITHUB_ENV"
fi
shell: bash
- name: Build xsf
run: pixi run build-tests
- name: Run tests
run: pixi run --skip-deps tests-only $NUM_WORKERS
- name: Ccache performance
shell: bash -l {0}
run: pixi run ccache -s
run: pixi run --environment=${{ matrix.environment }} tests $NUM_WORKERS

tests-debug:
name: Debug ${{ matrix.runs-on }}
Expand All @@ -124,28 +101,24 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, ubuntu-24.04-arm]
environment: [tests-debug]
env:
CCACHE_DIR: ${{ github.workspace }}/packages/tests-debug/.ccache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- uses: ./.github/ccache
with:
key_segment: ${{ github.workflow }}-${{ matrix.environment }}-${{ matrix.runs-on }}
- name: Setup ${{ matrix.environment }} environment
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
pixi-version: v0.75.0
pixi-version: v0.77.0
cache: true
environments: default
- name: Prepare compiler cache
id: prep-ccache
cache-key: pixi-v0-${{ github.job }}
environments: ${{ matrix.environment }}
- name: Ccache performance
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache-ccache
with:
path: ${{ steps.prep-ccache.outputs.dir }}
key: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-debug-${{ steps.prep-ccache.outputs.timestamp }}
restore-keys: v4-${{ github.workflow }}-ccache-${{ matrix.runs-on }}-debug-
run: pixi exec ccache -s
- name: Determine number of workers
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
Expand All @@ -156,10 +129,5 @@ jobs:
echo "NUM_WORKERS=$NUMBER_OF_PROCESSORS" >> "$GITHUB_ENV"
fi
shell: bash
- name: Build xsf
run: pixi run build-tests-debug
- name: Run tests
run: pixi run --skip-deps tests-debug $NUM_WORKERS
- name: Ccache performance
shell: bash -l {0}
run: pixi run ccache -s
run: pixi run --environment=${{ matrix.environment }} tests $NUM_WORKERS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.cache
.ccache

# Prerequisites
*.d
Expand Down
32 changes: 25 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
cmake_minimum_required(VERSION 3.14)
project(xsf)

add_library(xsf INTERFACE)

# Scipy is restricted to C++17
# https://docs.scipy.org/doc/scipy/dev/toolchain.html#c-language-standards
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_features(xsf INTERFACE cxx_std_17)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "")
endif()
target_include_directories(xsf
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

install(
TARGETS xsf
EXPORT xsfTargets
)

install(
DIRECTORY include/
DESTINATION include
)

install(
EXPORT xsfTargets
FILE xsfTargets.cmake
NAMESPACE xsf::
DESTINATION lib/cmake/xsf
)

# Tests
option(BUILD_TESTS "Build the tests" OFF)
Expand Down
41 changes: 41 additions & 0 deletions packages/coverage/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = { workspace = true }
version = { workspace = true }
build = {
backend.name = "pixi-build-cmake",
config.extra-args = [
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DBUILD_TESTS=ON",
"-DCMAKE_BUILD_TYPE=Coverage",
],
flags = ["tests", "coverage"],
source.path = "../..",
# RECIPE_DIR references the current working directory,
# enabling ccache specific to this build variant.
target.unix.config.env = {
CCACHE_DIR = "$RECIPE_DIR/.ccache",
CCACHE_BASEDIR = "$RECIPE_DIR",
},
target.win.config.env = {
CCACHE_DIR = "%RECIPE_DIR%\\.ccache",
CCACHE_BASEDIR = "%RECIPE_DIR%.",
},
}
build-dependencies = {
xsref = {
git = "https://github.com/lucascolley/xsref",
rev = "6d4891c435c8525d535bf5038142414603edbd27",
},
ccache = "*",
}
host-dependencies = {
catch2 = "*",
libarrow-all = "*",
}
run-dependencies = {
cmake = "*",
lcov = "*",
"if(linux)" = {
gcc = "16.*", # for gcov
}
}
Loading
Loading