|
7 | 7 | branches: [main] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - # Step 1: dynamically detect example folders |
11 | | - detect-examples: |
12 | | - runs-on: ubuntu-latest |
13 | | - outputs: |
14 | | - folders: ${{ steps.set-folders.outputs.folders }} |
15 | | - steps: |
16 | | - - name: Checkout code |
17 | | - uses: actions/checkout@v4 |
18 | | - |
19 | | - - name: Detect example folders |
20 | | - id: set-folders |
21 | | - run: | |
22 | | - folders=$(find . -maxdepth 1 -type d -not -name '.' -exec test -f '{}/Makefile' \; -print | sed 's|^\./||' | tr '\n' ' ') |
23 | | - echo "Detected folders: $folders" |
24 | | - echo "::set-output name=folders::$folders" |
25 | | -
|
26 | | - # Step 2: build and run examples in parallel using a matrix |
27 | 10 | build-and-run: |
28 | | - needs: detect-examples |
29 | 11 | runs-on: ubuntu-latest |
30 | 12 | env: |
31 | | - ASAN_OPTIONS: detect_leaks=1 |
32 | | - strategy: |
33 | | - matrix: |
34 | | - folder: ${{ fromJSON('["' + needs.detect-examples.outputs.folders | replace(' ', '","') + '"]') }} |
35 | | - sanitizer: [address, thread, undefined] |
36 | | - |
| 13 | + ASAN_OPTIONS: detect_leaks=1 # automatically detect memory leaks |
37 | 14 | steps: |
| 15 | + # 1. Checkout repo |
38 | 16 | - name: Checkout code |
39 | 17 | uses: actions/checkout@v4 |
40 | 18 |
|
| 19 | + # 2. Install build tools |
41 | 20 | - name: Install build tools |
42 | 21 | run: | |
43 | 22 | sudo apt-get update |
44 | 23 | sudo apt-get install -y build-essential g++ clang |
45 | 24 |
|
46 | | - - name: Build example |
47 | | - run: | |
48 | | - echo "Building ${{ matrix.folder }} with SANITIZE=${{ matrix.sanitizer }}" |
49 | | - make -C ${{ matrix.folder }} SANITIZE=${{ matrix.sanitizer }} |
50 | | -
|
51 | | - - name: Run example |
| 25 | + # 3. Build and run all examples dynamically |
| 26 | + - name: Build and run examples |
52 | 27 | run: | |
53 | | - echo "Running ${{ matrix.folder }} with SANITIZE=${{ matrix.sanitizer }}" |
54 | | - make -C ${{ matrix.folder }} SANITIZE=${{ matrix.sanitizer }} run |
| 28 | + # Detect folders with Makefile |
| 29 | + folders=$(find . -maxdepth 1 -type d -not -name '.' -exec test -f '{}/Makefile' \; -print | sed 's|^\./||') |
| 30 | + |
| 31 | + # List detected folders |
| 32 | + echo "Detected example folders: $folders" |
| 33 | +
|
| 34 | + # Loop over each folder and sanitizer |
| 35 | + for folder in $folders; do |
| 36 | + for san in address thread undefined; do |
| 37 | + echo "=== Building $folder with sanitizer $san ===" |
| 38 | + make -C $folder SANITIZE=$san |
| 39 | + |
| 40 | + echo "=== Running $folder with sanitizer $san ===" |
| 41 | + make -C $folder SANITIZE=$san run |
| 42 | + done |
| 43 | + done |
0 commit comments