|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, devito] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # Run tests for mathematical derivations and operators with coverage |
| 11 | + test-derivations: |
| 12 | + name: Test Mathematical Derivations |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install pytest pytest-cov numpy sympy matplotlib ipython |
| 28 | +
|
| 29 | + - name: Run tests with coverage |
| 30 | + run: | |
| 31 | + pytest tests/test_operators.py tests/test_derivations.py -v --cov=src --cov-report=xml --cov-report=term-missing |
| 32 | +
|
| 33 | + - name: Upload coverage to Codecov |
| 34 | + uses: codecov/codecov-action@v4 |
| 35 | + with: |
| 36 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 37 | + files: ./coverage.xml |
| 38 | + flags: derivations |
| 39 | + name: derivations-coverage |
| 40 | + fail_ci_if_error: false |
| 41 | + |
| 42 | + # Run explicit Devito solver tests with coverage |
| 43 | + test-devito-explicit: |
| 44 | + name: Test Devito Explicit Solvers |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout repository |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: '3.11' |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + python -m pip install --upgrade pip |
| 59 | + pip install pytest pytest-cov numpy sympy matplotlib |
| 60 | + pip install devito |
| 61 | +
|
| 62 | + - name: Run Devito tests with coverage |
| 63 | + run: | |
| 64 | + pytest tests/ -v -m "devito" --cov=src --cov-report=xml --cov-report=term-missing --tb=short |
| 65 | + continue-on-error: true # Allow to continue even if Devito tests fail initially |
| 66 | + |
| 67 | + - name: Upload coverage to Codecov |
| 68 | + uses: codecov/codecov-action@v4 |
| 69 | + with: |
| 70 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 71 | + files: ./coverage.xml |
| 72 | + flags: devito |
| 73 | + name: devito-coverage |
| 74 | + fail_ci_if_error: false |
| 75 | + |
| 76 | + # Lint and style checks |
| 77 | + lint: |
| 78 | + name: Lint and Style |
| 79 | + runs-on: ubuntu-latest |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Checkout repository |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Set up Python |
| 86 | + uses: actions/setup-python@v5 |
| 87 | + with: |
| 88 | + python-version: '3.11' |
| 89 | + |
| 90 | + - name: Install linting tools |
| 91 | + run: | |
| 92 | + python -m pip install --upgrade pip |
| 93 | + pip install ruff isort |
| 94 | +
|
| 95 | + - name: Run ruff check |
| 96 | + run: | |
| 97 | + # Check only new Devito code (skip legacy code with many pre-existing issues) |
| 98 | + ruff check src/wave/*_devito.py src/diffu/*_devito.py src/advec/*_devito.py src/nonlin/ src/symbols.py src/operators.py src/display.py src/verification.py src/plotting.py tests/ --select=E,W,F --ignore=F403,F405,E501,E741,E743,E731,E402,F841,E722 |
| 99 | +
|
| 100 | + - name: Check import ordering |
| 101 | + run: | |
| 102 | + isort --check-only src/ tests/ --skip __init__.py |
| 103 | + continue-on-error: true |
| 104 | + |
| 105 | + # Build Quarto book |
| 106 | + build-book: |
| 107 | + name: Build Quarto Book |
| 108 | + runs-on: ubuntu-latest |
| 109 | + |
| 110 | + steps: |
| 111 | + - name: Checkout repository |
| 112 | + uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Set up Python |
| 115 | + uses: actions/setup-python@v5 |
| 116 | + with: |
| 117 | + python-version: '3.11' |
| 118 | + |
| 119 | + - name: Install Python dependencies |
| 120 | + run: | |
| 121 | + python -m pip install --upgrade pip |
| 122 | + pip install numpy sympy matplotlib jupyter |
| 123 | +
|
| 124 | + - name: Set up Quarto |
| 125 | + uses: quarto-dev/quarto-actions/setup@v2 |
| 126 | + with: |
| 127 | + version: '1.4.554' |
| 128 | + |
| 129 | + - name: Install TinyTeX |
| 130 | + run: | |
| 131 | + quarto install tinytex |
| 132 | +
|
| 133 | + - name: Render book |
| 134 | + run: | |
| 135 | + quarto render --to pdf |
| 136 | + continue-on-error: true # Book may not build initially |
| 137 | + |
| 138 | + - name: Upload book artifact |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: book-pdf |
| 142 | + path: _book/*.pdf |
| 143 | + if: success() |
0 commit comments