|
| 1 | +# Tests PRs on multiple operating systems and Python/Java versions |
| 2 | +name: Downstream - Timefold Solver Enterprise for Python |
| 3 | + |
| 4 | +on: |
| 5 | + # Enables the workflow to run on PRs from forks; |
| 6 | + # token sharing is safe here, because enterprise is a private repo and therefore fully under our control. |
| 7 | + pull_request_target: |
| 8 | + branches: [ main, '*.x' ] |
| 9 | + types: |
| 10 | + - opened |
| 11 | + - reopened |
| 12 | + - synchronize |
| 13 | + paths-ignore: |
| 14 | + - 'LICENSE*' |
| 15 | + - '.gitignore' |
| 16 | + - '**.md' |
| 17 | + - '**.adoc' |
| 18 | + - '*.txt' |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + concurrency: |
| 27 | + group: downstream-enterprise-python-${{ github.event_name }}-${{ github.head_ref }} |
| 28 | + cancel-in-progress: true |
| 29 | + timeout-minutes: 120 |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Check out repository code |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + path: './timefold-solver-python' |
| 37 | + |
| 38 | + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. |
| 39 | + - name: Checkout timefold-solver (PR) # Checkout the PR branch first, if it exists |
| 40 | + id: checkout-solver |
| 41 | + uses: actions/checkout@v4 |
| 42 | + continue-on-error: true |
| 43 | + with: |
| 44 | + repository: ${{ github.actor }}/timefold-solver |
| 45 | + ref: ${{ github.head_ref }} |
| 46 | + path: ./timefold-solver |
| 47 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 48 | + - name: Checkout timefold-solver (main) # Checkout the main branch if the PR branch does not exist |
| 49 | + if: steps.checkout-solver.outcome != 'success' |
| 50 | + uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + repository: TimefoldAI/timefold-solver |
| 53 | + ref: main |
| 54 | + path: ./timefold-solver |
| 55 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 56 | + - name: Prevent stale fork of timefold-solver |
| 57 | + env: |
| 58 | + BLESSED_REPO: "timefold-solver" |
| 59 | + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} |
| 60 | + shell: bash |
| 61 | + working-directory: ./timefold-solver |
| 62 | + run: .github/scripts/prevent_stale_fork.sh |
| 63 | + |
| 64 | + # Clone timefold-solver-enterprise |
| 65 | + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. |
| 66 | + - name: Checkout timefold-solver-enterprise (PR) # Checkout the PR branch first, if it exists |
| 67 | + id: checkout-solver-enterprise |
| 68 | + uses: actions/checkout@v4 |
| 69 | + continue-on-error: true |
| 70 | + with: |
| 71 | + repository: TimefoldAI/timefold-solver-enterprise |
| 72 | + ref: ${{ github.head_ref }} |
| 73 | + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. |
| 74 | + path: ./timefold-solver-enterprise |
| 75 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 76 | + - name: Checkout timefold-solver-enterprise (main) # Checkout the main branch if the PR branch does not exist |
| 77 | + if: steps.checkout-solver-enterprise.outcome != 'success' |
| 78 | + uses: actions/checkout@v4 |
| 79 | + with: |
| 80 | + repository: TimefoldAI/timefold-solver-enterprise |
| 81 | + ref: main |
| 82 | + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. |
| 83 | + path: ./timefold-solver-enterprise |
| 84 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 85 | + - name: Prevent stale fork of timefold-solver-enterprise |
| 86 | + env: |
| 87 | + BLESSED_REPO: "timefold-solver-enterprise" |
| 88 | + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} |
| 89 | + shell: bash |
| 90 | + working-directory: ./timefold-solver-enterprise |
| 91 | + run: ../timefold-solver/.github/scripts/prevent_stale_fork.sh |
| 92 | + |
| 93 | + # Clone timefold-solver-python-enterprise |
| 94 | + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. |
| 95 | + - name: Checkout timefold-solver-enterprise-python (PR) # Checkout the PR branch first, if it exists |
| 96 | + id: checkout-solver-enterprise-python |
| 97 | + uses: actions/checkout@v4 |
| 98 | + continue-on-error: true |
| 99 | + with: |
| 100 | + repository: TimefoldAI/timefold-solver-enterprise-python |
| 101 | + ref: ${{ github.head_ref }} |
| 102 | + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. |
| 103 | + path: ./timefold-solver-enterprise-python |
| 104 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 105 | + - name: Checkout timefold-solver-python-enterprise-python (main) # Checkout the main branch if the PR branch does not exist |
| 106 | + if: steps.checkout-solver-enterprise-python.outcome != 'success' |
| 107 | + uses: actions/checkout@v4 |
| 108 | + with: |
| 109 | + repository: TimefoldAI/timefold-solver-enterprise-python |
| 110 | + ref: main |
| 111 | + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. |
| 112 | + path: ./timefold-solver-enterprise-python |
| 113 | + fetch-depth: 0 # Otherwise merge will fail on account of not having history. |
| 114 | + - name: Prevent stale fork of timefold-solver-enterprise-python |
| 115 | + env: |
| 116 | + BLESSED_REPO: "timefold-solver-enterprise-python" |
| 117 | + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} |
| 118 | + shell: bash |
| 119 | + working-directory: ./timefold-solver-enterprise-python |
| 120 | + run: ../timefold-solver/.github/scripts/prevent_stale_fork.sh |
| 121 | + |
| 122 | + # Build and test |
| 123 | + - name: Set up JDK 17 |
| 124 | + uses: actions/setup-java@v4 |
| 125 | + with: |
| 126 | + java-version: 17 |
| 127 | + distribution: 'temurin' |
| 128 | + cache: 'maven' |
| 129 | + # Need to install all Python versions in the same run for tox |
| 130 | + - name: Python 3.10, Python 3.11, Python 3.12 Setup |
| 131 | + uses: actions/setup-python@v4 |
| 132 | + with: |
| 133 | + python-version: | |
| 134 | + 3.10 |
| 135 | + 3.11 |
| 136 | + 3.12 |
| 137 | + cache: 'pip' |
| 138 | + cache-dependency-path: | |
| 139 | + **/setup.py |
| 140 | + - name: Install tox |
| 141 | + run: |
| 142 | + python -m pip install --upgrade pip |
| 143 | + pip install tox build |
| 144 | + - name: Quickly build timefold-solver |
| 145 | + working-directory: ./timefold-solver |
| 146 | + run: mvn -B -Dquickly clean install |
| 147 | + - name: Quickly Build timefold-solver-enterprise |
| 148 | + working-directory: ./timefold-solver-enterprise |
| 149 | + shell: bash |
| 150 | + run: mvn -B -Dquickly clean verify |
| 151 | + - name: Build with Maven to install parent poms for python build |
| 152 | + working-directory: ./timefold-solver-python |
| 153 | + run: mvn -B --fail-at-end clean install |
| 154 | + - name: Build timefold solver python |
| 155 | + working-directory: ./timefold-solver-python |
| 156 | + run: python -m build |
| 157 | + - name: Run tox on timefold solver enterprise python test suite |
| 158 | + working-directory: ./timefold-solver-enterprise-python |
| 159 | + env: |
| 160 | + PIP_FIND_LINKS: ${{ github.workspace }}/timefold-solver-python/dist |
| 161 | + run: tox |
0 commit comments