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