Repository navigation
Add workflow to determine functional changes in PRs #41
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| determine_changes: | |
| name: Determine if functional changes exist | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip_full_tests: ${{ steps.check.outputs.skip_full_tests }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: check | |
| run: | | |
| # Check if PR body contains "no functional change" | |
| if echo "${{ github.event.pull_request.body }}" | grep -iq "no functional change"; then | |
| echo "skip_full_tests=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # List changed files between PR base and head | |
| CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) | |
| # Check if any .cpp or .c files changed | |
| if echo "$CHANGED" | grep -E '\.(cpp|c)$' >/dev/null; then | |
| echo "skip_full_tests=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "skip_full_tests=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| needs: determine_changes | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| build_type: [Debug, Release] | |
| c_compiler: [gcc, clang, cl] | |
| include: | |
| # Windows | |
| - os: windows-latest | |
| c_compiler: cl | |
| cpp_compiler: cl | |
| - os: windows-latest | |
| c_compiler: clang | |
| cpp_compiler: clang++ | |
| - os: windows-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| # Linux | |
| - os: ubuntu-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| - os: ubuntu-latest | |
| c_compiler: clang | |
| cpp_compiler: clang++ | |
| exclude: | |
| - os: ubuntu-latest | |
| c_compiler: cl | |
| steps: | |
| - name: Skip heavy build if no functional changes | |
| shell: bash | |
| run: | | |
| if [[ "${{ needs.determine_changes.outputs.skip_full_tests }}" == "true" ]]; then | |
| echo "Skipping build/tests (no functional changes)" | |
| exit 0 | |
| fi | |
| - uses: actions/checkout@v4 | |
| - name: Set build dir | |
| id: vars | |
| shell: bash | |
| run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then | |
| if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then | |
| SANITIZERS="memory,undefined" | |
| else | |
| SANITIZERS="address,undefined" | |
| fi | |
| fi | |
| cmake -B "${{ steps.vars.outputs.dir }}" \ | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DSANITIZERS=${SANITIZERS} \ | |
| -DDART_TESTING_TIMEOUT=0 \ | |
| -S "${{ github.workspace }}" | |
| - name: Build | |
| run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} | |
| - name: Test | |
| working-directory: ${{ steps.vars.outputs.dir }} | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| ctest --build-config ${{ matrix.build_type }} --verbose -j 4 --timeout 0 | |
| else | |
| ctest --verbose -j 4 --timeout 0 | |
| fi |