Skip to content

Commit

Permalink
ci new
Browse files Browse the repository at this point in the history
  • Loading branch information
lpanaf committed Jul 24, 2024
1 parent 85602df commit d0abd00
Showing 1 changed file with 164 additions and 91 deletions.
255 changes: 164 additions & 91 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,182 @@ name: Ubuntu

on:
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main" ]

types: [ assigned, opened, synchronize, reopened ]
release:
types: [ published, edited ]

jobs:
build:
name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} ${{ matrix.config.asanEnabled && 'ASan' || '' }}
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
os: [ubuntu-22.04]
cuda: [true, false]
asan: [true, false]
config: [
{
os: ubuntu-22.04,
cmakeBuildType: Release,
asanEnabled: false,
checkCodeFormat: true,
cudaEnabled: true,
},
{
os: ubuntu-22.04,
cmakeBuildType: Release,
asanEnabled: false,
checkCodeFormat: false,
cudaEnabled: true,
},
{
os: ubuntu-22.04,
cmakeBuildType: Release,
asanEnabled: true,
checkCodeFormat: false,
cudaEnabled: true,
},
]

runs-on: ${{ matrix.os }}
env:
COMPILER_CACHE_VERSION: 1
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CTCACHE_DIR: ${{ github.workspace }}/compiler-cache/ctcache

steps:
- run: |
sudo apt-get update && sudo apt-get install -y \
build-essential \
ninja-build \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libboost-test-dev \
libeigen3-dev \
libceres-dev \
libflann-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgflags-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libcgal-qt5-dev \
libgl1-mesa-dri \
libunwind-dev \
libgtest-dev \
libomp-dev \
xvfb
name: Install dependencies
- run: |
sudo apt-get install -y \
nvidia-cuda-toolkit \
nvidia-cuda-toolkit-gcc
echo "CC=/usr/bin/cuda-gcc" >> $GITHUB_ENV
echo "CXX=/usr/bin/cuda-g++" >> $GITHUB_ENV
if: ${{ matrix.cuda && matrix.os == 'ubuntu-20.04' }}
name: Install CUDA
- run: |
sudo apt-get install -y \
nvidia-cuda-toolkit \
nvidia-cuda-toolkit-gcc \
gcc-10 g++-10
echo "CC=/usr/bin/gcc-10" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-10" >> $GITHUB_ENV
echo "CUDAHOSTCXX=/usr/bin/g++-10" >> $GITHUB_ENV
if: ${{ matrix.cuda && matrix.os == 'ubuntu-22.04' }}
name: Install CUDA
- run: |
sudo apt-get install -y clang-15
echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
if: ${{ matrix.asan }}
name: Install Clang
- run: |
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache-builds
with:
key: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}-${{ github.run_id }}-${{ github.run_number }}
restore-keys: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}
path: ${{ env.COMPILER_CACHE_DIR }}

