larra/.forgejo/workflows/pr_check.yaml

154 lines
6.8 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
- name: Setup environment - Install LLVM-19.1.1
run: |
echo "" >> ~/.bashrc
echo "export LLVM_VER='LLVM-19.1.1'" >> ~/.bashrc
source ~/.bashrc
echo "::group::Download $LLVM_VER"
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.1/LLVM-19.1.1-Linux-X64.tar.xz -O /$LLVM_VER-Linux-X64.tar.xz
echo "::endgroup::"
echo "::group::Extracting $LLVM_VER"
mkdir -p /home/$LLVM_VER/
tar -xf /$LLVM_VER-Linux-X64.tar.xz -C "/home/$LLVM_VER/" --strip-components=1 $LLVM_VER-Linux-X64/bin/clang-19 $LLVM_VER-Linux-X64/bin/clang $LLVM_VER-Linux-X64/bin/clang++ $LLVM_VER-Linux-X64/bin/clang-scan-deps $LLVM_VER-Linux-X64/bin/clang-format $LLVM_VER-Linux-X64/bin/clang-tidy $LLVM_VER-Linux-X64/include/ $LLVM_VER-Linux-X64/lib/ $LLVM_VER-Linux-X64/libexec/ $LLVM_VER-Linux-X64/local/ $LLVM_VER-Linux-X64/share/
rm /$LLVM_VER-Linux-X64.tar.xz
echo "::endgroup::"
echo "" >> ~/.bashrc
echo "export PATH='/home/$LLVM_VER/bin:${PATH}'" >> ~/.bashrc
echo "Available LLVM binaries:"
ls -la /home/$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 }}"
- 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
git remote add origin https://${{ github.token }}@helicopter.myftp.org/git/Larra/larra
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 }}."
#- 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_VER-Linux-X64-small.tar.xz
# key: $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_VER-Linux-X64-small.tar.xz
# key: $LLVM_VER-Linux-X64-small
2024-10-18 07:38:35 +00:00
- name: Check clang-format
run: |
export PATH="/home/$LLVM_VER/bin:${PATH}"
2024-10-18 07:38:35 +00:00
cd ${{ github.workspace }}
find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt
export REPO_FILES=$(cat repo_sources_to_check.txt)
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: Clang build with -fsanitize=address
environment:
CC: /home/$LLVM_VER/bin/clang
CXX: /home/$LLVM_VER/bin/clang++
run: |
mkdir -p ${{ github.workspace }}/build_clang
cmake -Wno-dev \
-DCMAKE_C_COMPILER=/home/$LLVM_VER/bin/clang \
-DCMAKE_CXX_COMPILER=/home/$LLVM_VER/bin/clang++ \
-S ${{ github.workspace }} \
-B ${{ github.workspace }}/build_clang \
-GNinja -DCMAKE_BUILD_TYPE=Release \
-DENABLE_EXAMPLES=ON \
-DENABLE_TESTS=ON \
-DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr"
cmake --build ${{ github.workspace }}/build_clang --parallel `nproc`
- name: Clang unit tests with -fsanitize=address
run: |
cd ${{ github.workspace }}/build_clang
ASAN_SYMBOLIZER_PATH=/home/$LLVM_VER/bin/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
2024-10-18 07:38:35 +00:00
- name: Check clang-tidy
run: |
export PATH="/home/$LLVM_VER/bin:${PATH}"
2024-10-18 07:38:35 +00:00
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 -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/
echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors"
- name: GCC build
environment:
CC: /usr/sbin/gcc
CXX: /usr/sbin/g++
run: |
mkdir -p ${{ github.workspace }}/build_gcc
cmake -Wno-dev \
-S ${{ github.workspace }} \
-B ${{ github.workspace }}/build_gcc \
-GNinja -DCMAKE_BUILD_TYPE=Release \
-DENABLE_EXAMPLES=ON \
-DENABLE_TESTS=ON
cmake --build ${{ github.workspace }}/build_gcc --parallel `nproc`
- name: GCC unit tests
run: |
cd ${{ github.workspace }}/build_gcc
./larra_xmpp_tests