|
| 1 | +name: Python |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [stable, development, '*.x'] |
| 6 | + paths: |
| 7 | + - '**/*.py' |
| 8 | + - '**/pyproject.toml' |
| 9 | + - '.github/**/*.yml' |
| 10 | + pull_request: |
| 11 | + branches: [stable, development, '*.x'] |
| 12 | + paths: |
| 13 | + - '**/*.py' |
| 14 | + - '**/pyproject.toml' |
| 15 | + - '.github/**/*.yml' |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + concurrency: |
| 20 | + group: pull_request_python-${{ github.event_name }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.java-version }}-${{ matrix.python-version }} |
| 21 | + cancel-in-progress: true |
| 22 | + runs-on: ${{matrix.os}} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: [ubuntu-latest, windows-latest, macOS-latest] |
| 26 | + java-version: [ 17 ] # Only the first supported LTS; already too many jobs here. |
| 27 | + # TODO: Add Python 3.10 once employee scheduling and school timetabling support it |
| 28 | + python-version: ['3.11', '3.12'] |
| 29 | + timeout-minutes: 120 |
| 30 | + steps: |
| 31 | + # Clone timefold-solver |
| 32 | + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. |
| 33 | + - name: Checkout timefold-solver (PR) # Checkout the PR branch first, if it exists |
| 34 | + if: github.head_ref # Only true if this is a PR. |
| 35 | + id: checkout-solver-pr |
| 36 | + uses: actions/checkout@v4 |
| 37 | + continue-on-error: true |
| 38 | + with: |
| 39 | + repository: ${{ github.actor }}/timefold-solver |
| 40 | + ref: ${{ github.head_ref }} |
| 41 | + path: ./timefold-solver |
| 42 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 43 | + - name: Checkout timefold-solver (main) # Checkout the main branch if the PR branch does not exist |
| 44 | + if: ${{ steps.checkout-solver-pr.outcome != 'success' }} |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + repository: TimefoldAI/timefold-solver |
| 48 | + ref: main |
| 49 | + path: ./timefold-solver |
| 50 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 51 | + - name: Prevent stale fork of timefold-solver # Solver can't be stale if development/stable branch requested. |
| 52 | + if: ${{ steps.checkout-solver-pr.outcome == 'success' }} |
| 53 | + env: |
| 54 | + BLESSED_REPO: "timefold-solver" |
| 55 | + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} |
| 56 | + shell: bash |
| 57 | + working-directory: ./timefold-solver |
| 58 | + run: .github/scripts/prevent_stale_fork.sh |
| 59 | + |
| 60 | + # Clone timefold-solver-python |
| 61 | + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. |
| 62 | + - name: Checkout timefold-solver-python (PR) # Checkout the PR branch first, if it exists |
| 63 | + if: github.head_ref # Only true if this is a PR. |
| 64 | + id: checkout-solver-python-pr |
| 65 | + uses: actions/checkout@v4 |
| 66 | + continue-on-error: true |
| 67 | + with: |
| 68 | + repository: ${{ github.actor }}/timefold-solver-python |
| 69 | + ref: ${{ github.head_ref }} |
| 70 | + path: ./timefold-solver-python |
| 71 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 72 | + - name: Checkout timefold-solver-python (main) # Checkout the main branch if the PR branch does not exist |
| 73 | + if: ${{ steps.checkout-solver-python-pr.outcome != 'success' }} |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + repository: TimefoldAI/timefold-solver-python |
| 77 | + ref: main |
| 78 | + path: ./timefold-solver-python |
| 79 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 80 | + - name: Prevent stale fork of timefold-solver-python # Solver can't be stale if development/stable branch requested. |
| 81 | + if: ${{ steps.checkout-solver-python-pr.outcome == 'success' }} |
| 82 | + env: |
| 83 | + BLESSED_REPO: "timefold-solver-python" |
| 84 | + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} |
| 85 | + shell: bash |
| 86 | + working-directory: ./timefold-solver-python |
| 87 | + run: ../timefold-solver/.github/scripts/prevent_stale_fork.sh |
| 88 | + |
| 89 | + # Clone timefold-quickstarts |
| 90 | + # No need to check for stale repo, as Github merges the main repo into the fork automatically. |
| 91 | + - name: Checkout timefold-quickstarts |
| 92 | + uses: actions/checkout@v4 |
| 93 | + with: |
| 94 | + path: './timefold-quickstarts' |
| 95 | + |
| 96 | + # Build and test |
| 97 | + - name: "Setup Java and Maven" |
| 98 | + uses: actions/setup-java@v3 |
| 99 | + with: |
| 100 | + java-version: ${{matrix.java-version}} |
| 101 | + distribution: 'temurin' |
| 102 | + cache: 'maven' |
| 103 | + |
| 104 | + - name: Python Setup |
| 105 | + uses: actions/setup-python@v4 |
| 106 | + with: |
| 107 | + python-version: ${{matrix.python-version}} |
| 108 | + cache: 'pip' |
| 109 | + cache-dependency-path: | |
| 110 | + **/pyproject.toml |
| 111 | +
|
| 112 | + - name: Install build |
| 113 | + run: |
| 114 | + python -m pip install --upgrade pip |
| 115 | + pip install build |
| 116 | + |
| 117 | + - name: Quickly build timefold-solver |
| 118 | + working-directory: ./timefold-solver |
| 119 | + run: mvn -B -Dquickly -DskipTests clean install |
| 120 | + |
| 121 | + - name: Build timefold-solver-python |
| 122 | + working-directory: ./timefold-solver-python |
| 123 | + run: python -m build |
| 124 | + |
| 125 | + - name: Build and test timefold-quickstarts |
| 126 | + working-directory: ./timefold-quickstarts |
| 127 | + env: |
| 128 | + TIMEFOLD_SOLVER_PYTHON_DIST: "${{ github.workspace }}/timefold-solver-python/dist" |
| 129 | + run: .github/scripts/run_python_tests.sh |
0 commit comments