|
| 1 | +# .github/workflows/python-tests.yml |
1 | 2 | name: Python (Chapters) |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
5 | | - branches: [ main, master ] |
| 6 | + branches: [ "main" ] |
6 | 7 | pull_request: |
7 | | - branches: [ main, master ] |
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | test: |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | strategy: |
13 | 13 | matrix: |
14 | | - python-version: ["3.10", "3.11"] |
| 14 | + chapter: [ch2_rl_formulation, ch3_bandits] # add/remove chapters as needed |
15 | 15 | steps: |
16 | | - - uses: actions/checkout@v4 |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
17 | 18 |
|
18 | 19 | - name: Set up Python |
19 | 20 | uses: actions/setup-python@v5 |
20 | 21 | with: |
21 | | - python-version: ${{ matrix.python-version }} |
| 22 | + python-version: "3.10" |
22 | 23 |
|
23 | | - - name: Install root deps |
| 24 | + - name: Install deps |
24 | 25 | run: | |
25 | 26 | python -m pip install --upgrade pip |
26 | | - pip install -r requirements.txt |
| 27 | + # Root requirements (optional) |
| 28 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 29 | + # Chapter-specific requirements (if present) |
| 30 | + if [ -f "${{ matrix.chapter }}/requirements.txt" ]; then \ |
| 31 | + pip install -r "${{ matrix.chapter }}/requirements.txt"; \ |
| 32 | + fi |
| 33 | + pip install pytest |
27 | 34 |
|
28 | | - - name: Run Chapter 2 tests |
29 | | - run: pytest -q ch2_rl_formulation/tests |
| 35 | + - name: Make repo importable |
| 36 | + run: echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV |
30 | 37 |
|
31 | | - - name: Run Chapter 3 tests |
32 | | - run: pytest -q ch3_multi_armed_bandits/tests |
| 38 | + - name: Run ${{ matrix.chapter }} tests |
| 39 | + run: pytest -q ${{ matrix.chapter }}/tests |
0 commit comments