-
Notifications
You must be signed in to change notification settings - Fork 45
61 lines (57 loc) · 2.2 KB
/
PR_license.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
# This workflow uses `pull_request_target` which has access to a WLS license. For security reasons, this workflow
# will only be run for PRs from a fork after it has been assessed by a repository owner and has the "safe to test"
# label added. Any changes to the PR in need of a retriggering of the workflow require the removal and re-adding of the
# "safe to test" label.
#
# Since a subset of tests was already run in the nolicense workflow, this workflow runs skips the following tests:
# - Lint with flake8.
name: build and test PR, license required
on:
pull_request_target:
types: [labeled]
permissions:
contents: read
jobs:
build_pr_license:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
gurobi-version: ["gurobi10", "gurobi11","gurobi12"]
exclude:
- python-version: "3.12"
gurobi-version: "gurobi10"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest tox tox-gh-actions
- shell: bash
id: write-license
env:
LICENSE: ${{ secrets.LICENSE }}
run: |
echo "$LICENSE" > $PWD/gurobi.lic
echo "grb_license_file=$PWD/gurobi.lic" >> $GITHUB_OUTPUT
- name: Test with tox
run: |
tox
env:
GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }}
GUROBI_VERSION: ${{ matrix.gurobi-version }}
- name: Run examples with Gurobi 11
if: ${{ (matrix.gurobi-version == 'gurobi11') && (matrix.python-version == '3.12') }}
env:
GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }}
GUROBI_VERSION: ${{ matrix.gurobi-version }}
run: |
python_version_no_dot=$(echo "${{ matrix.python-version }}" | tr -d '.')
tox -e py${python_version_no_dot}-examples-${{matrix.gurobi-version}}