|
7 | 7 | - main |
8 | 8 | paths: |
9 | 9 | - "**.py" |
| 10 | + - "pyproject.toml" |
| 11 | + - "test/**" |
10 | 12 | pull_request: |
11 | 13 | branches: |
12 | 14 | - dev |
|
17 | 19 | - synchronize |
18 | 20 | paths: |
19 | 21 | - "**.py" |
| 22 | + - "pyproject.toml" |
| 23 | + - "test/**" |
20 | 24 | workflow_dispatch: |
21 | 25 | inputs: |
22 | 26 | PYTHON_VERSION: |
23 | 27 | required: false |
24 | | - default: 3.11 |
| 28 | + default: "3.11" |
| 29 | + TEST_TYPE: |
| 30 | + description: 'Type of tests to run' |
| 31 | + required: false |
| 32 | + default: 'all' |
| 33 | + type: choice |
| 34 | + options: |
| 35 | + - all |
| 36 | + - fast |
| 37 | + - unit |
| 38 | + - integration |
| 39 | + - smoke |
25 | 40 |
|
26 | 41 | concurrency: |
27 | 42 | group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" |
28 | 43 | cancel-in-progress: true |
29 | 44 |
|
30 | 45 | jobs: |
31 | | - run-unit-test: |
32 | | - runs-on: ["ubuntu-latest"] |
| 46 | + # Fast smoke test job for quick feedback |
| 47 | + smoke-test: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v4 |
| 54 | + with: |
| 55 | + python-version: "3.11" |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + python -m pip install --upgrade pip |
| 59 | + pip install poetry |
| 60 | + poetry install --no-interaction |
| 61 | + - name: Run smoke tests |
| 62 | + run: | |
| 63 | + poetry run pytest -m "micro" --maxfail=1 --tb=no -q --timeout=30 |
| 64 | + timeout-minutes: 3 |
| 65 | + |
| 66 | + # Main test matrix |
| 67 | + test-matrix: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: [smoke-test] |
| 70 | + if: always() && (needs.smoke-test.result == 'success' || github.event_name != 'pull_request') |
33 | 71 | strategy: |
| 72 | + fail-fast: false |
34 | 73 | matrix: |
35 | | - python-version: [3.11] |
| 74 | + python-version: ["3.9", "3.10", "3.11"] |
| 75 | + test-group: ["unit", "integration", "layers"] |
| 76 | + include: |
| 77 | + - python-version: "3.11" |
| 78 | + test-group: "processor" |
| 79 | + - python-version: "3.11" |
| 80 | + test-group: "time-series" |
| 81 | + |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v4 |
| 84 | + - name: Set up Python ${{ matrix.python-version }} |
| 85 | + uses: actions/setup-python@v4 |
| 86 | + with: |
| 87 | + python-version: ${{ matrix.python-version }} |
| 88 | + |
| 89 | + - name: Cache Poetry dependencies |
| 90 | + uses: actions/cache@v3 |
| 91 | + with: |
| 92 | + path: | |
| 93 | + ~/.cache/pypoetry |
| 94 | + ~/.cache/pip |
| 95 | + key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 96 | + restore-keys: | |
| 97 | + ${{ runner.os }}-poetry-${{ matrix.python-version }}- |
| 98 | +
|
| 99 | + - name: Install dependencies |
| 100 | + run: | |
| 101 | + python -m pip install --upgrade pip |
| 102 | + pip install poetry |
| 103 | + poetry install --no-interaction |
| 104 | +
|
| 105 | + - name: Run tests - ${{ matrix.test-group }} |
| 106 | + run: | |
| 107 | + case "${{ matrix.test-group }}" in |
| 108 | + "unit") |
| 109 | + poetry run pytest -c pytest-fast.ini -m "unit" --maxfail=10 --timeout=120 |
| 110 | + ;; |
| 111 | + "integration") |
| 112 | + poetry run pytest -m "integration" --maxfail=3 --timeout=300 |
| 113 | + ;; |
| 114 | + "layers") |
| 115 | + poetry run pytest -c pytest-fast.ini -m "layers" --maxfail=5 --timeout=120 |
| 116 | + ;; |
| 117 | + "processor") |
| 118 | + poetry run pytest -c pytest-fast.ini -m "processor" --maxfail=3 --timeout=180 |
| 119 | + ;; |
| 120 | + "time-series") |
| 121 | + poetry run pytest -c pytest-fast.ini -m "time_series" --maxfail=3 --timeout=180 |
| 122 | + ;; |
| 123 | + esac |
| 124 | + timeout-minutes: 8 |
| 125 | + |
| 126 | + - name: Upload test results |
| 127 | + uses: actions/upload-artifact@v3 |
| 128 | + if: always() |
| 129 | + with: |
| 130 | + name: test-results-${{ matrix.python-version }}-${{ matrix.test-group }} |
| 131 | + path: | |
| 132 | + pytest.xml |
| 133 | + htmlcov/ |
| 134 | + retention-days: 7 |
| 135 | + |
| 136 | + # Coverage job (only on main Python version) |
| 137 | + coverage: |
| 138 | + runs-on: ubuntu-latest |
| 139 | + needs: [test-matrix] |
| 140 | + if: always() && needs.test-matrix.result == 'success' |
36 | 141 | steps: |
37 | | - - uses: actions/checkout@v3 |
38 | | - - name: "running unit-tests" |
39 | | - uses: "piotrlaczkowski/keras-data-processor/.github/templates/Python/unittests@main" |
| 142 | + - uses: actions/checkout@v4 |
| 143 | + - name: Set up Python |
| 144 | + uses: actions/setup-python@v4 |
| 145 | + with: |
| 146 | + python-version: "3.11" |
| 147 | + |
| 148 | + - name: Install dependencies |
| 149 | + run: | |
| 150 | + python -m pip install --upgrade pip |
| 151 | + pip install poetry |
| 152 | + poetry install --no-interaction |
| 153 | +
|
| 154 | + - name: Run tests with coverage |
| 155 | + run: | |
| 156 | + poetry run pytest -c pytest-fast.ini --cov=kdp --cov-report=xml --cov-report=html --timeout=180 |
| 157 | + timeout-minutes: 10 |
| 158 | + |
| 159 | + - name: Upload coverage to Codecov |
| 160 | + uses: codecov/codecov-action@v3 |
| 161 | + with: |
| 162 | + file: ./coverage.xml |
| 163 | + flags: unittests |
| 164 | + name: codecov-umbrella |
| 165 | + fail_ci_if_error: false |
| 166 | + |
| 167 | + - name: Upload coverage report |
| 168 | + uses: actions/upload-artifact@v3 |
| 169 | + with: |
| 170 | + name: coverage-report |
| 171 | + path: htmlcov/ |
| 172 | + retention-days: 30 |
| 173 | + |
| 174 | + # Performance benchmark job (optional) |
| 175 | + benchmark: |
| 176 | + runs-on: ubuntu-latest |
| 177 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 178 | + steps: |
| 179 | + - uses: actions/checkout@v4 |
| 180 | + - name: Set up Python |
| 181 | + uses: actions/setup-python@v4 |
| 182 | + with: |
| 183 | + python-version: "3.11" |
| 184 | + |
| 185 | + - name: Install dependencies |
| 186 | + run: | |
| 187 | + python -m pip install --upgrade pip |
| 188 | + pip install poetry |
| 189 | + poetry install --no-interaction |
| 190 | +
|
| 191 | + - name: Run benchmarks |
| 192 | + run: | |
| 193 | + poetry run pytest -m "performance" --benchmark-only --benchmark-json=benchmark.json || true |
| 194 | + timeout-minutes: 10 |
| 195 | + |
| 196 | + - name: Upload benchmark results |
| 197 | + uses: actions/upload-artifact@v3 |
| 198 | + if: always() |
40 | 199 | with: |
41 | | - pkg_folder: "kdp" |
42 | | - PYTHON_VERSION: ${{ matrix.python-version }} |
| 200 | + name: benchmark-results |
| 201 | + path: benchmark.json |
| 202 | + retention-days: 30 |
0 commit comments