Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
112 changes: 62 additions & 50 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ env:
MULL_LLVM_VERSION: 20.1.2
MULL_VERSION: 0.34.0
HYPOTHESIS_PROFILE: default
UV_CACHE_DIR: /tmp/.uv-cache
PIPX_BIN_DIR: /tmp/.pipx_bin

concurrency:
group: ${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -120,21 +122,49 @@ jobs:
DISTRO=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb "https://apt.llvm.org/$DISTRO/" "llvm-toolchain-$DISTRO-${{matrix.version}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{matrix.version}} libc++-${{matrix.version}}-dev libc++abi-${{matrix.version}}-dev
sudo apt update && sudo apt install -y pipx ninja-build clang-${{matrix.version}} libc++-${{matrix.version}}-dev libc++abi-${{matrix.version}}-dev
else
sudo apt update && sudo apt install -y ninja-build gcc-${{matrix.version}} g++-${{matrix.version}}
sudo apt update && sudo apt install -y pipx ninja-build gcc-${{matrix.version}} g++-${{matrix.version}}
fi

- &install_uv
name: Install uv
run: |
pipx install uv
echo "$PIPX_BIN_DIR" >> "$GITHUB_PATH"

- &restore_uv_cache
name: Restore uv cache
env:
cache-name: uv-cache-0
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{env.UV_CACHE_DIR}}
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('uv.lock') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-${{ hashFiles('uv.lock') }}
${{runner.os}}-${{env.cache-name}}-

- &setup_python
name: Setup python venv
working-directory: ${{github.workspace}}
run: |
uv venv -c
source .venv/bin/activate
uv sync
echo "$(pwd)/.venv/bin" >> "$GITHUB_PATH"

- &restore_cpm_cache
name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
${{runner.os}}-${{env.cache-name}}-

- name: Configure CMake
Expand All @@ -143,31 +173,17 @@ jobs:
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}} -DCMAKE_CXX_FLAGS_INIT=${{matrix.cxx_flags}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCPM_SOURCE_CACHE=~/cpm-cache

- &save_cpm_cache
name: Save CPM cache
env:
cache-name: cpm-cache-0
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}

- &python_test_reqs
name: Install python test requirements
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest --output-on-failure -j -C ${{matrix.build_type}}

- &minimize_uv_cache
name: Minimize uv cache
run: uv cache prune --ci

quality_checks_pass:
runs-on: *runner
steps:
Expand All @@ -183,23 +199,16 @@ jobs:
- name: Checkout PR branch
uses: *checkout

- name: Setup python venv
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Install build tools
run: |
DISTRO=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb "https://apt.llvm.org/$DISTRO/" "llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-tidy-${{env.DEFAULT_LLVM_VERSION}} clang-format-${{env.DEFAULT_LLVM_VERSION}}

- name: Install cmake-format
run: |
pip install cmakelang pyyaml
sudo apt update && sudo apt install -y pipx ninja-build clang-tidy-${{env.DEFAULT_LLVM_VERSION}} clang-format-${{env.DEFAULT_LLVM_VERSION}}

- *install_uv
- *restore_uv_cache
- *setup_python
- *restore_cpm_cache

- name: Configure CMake
Expand All @@ -209,11 +218,11 @@ jobs:
PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- *save_cpm_cache

- name: Run quality checks
run: cmake --build ${{github.workspace}}/build -t ci-quality

- *minimize_uv_cache

sanitize:
runs-on: *runner
strategy:
Expand All @@ -240,11 +249,14 @@ jobs:
DISTRO=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb "https://apt.llvm.org/$DISTRO/" "llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{env.DEFAULT_LLVM_VERSION}}
sudo apt update && sudo apt install -y pipx ninja-build clang-${{env.DEFAULT_LLVM_VERSION}}
else
sudo apt update && sudo apt install -y ninja-build ${{matrix.cc}} ${{matrix.cxx}}
sudo apt update && sudo apt install -y pipx ninja-build ${{matrix.cc}} ${{matrix.cxx}}
fi

- *install_uv
- *restore_uv_cache
- *setup_python
- *restore_cpm_cache

- name: Configure CMake
Expand All @@ -254,10 +266,6 @@ jobs:
SANITIZERS: ${{matrix.sanitizer}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- *save_cpm_cache

- *python_test_reqs

# https://github.com/actions/runner-images/issues/9524
- name: Fix kernel mmap rnd bits
# Asan in llvm 14 provided in ubuntu 22.04 is incompatible with
Expand All @@ -268,15 +276,20 @@ jobs:
- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build -t unit_tests

- *minimize_uv_cache

valgrind:
runs-on: *runner
steps:
- uses: *checkout

- name: Install build tools
run: |
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind python3-venv python3-pip
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} pipx ninja-build valgrind

- *install_uv
- *restore_uv_cache
- *setup_python
- *restore_cpm_cache

