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