|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Build and Test |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [ "main" ] |
| 20 | + pull_request: |
| 21 | + branches: [ "main" ] |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + # Use larger machine with more disk space |
| 26 | + runs-on: ubuntu-24.04-32core |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + python-version: ["3.10"] |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + |
| 34 | + - name: Set up Python ${{ matrix.python-version }} |
| 35 | + uses: actions/setup-python@v3 |
| 36 | + with: |
| 37 | + python-version: ${{ matrix.python-version }} |
| 38 | + |
| 39 | + - run: df -h |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: | |
| 43 | + python -m pip install --upgrade pip |
| 44 | + # Clean up apt cache to save space |
| 45 | + sudo apt-get clean |
| 46 | + sudo rm -rf /var/lib/apt/lists/* |
| 47 | + df -h |
| 48 | + # Install python dependencies (with coverage enabled) |
| 49 | + echo -e "\n##### Running pip install #####" |
| 50 | + pip install -e '.[dev]' --config-settings=cmake.args="-DENABLE_COVERAGE=ON" |
| 51 | +
|
| 52 | + - run: df -h |
| 53 | + |
| 54 | + - name: Test with pytest with coverage enabled |
| 55 | + run: | |
| 56 | + # Run all tests with coverage (Python and C++) |
| 57 | + echo -e "\n##### Running Python tests with coverage #####" |
| 58 | + coverage run --source=src/ml_flashpoint --branch -m pytest -v -s |
| 59 | +
|
| 60 | + - name: Check Python test coverage |
| 61 | + run: | |
| 62 | + # Verify python coverage thresholds |
| 63 | + echo -e "\n##### Verifying Python coverage thresholds #####" |
| 64 | + coverage report |
| 65 | +
|
| 66 | + - name: Check C++ test coverage |
| 67 | + if: false # TODO(#3): fix and then re-enable |
| 68 | + run: | |
| 69 | + # Run C++ coverage check |
| 70 | + echo -e "\n##### Running C++ coverage check #####" |
| 71 | + mkdir -p htmlcov/cpp |
| 72 | + gcovr --root=. \ |
| 73 | + --filter=src/ml_flashpoint \ |
| 74 | + --exclude=".*/_deps/.*" \ |
| 75 | + --gcov-executable=gcov \ |
| 76 | + --txt-metric branch \ |
| 77 | + --html-details htmlcov/cpp/index.html \ |
| 78 | + --xml-pretty -o cxx-coverage.xml \ |
| 79 | + --sort uncovered-number \ |
| 80 | + --gcov-ignore-parse-errors negative_hits.warn \ |
| 81 | + --gcov-ignore-parse-errors suspicious_hits.warn |
| 82 | +
|
| 83 | + lint: |
| 84 | + runs-on: ubuntu-24.04-32core |
| 85 | + strategy: |
| 86 | + matrix: |
| 87 | + python-version: [ "3.10" ] |
| 88 | + |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v3 |
| 91 | + |
| 92 | + - name: Set up Python ${{ matrix.python-version }} |
| 93 | + uses: actions/setup-python@v3 |
| 94 | + with: |
| 95 | + python-version: ${{ matrix.python-version }} |
| 96 | + |
| 97 | + - name: Lint with ruff |
| 98 | + run: | |
| 99 | + pip install ruff==0.12.11 |
| 100 | + ruff check . |
| 101 | + ruff format --check . |
| 102 | +
|
| 103 | + - name: Lint with clang-format |
| 104 | + if: false # TODO(#2): fix this then re-enable |
| 105 | + run: | |
| 106 | + # Install and run C++ linter |
| 107 | + echo -e "\n##### Installing and running clang-format linter #####" |
| 108 | + sudo apt-get update && sudo apt-get install -y clang-format |
| 109 | + clang-format --version |
| 110 | + find src -name '*.cpp' -o -name '*.h' | xargs clang-format --dry-run --Werror |
0 commit comments