- name: Configure CMake
Expand All @@ -285,10 +298,6 @@ jobs:
CXX: "/usr/bin/g++-${{env.DEFAULT_GCC_VERSION}}"
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- *save_cpm_cache

- *python_test_reqs

- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build -t build_unit_tests

Expand Down Expand Up @@ -325,6 +334,8 @@ jobs:
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
test "$FAILSIZE" = "0"

- *minimize_uv_cache

mutate:
runs-on: *runner
steps:
Expand All @@ -335,7 +346,7 @@ jobs:
DISTRO=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb "https://apt.llvm.org/$DISTRO/" "llvm-toolchain-$DISTRO-${{env.MULL_LLVM_MAJOR_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{env.MULL_LLVM_MAJOR_VERSION}}
sudo apt update && sudo apt install -y pipx ninja-build clang-${{env.MULL_LLVM_MAJOR_VERSION}}

- name: Install mull
env:
Expand All @@ -345,6 +356,9 @@ jobs:
wget -O "$MULL_DEB" https://github.com/mull-project/mull/releases/download/${{env.MULL_VERSION}}/${{env.mull-pkg}}
sudo dpkg -i "$MULL_DEB"

- *install_uv
- *restore_uv_cache
- *setup_python
- *restore_cpm_cache

- name: Configure CMake
Expand All @@ -353,13 +367,11 @@ jobs:
CXX: "/usr/lib/llvm-${{env.MULL_LLVM_MAJOR_VERSION}}/bin/clang++"
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- *save_cpm_cache

- *python_test_reqs

- name: Build and run mull tests
run: cmake --build build -t mull_tests

- *minimize_uv_cache

merge_ok:
runs-on: *runner
needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind]
Expand Down
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[project]
name = "intel-cpp-std-extensions"
version = "0.0.1"
requires-python = ">=3.12"
dependencies = [
"intel-cicd-repo-infrastructure"
]
license = "BSL-1.0"

[project.urls]
Repository = "https://github.com/intel/cpp-std-extensions/"
Documentation = "https://intel.github.io/cpp-std-extensions/"

[tool.setuptools]
packages = []

[tool.uv.sources]
intel-cicd-repo-infrastructure = { git = "https://github.com/intel/cicd-repo-infrastructure", branch = "dev" }
42 changes: 14 additions & 28 deletions test/pbt/tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,22 @@ def tuple_trees(draw, leaves=st.integers()):
@settings(deadline=50000)
@given(tuple_trees(small_ints))
def test_tuple_trees(compile, t):
assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>

[[maybe_unused]] constexpr auto t = {t};

int main() {{
return 0;
}}
"""
)
""")


@settings(deadline=50000)
@given(list_trees(small_ints))
def test_tuple_size(compile, l):
t = as_tuple_tree(l)
assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>

constexpr auto t = {t};
Expand All @@ -68,8 +65,7 @@ def test_tuple_size(compile, l):
int main() {{
return 0;
}}
"""
)
""")


@settings(deadline=50000)
Expand All @@ -81,8 +77,7 @@ def test_get_by_index(compile, l, i):

expected_v = as_tuple_tree(l[i])

assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>

using namespace stdx::literals;
Expand All @@ -105,8 +100,7 @@ def test_get_by_index(compile, l, i):
int main() {{
return 0;
}}
"""
)
""")


@settings(deadline=50000)
Expand All @@ -117,8 +111,7 @@ def test_tuple_cat(compile, ls):
flattened_ls = [i for subl in ls for i in subl]
expected = as_tuple_tree(flattened_ls)

assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>
#include <stdx/tuple_algorithms.hpp>

Expand All @@ -127,8 +120,7 @@ def test_tuple_cat(compile, ls):
int main() {{
return 0;
}}
"""
)
""")


@settings(deadline=50000)
Expand All @@ -144,8 +136,7 @@ def test_push(compile, l, elem):

t = as_tuple_tree(l)

assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>
#include <stdx/tuple_algorithms.hpp>

Expand All @@ -163,8 +154,7 @@ def test_push(compile, l, elem):
int main() {{
return 0;
}}
"""
)
""")


from itertools import product
Expand All @@ -184,8 +174,7 @@ def test_cartesian_product(compile, ls):
ts = [as_tuple_tree(l) for l in ls]
expected = as_tuple_tree([list(p) for p in product(*ls)])

assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>
#include <stdx/tuple_algorithms.hpp>

Expand All @@ -194,8 +183,7 @@ def test_cartesian_product(compile, ls):
int main() {{
return 0;
}}
"""
)
""")


from functools import reduce
Expand All @@ -210,8 +198,7 @@ def test_star_of(compile, l):

t = as_tuple_tree(l)

assert compile(
f"""
assert compile(f"""
#include <stdx/tuple.hpp>
#include <stdx/tuple_algorithms.hpp>

Expand All @@ -224,5 +211,4 @@ def test_star_of(compile, l):
int main() {{
return 0;
}}
"""
)
""")
Loading