Skip to content

Update at Friday, October 11, 2024 PM05:14:09 HKT #52

Update at Friday, October 11, 2024 PM05:14:09 HKT

Update at Friday, October 11, 2024 PM05:14:09 HKT #52

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Job 1: Build and test projects under 'data-structures'
data-structures-build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
# Add your projects from 'data-structures'
project: [Array, LinkedList, Queue, Stack]
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Install dependencies (C++ tools)
- name: Install dependencies
run: sudo apt-get install -y gcc g++ make cmake lcov
# Step 3: Build and test each project in 'data-structures'
- name: Build and test project
run: |
# Navigate to the correct project directory
cd data-structures/${{ matrix.project }}
# Create the build directory if it doesn't exist
if [ ! -d "build" ]; then
mkdir build
fi
# Run CMake in the build directory
cd build
cmake -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage" ..
# Build the project using make
make
# Return to the project root directory
cd ..
./bin/test_${{ matrix.project }}
# Step 4: Generate coverage report
- name: Generate coverage report
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
# Step 5: Upload coverage to Codecov
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}