- name: Install compiler cache
run: |
mkdir -p "$CCACHE_DIR" "$CTCACHE_DIR"
echo "$COMPILER_CACHE_DIR/bin" >> $GITHUB_PATH
if [ -f "$COMPILER_CACHE_DIR/bin/ccache" ]; then
exit 0
fi
set -x
wget https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz
echo "0b33f39766fe9db67f40418aed6a5b3d7b2f4f7fab025a8213264b77a2d0e1b1 ccache-4.8.2-linux-x86_64.tar.xz" | sha256sum --check
tar xfv ccache-4.8.2-linux-x86_64.tar.xz
mkdir -p "$COMPILER_CACHE_DIR/bin"
mv ./ccache-4.8.2-linux-x86_64/ccache "$COMPILER_CACHE_DIR/bin"
ctcache_commit_id="66c3614175fc650591488519333c411b2eac15a3"
wget https://github.com/matus-chochlik/ctcache/archive/${ctcache_commit_id}.zip
echo "108b087f156a9fe7da0c796de1ef73f5855d2a33a27983769ea39061359a40fc ${ctcache_commit_id}.zip" | sha256sum --check
unzip "${ctcache_commit_id}.zip"
mv ctcache-${ctcache_commit_id}/clang-tidy* "$COMPILER_CACHE_DIR/bin"
- name: Check code format
run: |
if [ "${{ matrix.config.checkCodeFormat }}" != "true" ]; then
exit 0
fi
set +x -euo pipefail
sudo apt-get update && sudo apt-get install -y clang-format-14 black
./scripts/format/clang_format.sh
git diff --name-only
git diff --exit-code || (echo "Code formatting failed" && exit 1)
- name: Setup Ubuntu
run: |
sudo apt-get update && sudo apt-get install -y \
build-essential \
cmake \
ninja-build \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libeigen3-dev \
libceres-dev \
libflann-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libcgal-qt5-dev \
libgl1-mesa-dri \
libunwind-dev \
xvfb
if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then
if [ "${{ matrix.config.os }}" == "ubuntu-20.04" ]; then
sudo apt-get install -y \
nvidia-cuda-toolkit \
nvidia-cuda-toolkit-gcc
echo "CC=/usr/bin/cuda-gcc" >> $GITHUB_ENV
echo "CXX=/usr/bin/cuda-g++" >> $GITHUB_ENV
elif [ "${{ matrix.config.os }}" == "ubuntu-22.04" ]; then
sudo apt-get install -y \
nvidia-cuda-toolkit \
nvidia-cuda-toolkit-gcc \
gcc-10 g++-10
echo "CC=/usr/bin/gcc-10" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-10" >> $GITHUB_ENV
echo "CUDAHOSTCXX=/usr/bin/g++-10" >> $GITHUB_ENV
fi
fi
if [ "${{ matrix.config.asanEnabled }}" == "true" ]; then
sudo apt-get install -y clang-15 libomp-15-dev
echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
fi
if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then
sudo apt-get install -y clang-15 clang-tidy-15 libomp-15-dev
echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
fi
- name: Upgrade CMake
run: |
CMAKE_VERSION=3.28.6
CMAKE_DIR=cmake-${CMAKE_VERSION}-linux-x86_64
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_DIR}.tar.gz
tar -xzf ${CMAKE_DIR}.tar.gz
sudo cp -r ${CMAKE_DIR}/* /usr/local/
rm -rf ${CMAKE_DIR}*
name: Upgrade CMake
- name: Checkout
uses: actions/checkout@v3

- run: |
cmake --version
mkdir build
cd build
cmake .. \
-GNinja \
-DTESTS_ENABLED=ON \
-DASAN_ENABLED=${{ matrix.asan }} \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++
ninja
name: Configure and build
- run: |
export DISPLAY=":99.0"
export QT_QPA_PLATFORM="offscreen"
Xvfb :99 &
sleep 3
cd build
ctest -E "$CTEST_EXCLUSIONS"
tests_pass=$?
if [ $tests_pass -ne 0 ]; then
echo "Tests failed, rerunning with verbose output"
ctest --rerun-failed --output-on-failure
fi
exit $tests_pass
name: Run tests
- name: Configure and build
run: |
set -x
cmake --version
mkdir build
cd build
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=${{ matrix.config.cmakeBuildType }} \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_CUDA_ARCHITECTURES=50 \
-DTESTS_ENABLED=ON \
-DASAN_ENABLED=${{ matrix.config.asanEnabled }}
ninja -k 10000
- name: Run tests
run: |
if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then
exit 0
fi
export DISPLAY=":99.0"
export QT_QPA_PLATFORM="offscreen"
Xvfb :99 &
sleep 3
cd build
ctest --output-on-failure
- name: Cleanup compiler cache
run: |
set -x
ccache --show-stats --verbose
ccache --evict-older-than 1d
ccache --show-stats --verbose
echo "Size of ctcache before: $(du -sh $CTCACHE_DIR)"
echo "Number of ctcache files before: $(find $CTCACHE_DIR | wc -l)"
# Delete cache older than 10 days.
find "$CTCACHE_DIR"/*/ -mtime +10 -print0 | xargs -0 rm -rf
echo "Size of ctcache after: $(du -sh $CTCACHE_DIR)"
echo "Number of ctcache files after: $(find $CTCACHE_DIR | wc -l)"

0 comments on commit d0abd00

Please sign in to comment.