Skip to content

Commit a78812f

Browse files
committed
Fix CI
1 parent fa14bd1 commit a78812f

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,37 @@ on:
77
branches: [main]
88

99
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
2710
build-and-run:
28-
needs: detect-examples
2911
runs-on: ubuntu-latest
3012
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
3714
steps:
15+
# 1. Checkout repo
3816
- name: Checkout code
3917
uses: actions/checkout@v4
4018

19+
# 2. Install build tools
4120
- name: Install build tools
4221
run: |
4322
sudo apt-get update
4423
sudo apt-get install -y build-essential g++ clang
4524
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
5227
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

Comments
 (0)