Skip to content

clearup commits (#32) #110

clearup commits (#32)

clearup commits (#32) #110

Workflow file for this run

# This file is a part of Simple-XX/SimplePhysicsEngine
# (https://github.com/Simple-XX/SimplePhysicsEngine).
#
# workflow.yml for Simple-XX/SimplePhysicsEngine.
name: build
on:
- push
- release
env:
CMAKE_BUILD_TYPE: Release
jobs:
build_docs:
name: Build and publish documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
- name: Build
run: |
cmake --preset=build
cmake --build build --target doc
- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{github.workspace}}/doc/html
build_ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for CUDA
id: check_cuda
run: |
if command -v nvcc &> /dev/null; then
echo "CUDA is installed."
echo "has_cuda=true" >> $GITHUB_ENV
else
echo "CUDA is not installed."
echo "has_cuda=false" >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
sudo apt-get install --no-install-recommends -y xvfb ffmpeg
# Optionally install CUDA dependencies if CUDA is available
if [ "$has_cuda" = "true" ]; then
sudo apt install --fix-missing -y cuda-toolkit
fi
- name: Build
run: |
cmake --preset=build
cmake --build build --target all
cmake --build build --target coverage
- name: Start Xvfb
run: |
nohup Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Run demo2d
run: |
for i in {1..7}; do
# Start recording with ffmpeg
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/demo2d_$i.gif &
FFmpeg_PID=$!
# Run the demo2d program in the background
./build/bin/demo2d --instruction $i &
Demo2d_PID=$!
# Wait for 5 seconds
sleep 5
# Stop the ffmpeg recording
kill $FFmpeg_PID
# Terminate the demo2d program
kill $Demo2d_PID
done
env:
DISPLAY: :99
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i --edge_num 101 &
MassSpring3D_PID=$!
sleep 5
kill $FFmpeg_PID
kill $MassSpring3D_PID
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_ubuntu
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
check_nvidia_gpu:
runs-on: ubuntu-latest # use own runner with NVIDIA GPU
outputs:
has_gpu: ${{ steps.check_gpu.outputs.has_gpu }}
steps:
- name: Check for NVIDIA GPU
id: check_gpu
run: |
if lspci | grep -i nvidia; then
echo "NVIDIA GPU found."
echo "::set-output name=has_gpu::true"
else
echo "No NVIDIA GPU found."
echo "::set-output name=has_gpu::false"
fi
build_ubuntu_with_cuda:
runs-on: ubuntu-latest # use own runner with NVIDIA GPU
needs: check_nvidia_gpu
if: needs.check_nvidia_gpu.outputs.has_gpu == 'true'
steps:
- uses: actions/checkout@v3
- name: Set up CUDA
uses: Jimver/[email protected] # https://github.com/marketplace/actions/cuda-toolkit
with:
cuda: 11.7.0
sub-packages: '[]'
non-cuda-sub-packages: '[]'
method: network
linux-local-args: '["--toolkit", "--samples"]'
use-github-cache: true
use-local-cache: true
log-file-suffix: log.txt
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
sudo apt-get install --no-install-recommends -y xvfb ffmpeg
# Optionally install CUDA dependencies if CUDA is available
if [ "$has_cuda" = "true" ]; then
sudo apt install --fix-missing -y cuda-toolkit
fi
- name: Build
run: |
ls
cmake --preset=build
cmake --build build --target all
cmake --build build --target coverage
- name: Start Xvfb
run: |
nohup Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i --edge_num 101 &
MassSpring3D_PID=$!
sleep 5
kill $FFmpeg_PID
kill $MassSpring3D_PID
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_ubuntu
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
build_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
brew install doxygen graphviz llvm cppcheck lcov spdlog boost freeglut glfw glew vtk cgal glm ffmpeg
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
brew install --cask xquartz
- name: Start Xvfb
run: |
sudo /opt/X11/bin/Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
export DISPLAY=:99
sleep 3 # Give Xvfb some time to start
- name: Build
run: |
cmake --preset=build
cmake --build build --target all
- name: Run demo2d
run: |
for i in {1..7}; do
# Start recording with ffmpeg
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/demo2d_$i.gif &
FFmpeg_PID=$!
# Run the demo2d program in the background
./build/bin/demo2d --instruction $i &
Demo2d_PID=$!
# Wait for 5 seconds
sleep 5
# Stop the ffmpeg recording
if ps -p $FFmpeg_PID > /dev/null; then
kill $FFmpeg_PID
fi
# Terminate the demo2d program
if ps -p $Demo2d_PID > /dev/null; then
kill $Demo2d_PID
fi
done
env:
DISPLAY: :99
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i --edge_num 101 &
MassSpring3D_PID=$!
sleep 5
if ps -p $FFmpeg_PID > /dev/null; then
kill $FFmpeg_PID
fi
if ps -p $MassSpring3D_PID > /dev/null; then
kill $MassSpring3D_PID
fi
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_macos
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
# @bug 在 osx 下无法正常执行 lcov
# cmake --build build --target coverage