Skip to content

Commit 49f9046

Browse files
committed
Parallel build and move to checkout v4
1 parent 93a1ae7 commit 49f9046

2 files changed

Lines changed: 88 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,130 @@ permissions:
88
env:
99
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
1010
BUILD_TYPE: Release
11+
CACHE_VERSION: v1
1112

1213
jobs:
14+
# Detect changes in the codebase
15+
changes:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
code-changed: ${{ steps.changes.outputs.code }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: dorny/paths-filter@v3
22+
id: changes
23+
with:
24+
filters: |
25+
code:
26+
- 'libCacheSim/**'
27+
- 'test/**'
28+
- 'CMakeLists.txt'
29+
- 'cmake/**'
30+
- 'scripts/**'
31+
1332
macos:
1433
name: macos / clang
1534
runs-on: macos-latest
35+
needs: changes
36+
if: needs.changes.outputs.code-changed == 'true' || github.event_name == 'push'
1637
steps:
1738
- uses: actions/checkout@v4
39+
40+
# Add dependency caching
41+
- name: Cache dependencies
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
/opt/homebrew/lib
46+
/opt/homebrew/include
47+
key: ${{ runner.os }}-deps-${{ env.CACHE_VERSION }}-${{ hashFiles('scripts/install_dependency.sh') }}
48+
restore-keys: |
49+
${{ runner.os }}-deps-${{ env.CACHE_VERSION }}-
50+
1851
- name: Prepare
1952
run: bash scripts/install_dependency.sh
53+
54+
# Add build caching
55+
- name: Cache build
56+
uses: actions/cache@v4
57+
with:
58+
path: ${{github.workspace}}/build
59+
key: ${{ runner.os }}-build-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
60+
restore-keys: |
61+
${{ runner.os }}-build-${{ env.BUILD_TYPE }}-
62+
2063
- name: Configure CMake
21-
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
64+
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_TESTS=ON
65+
2266
- name: Build
23-
run: ninja -C ${{github.workspace}}/build
67+
run: ninja -C ${{github.workspace}}/build -j$(sysctl -n hw.logicalcpu)
68+
2469
- name: Test
2570
working-directory: ${{github.workspace}}/build
2671
run: |
27-
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel
72+
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel $(sysctl -n hw.logicalcpu)
2873
2974
ubuntu:
3075
runs-on: ubuntu-latest
76+
needs: changes
77+
if: needs.changes.outputs.code-changed == 'true' || github.event_name == 'push'
3178
steps:
3279
- uses: actions/checkout@v4
80+
81+
# Add dependency caching
82+
- name: Cache dependencies
83+
uses: actions/cache@v4
84+
with:
85+
path: |
86+
~/.cache/pip
87+
/usr/local/lib
88+
/var/cache/apt
89+
key: ${{ runner.os }}-deps-${{ env.CACHE_VERSION }}-${{ hashFiles('scripts/install_dependency.sh') }}
90+
restore-keys: |
91+
${{ runner.os }}-deps-${{ env.CACHE_VERSION }}-
92+
3393
- name: Prepare
3494
run: bash scripts/install_dependency.sh
95+
96+
# Add build caching
97+
- name: Cache build
98+
uses: actions/cache@v4
99+
with:
100+
path: ${{github.workspace}}/build
101+
key: ${{ runner.os }}-build-${{ env.BUILD_TYPE }}-lsan-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
102+
restore-keys: |
103+
${{ runner.os }}-build-${{ env.BUILD_TYPE }}-lsan-
104+
35105
- name: Configure CMake with LSan
36106
run: |
37107
cmake -G Ninja -B ${{github.workspace}}/build \
38108
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
39109
-DCMAKE_C_FLAGS="-fsanitize=leak" \
40-
-DCMAKE_CXX_FLAGS="-fsanitize=leak"
110+
-DCMAKE_CXX_FLAGS="-fsanitize=leak" \
111+
-DENABLE_TESTS=ON
112+
41113
- name: Build
42-
run: ninja -C ${{github.workspace}}/build
114+
run: ninja -C ${{github.workspace}}/build -j$(nproc)
115+
43116
- name: Test with LSan
44117
working-directory: ${{github.workspace}}/build
45118
run: |
46119
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1:verbosity=1"
47-
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel
120+
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel $(nproc) --timeout 300
48121
49122
selfhosted:
50123
runs-on: self-hosted
124+
needs: changes
125+
if: needs.changes.outputs.code-changed == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
51126
steps:
52127
- uses: actions/checkout@v4
128+
53129
- name: Configure CMake
54-
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_GLCACHE=on -DENABLE_LRB=on
130+
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_GLCACHE=on -DENABLE_LRB=on -DENABLE_TESTS=ON
131+
55132
- name: Build
56-
run: ninja -C ${{github.workspace}}/build
133+
run: ninja -C ${{github.workspace}}/build -j$(nproc 2>/dev/null || echo 4)
134+
57135
- name: Test
58136
working-directory: ${{github.workspace}}/build
59-
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel
137+
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --parallel $(nproc 2>/dev/null || echo 4) --timeout 300

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
name: Code Quality Checks
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
with:
1212
fetch-depth: 0 # Fetch all history for proper git diff
1313

0 commit comments

Comments
 (0)