Skip to content

Commit

Permalink
Added some actions for testing and install.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jun 13, 2024
1 parent 9bf7fd3 commit 81166b6
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/check-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
push:
branches:
- master
pull_request:

name: Check CMake install

jobs:
install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Install knncolle
run: |
git clone https://github.com/knncolle/knncolle dep-knncolle --depth=1
cd dep-knncolle
cmake -S . -B build -DKNNCOLLE_TESTS=OFF
sudo cmake --install build
- name: Install Annoy
run: |
git clone https://github.com/nmslib/hnswlib dep-hnsw --depth=1
cd dep-hnsw
cmake -S . -B build
sudo cmake --install build
- name: Configure the build
run: cmake -S . -B build -DKNNCOLLE_HNSW_TESTS=OFF -DKNNCOLLE_HNSW_FETCH_EXTERN=OFF

- name: Install the library
run: sudo cmake --install build

- name: Test downstream usage
run: |
mkdir _downstream
touch _downstream/source.cpp
cat << EOF > _downstream/CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(test_install)
add_executable(whee source.cpp)
find_package(knncolle_knncolle_hnsw)
target_link_libraries(whee knncolle::knncolle_hnsw)
EOF
cd _downstream && cmake -S . -B build
70 changes: 70 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
on:
push:
branches:
- master
pull_request:

name: Run unit tests

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Latest GCC, coverage enabled",
os: ubuntu-latest,
cov: true
}
- {
name: "macOS Latest Clang",
os: macos-latest,
cov: false
}

steps:
- uses: actions/checkout@v4

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Configure the build
if: ${{ matrix.config.cov == false }}
run: cmake -S . -B build

- name: Configure the build with coverage
if: ${{ matrix.config.cov == true }}
run: cmake -S . -B build -DCODE_COVERAGE=ON

- name: Run the build
run: cmake --build build

- name: Run the tests
run: |
cd build
# Avoid using ctest because it's so slow; it starts a
# new process for each individual test, which is crazy.
for exe in $(ctest --show-only=json-v1 | jq -r ".tests[] | .command | .[0]" | sort | uniq)
do
echo "#### RUNNING ${exe} ####"
echo
${exe} --gtest_brief=1
echo
done
- name: Generate code coverage
if: ${{ matrix.config.cov == true }}
run: |
cd build/tests/CMakeFiles/libtest.dir/src/
gcov -abcfu *.gcno
- name: Upload to Codecov
if: ${{ matrix.config.cov == true }}
uses: codecov/codecov-action@v4
with:
directory: build/tests/CMakeFiles/libtest.dir/src/
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 81166b6

Please sign in to comment.