|
1 |
| -name: C++ Build |
| 1 | +name: C++ CI and Codecov for Multiple Projects |
2 | 2 |
|
3 |
| -# Trigger the workflow on pushes and pull requests to specific branches |
4 | 3 | on:
|
5 | 4 | push:
|
6 | 5 | branches:
|
|
10 | 9 | - main
|
11 | 10 |
|
12 | 11 | jobs:
|
13 |
| - build: |
14 |
| - # This job will run on the latest version of Ubuntu |
| 12 | + # Job 1: Build and test projects under 'data-structures' |
| 13 | + data-structures-build-and-test: |
15 | 14 | runs-on: ubuntu-latest
|
16 | 15 |
|
17 |
| - # Steps define the actions within the job |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + # Add your projects from 'data-structures' |
| 19 | + project: [LinkedList, DoublyLinkedList] |
| 20 | + |
18 | 21 | steps:
|
19 |
| - # 1. Checkout the code from the repository |
| 22 | + # Step 1: Checkout the repository |
20 | 23 | - name: Checkout code
|
21 | 24 | uses: actions/checkout@v2
|
22 | 25 |
|
23 |
| - # 2. Install dependencies (e.g., for C++, you might want to install compilers or build tools) |
| 26 | + # Step 2: Install dependencies (C++ tools) |
24 | 27 | - name: Install dependencies
|
25 |
| - run: sudo apt-get update && sudo apt-get install -y g++ make cmake |
| 28 | + run: sudo apt-get install -y gcc g++ make cmake lcov |
26 | 29 |
|
27 |
| - # 3. Build the project |
28 |
| - - name: Build LinkedList |
| 30 | + # Step 3: Build and test each project in 'data-structures' |
| 31 | + - name: Build and test project |
29 | 32 | run: |
|
30 |
| - cd data-structures/linked-list |
| 33 | + # Navigate to the correct project directory |
| 34 | + cd data-structures/${{ matrix.project }} |
| 35 | + # Run the build script for the project |
31 | 36 | ./build.sh
|
| 37 | + ./bin/test_${{ matrix.project }} |
32 | 38 |
|
33 |
| - # 4. Run tests |
34 |
| - - name: Run test_LinkedList |
35 |
| - run: ./data-structures/linked-list/bin/test_linkedlist |
| 39 | + # Step 4: Upload coverage to Codecov |
| 40 | + - name: Upload coverage to Codecov |
| 41 | + run: bash <(curl -s https://codecov.io/bash) |
| 42 | + env: |
| 43 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments