Skip to content

Commit

Permalink
Workflow more ci platforms (#42)
Browse files Browse the repository at this point in the history
* Update CI-build-and-test.yml to include windows and clang

* Update CI-build-and-test.yml to actually set the os and c++ compiler

* Hopefully more system agnostic way to install protoc

* Use both of the cores in the runner

* Remove as this causes windows to be sad, dont think it actually did anything anyway

* Seems like ubuntu and windows will need different ways to install protoc, oh well

* Link math library to test targets as this seems to be needed for clang

* Gcc, clang -> g++, clang++

* Use dictionary to set c and cpp compilers separately in matrix job

* ' -> "

* Attempt some nasty hacking to try to get install working on windows

* Update CI-build-and-test.yml to fix indents

* Update CI-build-and-test.yml to correct OS check

* Do the spaces matter?

* Dont need test coverage for every platform

* This????

* The slashes seem upsetting for windows

* Update CI-build-and-test.yml

* Whoops, variable name was wrong lol

* Update CI-build-and-test.yml

* Update CI-build-and-test.yml

* Update CI-build-and-test.yml
  • Loading branch information
ewanwm authored Aug 13, 2024
1 parent 41ae3ec commit f7f62ba
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
49 changes: 42 additions & 7 deletions .github/workflows/CI-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,62 @@ jobs:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
OS: [ ubuntu-latest, windows-latest ]
compiler: [ {cpp: g++, c: gcc}, {cpp: clang++, c: clang} ]

name: Build & Test ${{ matrix.os }} ${{ matrix.compiler.c }}

runs-on: ${{ matrix.os }}

env:
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cpp }}

steps:
# this Action should follow steps to set up Python build environment
- uses: actions/checkout@v4

- name: Set Flags
run: export USE_CUDA=0
- name: Install Protoc Windows
if: ${{ startsWith(matrix.OS, 'windows') }}
uses: arduino/setup-protoc@v3

- name: Install Protobuf
- name: Install Protoc Ubuntu
if: ${{ startsWith(matrix.OS, 'ubuntu') }}
run: sudo apt install protobuf-compiler

- name: Install Python dependencies
uses: py-actions/py-dependency-install@v4
with:
path: "PyTorch_requirements.txt"

- name: Configure CMake
- name: Configure CMake ubuntu
if: ${{ startsWith(matrix.OS, 'ubuntu') }}
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -DNT_TEST_COVERAGE=ON -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: |
cmake \
-DNT_TEST_COVERAGE=ON \
-DCMAKE_PREFIX_PATH=`python3 -c "import torch;print(torch.utils.cmake_prefix_path)"` \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Configure CMake windows
if: ${{ startsWith(matrix.OS, 'windows') }}
# on windows to get the pytorch config we have to
# run the same python command as before but now save it
# to a file then read from the file into a variable to pass to cmake
run: |
$Torch_DIR = python3 -c "import torch;print(torch.utils.cmake_prefix_path)"
echo "torch location: $Torch_DIR"
cmake -DNT_TEST_COVERAGE=ON -DCMAKE_PREFIX_PATH="$Torch_DIR" -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 2

- name: Test
working-directory: ${{github.workspace}}/build
Expand All @@ -51,10 +82,14 @@ jobs:
run: ctest -C ${{env.BUILD_TYPE}}

- name: Generate Coverage Report
# only need to do this for one combination of OS and compiler
if: ${{ matrix.OS == 'ubuntu-latest' && matrix.compiler.c == 'gcc' }}
working-directory: ${{github.workspace}}/build
run: gcovr --json -o nuTens_coverage.json -r .. -f "../nuTens/*"

- name: Upload coverage reports to Codecov
# only need to do this for one combination of OS and compiler
if: ${{ matrix.OS == 'ubuntu-latest' && matrix.compiler.c == 'gcc' }}
uses: codecov/codecov-action@v4.0.1
with:
verbose: true
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

add_library(test-utils test-utils.hpp barger-propagator.hpp)
target_link_libraries(test-utils PUBLIC constants)
target_link_libraries(test-utils PUBLIC constants m)
set_target_properties(test-utils PROPERTIES LINKER_LANGUAGE CXX)

foreach(TESTNAME
Expand All @@ -13,7 +13,7 @@ foreach(TESTNAME
target_precompile_headers("${TESTNAME}" REUSE_FROM tensor)
ENDIF()

target_link_libraries("${TESTNAME}" PUBLIC test-utils tensor propagator instrumentation)
target_link_libraries("${TESTNAME}" PUBLIC test-utils tensor propagator instrumentation m)
target_include_directories("${TESTNAME}" PUBLIC "${CMAKE_SOURCE_DIR}")
add_test(NAME "${TESTNAME}-test" COMMAND "${TESTNAME}")

Expand Down

0 comments on commit f7f62ba

Please sign in to comment.