|
| 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: Run Tests |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [main] |
| 20 | + pull_request: |
| 21 | + branches: [main] |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + strategy: |
| 26 | + fail-fast: true |
| 27 | + matrix: |
| 28 | + os: [ubuntu-latest] |
| 29 | + python-version: [3.8.x, 3.x] |
| 30 | + compiler: [g++, clang] |
| 31 | + target: [Debug] |
| 32 | + |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Set up Python ${{ matrix.python-version }} |
| 40 | + uses: actions/setup-python@v5 |
| 41 | + with: |
| 42 | + python-version: ${{ matrix.python-version }} |
| 43 | + |
| 44 | + - name: Install baseline for ${{ matrix.os }}, with ${{ matrix.compiler }} |
| 45 | + run: | |
| 46 | + apt -y update |
| 47 | + apt -y upgrade |
| 48 | + apt -y install cmake \ |
| 49 | + ${{ matrix.compiler }} \ |
| 50 | + libmpfr-dev \ |
| 51 | + python3-dev \ |
| 52 | + libboost-dev \ |
| 53 | + libmpfr6 |
| 54 | +
|
| 55 | + - name: Install TNCO for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{ |
| 56 | + matrix.python-version }} (${{ matrix.target }}) |
| 57 | + run: | |
| 58 | + if [[ ${{ matrix.compiler }} == g++ ]]; then |
| 59 | + export CC=gcc |
| 60 | + export CXX=g++ |
| 61 | + elif [[ ${{ matrix.compiler }} == clang ]]; then |
| 62 | + export CC=clang |
| 63 | + export CXX=clang++ |
| 64 | + else |
| 65 | + echo 'Not supported.' |
| 66 | + return 1 |
| 67 | + fi |
| 68 | + pip install .[parallel,testing] --config-settings=cmake.build-type=${{ matrix.target }} --verbose |
| 69 | +
|
| 70 | + - name: Run Tests for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{ |
| 71 | + matrix.python-version }} (${{ matrix.target }}) |
| 72 | + if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'g++' && matrix.python-version |
| 73 | + == '3.x' |
| 74 | + run: | |
| 75 | + pip install pytest-sugar |
| 76 | + pytest --verbose --timeout=180 -n $((2 * $(nproc))) tests/*.py |
| 77 | +
|
| 78 | + - name: Run CLI for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{ |
| 79 | + matrix.python-version }} (${{ matrix.target }}) |
| 80 | + run: | |
| 81 | + tnco optimize '2 a b' '(0, 100)' --n-steps=100 --n-runs=100 > /dev/null |
| 82 | +
|
| 83 | + - name: Run Example for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{ |
| 84 | + matrix.python-version }} (${{ matrix.target }}) |
| 85 | + run: | |
| 86 | + pip install jupyterlab papermill |
| 87 | + papermill examples/Optimization.ipynb /dev/null |
0 commit comments