Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CI build github action. #80

Merged
merged 6 commits into from
May 8, 2024
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
45 changes: 45 additions & 0 deletions .github/workflows/build-larch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and run tests
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
submodules: true
- name: Prepare build environment
run: |
sudo apt-get update
sudo apt-get install build-essential cmake zlib1g-dev python3-pip python3-pytest
- name: Install conda
run: |
curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda
~/miniconda/bin/conda update -n base -c defaults conda
- name: Create conda env
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda env create -f environment.yml
- name: Build (cmake step)
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
mkdir build
cd build
export CMAKE_NUM_THREADS="8"
cmake -DCMAKE_BUILD_TYPE=Debug ..
- name: Build (make step)
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
cd build
make -j20
ln -s ../data
- name: Run tests
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
cd build
./larch-test -tag slow
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ file provided:
Building
--------

- Note: If you run against memory limitations during the cmake step, you can regulate number of parallel threads with `export CMAKE_NUM_THREADS="8"` (reduce number as necessary).

`git submodule update --init --recursive`
`mkdir build`
`cd build`
Expand Down
25 changes: 16 additions & 9 deletions protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ include(FetchContent)
set(Protobuf_USE_STATIC_LIBS ON)
cmake_policy(SET CMP0026 OLD)

if(NOT DEFINED CMAKE_NUM_THREADS)
set(CMAKE_NUM_THREADS "16")
endif()

FetchContent_Declare(
protocolbuffers_protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
Expand All @@ -19,33 +23,36 @@ set(Protobuf_ROOT ${protocolbuffers_protobuf_SOURCE_DIR})
message(STATUS "Setting up protobuf ...")
execute_process(
COMMAND
${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D protobuf_BUILD_TESTS=OFF -D protobuf_BUILD_PROTOC_BINARIES=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -G "${CMAKE_GENERATOR}" .
${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D protobuf_BUILD_TESTS=OFF -D protobuf_BUILD_PROTOC_BINARIES=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${Protobuf_ROOT})

if(result)
message(FATAL_ERROR "Failed to download protobuf (${result})!")
endif()

message(STATUS "Building protobuf ...")
execute_process(
COMMAND ${CMAKE_COMMAND} --build . --parallel
COMMAND ${CMAKE_COMMAND} --build . --parallel ${CMAKE_NUM_THREADS}
RESULT_VARIABLE result
WORKING_DIRECTORY ${Protobuf_ROOT})

if(result)
message(FATAL_ERROR "Failed to build protobuf (${result})!")
endif()

message(STATUS "Installing protobuf ...")
execute_process(
COMMAND ${CMAKE_COMMAND} --install . --config ${CMAKE_BUILD_TYPE} --prefix ${Protobuf_ROOT}/install
RESULT_VARIABLE result
WORKING_DIRECTORY ${Protobuf_ROOT})
COMMAND ${CMAKE_COMMAND} --install . --config ${CMAKE_BUILD_TYPE} --prefix ${Protobuf_ROOT}/install
RESULT_VARIABLE result
WORKING_DIRECTORY ${Protobuf_ROOT})

if(result)
message(FATAL_ERROR "Failed to build protobuf (${result})!")
message(FATAL_ERROR "Failed to build protobuf (${result})!")
endif()

if (NOT EXISTS ${Protobuf_ROOT}/install/lib64)
file (CREATE_LINK ${Protobuf_ROOT}/install/lib ${Protobuf_ROOT}/install/lib64 SYMBOLIC)
if(NOT EXISTS ${Protobuf_ROOT}/install/lib64)
file(CREATE_LINK ${Protobuf_ROOT}/install/lib ${Protobuf_ROOT}/install/lib64 SYMBOLIC)
endif()

find_package(Protobuf CONFIG REQUIRED HINTS ${Protobuf_ROOT}/install/lib64/cmake)
Expand All @@ -67,7 +74,7 @@ if(Protobuf_FOUND)
else()
message(
FATAL_ERROR
"Protobuf package not found -> specify search path via Protobuf_ROOT variable"
"Protobuf package not found -> specify search path via Protobuf_ROOT variable"
)
endif()

Expand Down