Skip to content

C++ junior developer #3

C++ junior developer

C++ junior developer #3

Workflow file for this run

name: CI
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y lcov g++
- name: Check repository
run: |
echo "## Repository Structure" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
find . -name "*.cpp" -o -name "*.h" | head -20 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Compile and test
run: |
if [ -f Makefile ]; then
make || true
elif [ -f CMakeLists.txt ]; then
cmake -B build -DCMAKE_CXX_FLAGS="--coverage" && cmake --build build && cd build && ctest || true
else
for f in $(find . -name "*.cpp" | head -5); do
g++ --coverage -o /dev/null "$f" 2>/dev/null || true
done
fi
- name: Coverage report
run: |
lcov --capture --directory . --output-file coverage.info --ignore-errors source 2>/dev/null || true
if [ -f coverage.info ] && [ -s coverage.info ]; then
lcov --remove coverage.info '/usr/*' --output-file coverage.info 2>/dev/null || true
echo "## Coverage" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
lcov --summary coverage.info 2>&1 | tail -5 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi