Update workflows #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | |
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | |
name: linux | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
CC: gcc-13 | |
CXX: g++-13 | |
jobs: | |
build: | |
# 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 | |
steps: | |
- uses: actions/checkout@v4 | |
# Step to cache downloaded dependencies | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{github.workspace}}/installed/libtorch | |
${{github.workspace}}/installed/fmtlib | |
${{github.workspace}}/installed/nlohmann | |
${{github.workspace}}/installed/ns3 | |
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
- name: Install python dev | |
run: | | |
sudo apt-get install python3-matplotlib python3-numpy python3-dev | |
- name: Install Matplotlib-cpp | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
git clone https://github.com/lava/matplotlib-cpp.git libraries/matplotlib-cpp | |
cd libraries/matplotlib-cpp | |
mkdir build && cd build | |
cmake .. | |
sudo make install | |
- name: Install LibTorch | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
curl -LO https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.0%2Bcpu.zip | |
unzip libtorch-cxx11-abi-shared-with-deps-2.3.0%2Bcpu.zip -d ${{github.workspace}}/installed | |
- name: Install fmtlib | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
curl -LO https://github.com/fmtlib/fmt/releases/download/10.2.1/fmt-10.2.1.zip | |
unzip fmt-10.2.1.zip -d ${{github.workspace}}/libraries | |
cd ${{github.workspace}}/libraries/fmt-10.2.1 | |
cmake -S . -B build | |
cmake --build ./build | |
cmake --install ./build --prefix=${{github.workspace}}/installed/fmtlib | |
- name: Install nlohmann json | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
git clone https://github.com/nlohmann/json.git libraries/nlohmann | |
cd libraries/nlohmann | |
cmake -S . -B build | |
cmake --build ./build | |
cmake --install ./build --prefix=${{github.workspace}}/installed/nlohmann | |
- name: Install ns3 | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
wget https://www.nsnam.org/releases/ns-allinone-3.41.tar.bz2 | |
tar xfj ns-allinone-3.41.tar.bz2 | |
cd ns-allinone-3.41/ns-3.41 | |
./ns3 configure --enable-examples --enable-tests --cxx-standard=23 --prefix=${{github.workspace}}/installed/ns3 | |
./ns3 build | |
./ns3 install | |
- name: Configure CMake | |
# 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 -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH="${{github.workspace}}/installed/libtorch;${{github.workspace}}/installed/ns3;${{github.workspace}}/installed/fmtlib;${{github.workspace}}/installed/nlohmann" | |
- name: Build | |
# Build your program with the given configuration | |
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: ctest -C ${{env.BUILD_TYPE}} | |