diff --git a/.github/workflows/downstream_python_enterprise.yml b/.github/workflows/downstream_python_enterprise.yml new file mode 100644 index 0000000..a74d96c --- /dev/null +++ b/.github/workflows/downstream_python_enterprise.yml @@ -0,0 +1,161 @@ +# Tests PRs on multiple operating systems and Python/Java versions +name: Downstream - Timefold Solver Enterprise for Python + +on: + # Enables the workflow to run on PRs from forks; + # token sharing is safe here, because enterprise is a private repo and therefore fully under our control. + pull_request_target: + branches: [ main, '*.x' ] + types: + - opened + - reopened + - synchronize + paths-ignore: + - 'LICENSE*' + - '.gitignore' + - '**.md' + - '**.adoc' + - '*.txt' + +defaults: + run: + shell: bash + +jobs: + build: + concurrency: + group: downstream-enterprise-python-${{ github.event_name }}-${{ github.head_ref }} + cancel-in-progress: true + timeout-minutes: 120 + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + path: './timefold-solver-python' + + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. + - name: Checkout timefold-solver (PR) # Checkout the PR branch first, if it exists + id: checkout-solver + uses: actions/checkout@v4 + continue-on-error: true + with: + repository: ${{ github.actor }}/timefold-solver + ref: ${{ github.head_ref }} + path: ./timefold-solver + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Checkout timefold-solver (main) # Checkout the main branch if the PR branch does not exist + if: steps.checkout-solver.outcome != 'success' + uses: actions/checkout@v4 + with: + repository: TimefoldAI/timefold-solver + ref: main + path: ./timefold-solver + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Prevent stale fork of timefold-solver + env: + BLESSED_REPO: "timefold-solver" + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} + shell: bash + working-directory: ./timefold-solver + run: .github/scripts/prevent_stale_fork.sh + + # Clone timefold-solver-enterprise + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. + - name: Checkout timefold-solver-enterprise (PR) # Checkout the PR branch first, if it exists + id: checkout-solver-enterprise + uses: actions/checkout@v4 + continue-on-error: true + with: + repository: TimefoldAI/timefold-solver-enterprise + ref: ${{ github.head_ref }} + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. + path: ./timefold-solver-enterprise + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Checkout timefold-solver-enterprise (main) # Checkout the main branch if the PR branch does not exist + if: steps.checkout-solver-enterprise.outcome != 'success' + uses: actions/checkout@v4 + with: + repository: TimefoldAI/timefold-solver-enterprise + ref: main + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. + path: ./timefold-solver-enterprise + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Prevent stale fork of timefold-solver-enterprise + env: + BLESSED_REPO: "timefold-solver-enterprise" + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} + shell: bash + working-directory: ./timefold-solver-enterprise + run: ../timefold-solver/.github/scripts/prevent_stale_fork.sh + + # Clone timefold-solver-python-enterprise + # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. + - name: Checkout timefold-solver-enterprise-python (PR) # Checkout the PR branch first, if it exists + id: checkout-solver-enterprise-python + uses: actions/checkout@v4 + continue-on-error: true + with: + repository: TimefoldAI/timefold-solver-enterprise-python + ref: ${{ github.head_ref }} + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. + path: ./timefold-solver-enterprise-python + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Checkout timefold-solver-python-enterprise-python (main) # Checkout the main branch if the PR branch does not exist + if: steps.checkout-solver-enterprise-python.outcome != 'success' + uses: actions/checkout@v4 + with: + repository: TimefoldAI/timefold-solver-enterprise-python + ref: main + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} # Safe; only used to clone the repo and not stored in the fork. + path: ./timefold-solver-enterprise-python + fetch-depth: 0 # Otherwise merge will fail on account of not having history. + - name: Prevent stale fork of timefold-solver-enterprise-python + env: + BLESSED_REPO: "timefold-solver-enterprise-python" + BLESSED_BRANCH: ${{ endsWith(github.head_ref, '.x') && github.head_ref || 'main' }} + shell: bash + working-directory: ./timefold-solver-enterprise-python + run: ../timefold-solver/.github/scripts/prevent_stale_fork.sh + + # Build and test + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + # Need to install all Python versions in the same run for tox + - name: Python 3.10, Python 3.11, Python 3.12 Setup + uses: actions/setup-python@v4 + with: + python-version: | + 3.10 + 3.11 + 3.12 + cache: 'pip' + cache-dependency-path: | + **/setup.py + - name: Install tox + run: + python -m pip install --upgrade pip + pip install tox build + - name: Quickly build timefold-solver + working-directory: ./timefold-solver + run: mvn -B -Dquickly clean install + - name: Quickly Build timefold-solver-enterprise + working-directory: ./timefold-solver-enterprise + shell: bash + run: mvn -B -Dquickly clean verify + - name: Build with Maven to install parent poms for python build + working-directory: ./timefold-solver-python + run: mvn -B --fail-at-end clean install + - name: Build timefold solver python + working-directory: ./timefold-solver-python + run: python -m build + - name: Run tox on timefold solver enterprise python test suite + working-directory: ./timefold-solver-enterprise-python + env: + PIP_FIND_LINKS: ${{ github.workspace }}/timefold-solver-python/dist + run: tox