larra/.forgejo/workflows/pr_check.yaml

190 lines
8.3 KiB
YAML
Raw Normal View History

2024-10-18 07:36:50 +00:00
name: PR Check
run-name: ${{ github.actor }} is testing
on: [push]
jobs:
on-push-commit-check:
runs-on: archlinux-latest
steps:
- name: Setup environment - Install pacman packages
2024-10-18 07:36:50 +00:00
shell: sh
run: |
pacman -Syyu --noconfirm
pacman -S --noconfirm git less vim sudo python-pip wget which pkgconf nodejs-lts-iron
pacman -S --noconfirm cmake make gcc ninja meson
pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 gtest
2024-10-18 07:36:50 +00:00
- name: Setup environment - Install LLVM-19.1.1
run: |
export LLVM_VER=19.1.1
echo "::group::Download LLVM-${LLVM_VER}"
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz -O /LLVM-${LLVM_VER}-Linux-X64.tar.xz
echo "::endgroup::"
echo "::group::Extracting LLVM-${LLVM_VER}"
mkdir -p /home/LLVM-${LLVM_VER}/
tar -xf /LLVM-${LLVM_VER}-Linux-X64.tar.xz -C "/home/LLVM-${LLVM_VER}/" --strip-components=1 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang \
LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \
LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \
LLVM-${LLVM_VER}-Linux-X64/include/ \
LLVM-${LLVM_VER}-Linux-X64/lib/ \
LLVM-${LLVM_VER}-Linux-X64/libexec/ \
LLVM-${LLVM_VER}-Linux-X64/local/ \
LLVM-${LLVM_VER}-Linux-X64/share/
rm /LLVM-${LLVM_VER}-Linux-X64.tar.xz
echo "::endgroup::"
echo "LLVM version ${LLVM_VER}"
echo "Available LLVM binaries:"
ls -la /home/LLVM-${LLVM_VER}/bin/
2024-10-18 07:36:50 +00:00
- name: List CI environment variables
run: |
echo "Runner OS: ${{ runner.os }}"
echo "Job triggered event: ${{ github.event_name }}"
echo "Repository name: ${{ github.repository }}"
echo "Workspace path: ${{ github.workspace }}"
echo "Actor: ${{ github.actor }}"
echo "Ref: ${{ github.ref }}"
echo "Ref name: ${{ github.ref_name }}"
echo "SHA: ${{ github.sha }}"
echo "PATH: ${PATH}"
2024-10-18 07:36:50 +00:00
- name: Check out repository code
run: |
export GIT_TERMINAL_PROMPT=0
mkdir -p ${{ github.workspace }}
cd ${{ github.workspace }}
echo "Configure project settings and remote credentials"
git init
git config credential.helper store
2024-11-07 14:38:17 +00:00
git remote add origin https://${{ github.token }}@sha512sum.xyz/git/Larra/larra
2024-10-18 07:36:50 +00:00
echo "Fetch repo state on pushed commit"
git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +${{ github.sha }}:${{ github.ref }}
echo "Checkout to fetched repo state"
git checkout ${{ github.ref }}
- name: Show repo content
run: |
echo "github.workspace content"
ls -la ${{ github.workspace }}
echo "This job's status is ${{ job.status }}."
2024-10-21 11:21:26 +00:00
- name: Store list of repo files
run: |
cd ${{ github.workspace }}
find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_files_to_check.txt
find -type f \( -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt
#- name: Delete cache
# run: |
# rm -rf ${{ runner.tool_cache }}/cache-llvm-19-restore
#
#- name: Try restore LLVM-19 binaries from cache
# id: cache-llvm-19-bins-restore
# uses: actions/cache@v4
# with:
# path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz
# key: LLVM-${LLVM_VER}-Linux-X64-small
#
#- name: Save LLVM-19 to cache
# if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true'
# id: cache-llvm-19-save
# uses: actions/cache/save@v4
# with:
# path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz
# key: LLVM-${LLVM_VER}-Linux-X64-small
2024-10-18 07:38:35 +00:00
- name: Check clang-format
run: |
export LLVM_VER=19.1.1
export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
2024-10-18 07:38:35 +00:00
cd ${{ github.workspace }}
2024-10-21 11:21:26 +00:00
export REPO_FILES=$(cat repo_files_to_check.txt)
2024-10-18 07:38:35 +00:00
printf "\nList of files to be checked:\n"
echo "::group::files to be checked"
for FILE in $REPO_FILES; do printf "\t ${{ github.workspace }}/$FILE \n"; done
echo "::endgroup::"
for FILE in $REPO_FILES; do clang-format -i ${{ github.workspace }}/$FILE --dry-run --Werror; done
echo "No clang-format violations detected!"
- name: GCC build
run: |
mkdir -p ${{ github.workspace }}/build_gcc
cmake -Wno-dev \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-S ${{ github.workspace }} \
-B ${{ github.workspace }}/build_gcc \
-GNinja -DCMAKE_BUILD_TYPE=Release \
-DENABLE_EXAMPLES=ON \
-DENABLE_TESTS=ON \
-DCMAKE_CXX_FLAGS="-ftemplate-backtrace-limit=0"
cmake --build ${{ github.workspace }}/build_gcc --parallel `nproc`
- name: GCC unit tests
run: |
cd ${{ github.workspace }}/build_gcc
./larra_xmpp_tests
- name: Check clang-tidy
run: |
export LLVM_VER=19.1.1
export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
2024-10-21 11:21:26 +00:00
cd ${{ github.workspace }}
sed -i 's|/usr/sbin/g++|/home/LLVM-19.1.1/bin/clang++ -stdlib=libc++ -I/home/LLVM-${LLVM_VER}/include/c++/v1|' build_gcc/compile_commands.json
sed -i 's|-fdeps-format=p1689r5||' build_gcc/compile_commands.json
sed -i 's|-fmodules-ts||' build_gcc/compile_commands.json
sed -i 's|-fmodule-mapper=.*\.modmap||' build_gcc/compile_commands.json
wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
python run-clang-tidy.py \
2024-10-21 11:21:26 +00:00
-warnings-as-errors=* \
-use-color \
-exclude-header-filter .*build.* \
-header-filter .hpp \
-p ${{ github.workspace }}/build_gcc/ \
-config-file ${{ github.workspace }}/.clang-tidy \
\
${{ github.workspace }}/examples \
${{ github.workspace }}/library/ \
${{ github.workspace }}/src/
echo "No clang-tidy violations detected!"
#- name: Clang build with -fsanitize=address
# run: |
# export LLVM_VER=19.1.1
# export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# mkdir -p ${{ github.workspace }}/build_clang
# cmake -Wno-dev \
# -DCMAKE_C_COMPILER=clang \
# -DCMAKE_CXX_COMPILER=clang++ \
# -S ${{ github.workspace }} \
# -B ${{ github.workspace }}/build_clang \
# -GNinja -DCMAKE_BUILD_TYPE=Release \
# -DENABLE_EXAMPLES=ON \
# -DENABLE_TESTS=ON \
2024-10-21 11:21:26 +00:00
# -DCMAKE_CXX_FLAGS="-stdlib=libc++ -I/home/LLVM-${LLVM_VER}/include/c++/v1 -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \
# -DCMAKE_EXE_LINKER_FLAGS="-L/home/LLVM-${LLVM_VER}/lib/ -Wl,-rpath,/home/LLVM-${LLVM_VER}/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr"
# cmake --build ${{ github.workspace }}/build_clang --parallel `nproc`
2024-10-21 11:21:26 +00:00
#- name: Clang unit tests with -fsanitize=address
# run: |
# export LLVM_VER=19.1.1
# export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# cd ${{ github.workspace }}/build_clang
# ASAN_SYMBOLIZER_PATH=llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests