Skip to content

Add bazel support for google benchmark #79

Add bazel support for google benchmark

Add bazel support for google benchmark #79

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache build
uses: actions/cache@v3
with:
path: core/build-tests
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt') }}
- name: Create build directory
run: mkdir -p core/build-tests
- name: Build tests
run: |
cd core/build-tests
cmake .. -DENABLE_TESTS=ON
make -j
- name: Run tests
run: |
cd core/build-tests
GTEST_OUTPUT=json:test-results/ ctest
- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test_results
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json
cmake-integration-tests:
strategy:
matrix:
codspeed-mode:
- "instrumentation"
- "off"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark_cmake/build
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
- name: Create build directory
run: mkdir -p examples/google_benchmark_cmake/build
- name: Build benchmark example
run: |
cd examples/google_benchmark_cmake/build
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
make -j
- name: Run the benchmarks
uses: CodSpeedHQ/action@main
if: matrix.codspeed-mode != 'off'
with:
run: examples/google_benchmark_cmake/build/benchmark_example
token: ${{ secrets.CODSPEED_TOKEN }}
cmake-integration-tests-walltime:
strategy:
matrix:
codspeed-mode:
- "walltime"
runs-on: ${{ matrix.codspeed-mode == 'walltime' && "codspeed-macro" || 'ubuntu-latest' }}

Check failure on line 82 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 82, Col: 14): Unexpected symbol: '"codspeed-macro"'. Located at position 39 within expression: matrix.codspeed-mode == 'walltime' && "codspeed-macro" || 'ubuntu-latest' .github/workflows/ci.yml (Line: 116, Col: 14): Unexpected symbol: '"codspeed-macro"'. Located at position 39 within expression: matrix.codspeed-mode == 'walltime' && "codspeed-macro" || 'ubuntu-latest'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark_cmake/build
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
- name: Create build directory
run: mkdir -p examples/google_benchmark_cmake/build
- name: Build benchmark example
run: |
cd examples/google_benchmark_cmake/build
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
make -j
- name: Run the benchmarks
uses: CodSpeedHQ/action@main
if: matrix.codspeed-mode != 'off'
with:
run: examples/google_benchmark_cmake/build/benchmark_example
token: ${{ secrets.CODSPEED_TOKEN }}
bazel-integration-tests:
strategy:
matrix:
codspeed-mode:
- "instrumentation"
- "walltime"
- "off"
runs-on: ${{ matrix.codspeed-mode == 'walltime' && "codspeed-macro" || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@0.14.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- name: Build and run benchmarks
run: |
bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
- name: Run the benchmarks
uses: CodSpeedHQ/action@main
if: matrix.codspeed-mode != 'off'
with:
run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
token: ${{ secrets.CODSPEED_TOKEN }}