Add support for ipopt solver #539
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: We use the insecure pull_request_target to allow running workflows from forks. | |
# However, we've added checks (see below) for safety. | |
# In short, the 'safe to test' label must exist AND the workflow must be run by someone with write access. | |
# See more details here: | |
# - https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ | |
# - https://michaelheap.com/access-secrets-from-forks/ | |
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: ["*"] | |
pull_request_target: | |
branches: ["*"] | |
schedule: | |
- cron: "0 5 * * WED" | |
workflow_dispatch: | |
jobs: | |
check_permissions: | |
runs-on: ubuntu-latest | |
steps: | |
# Important checks to ensure that the user has the required permissions. See note above. | |
# Step 1: If user has current permissions we're good! | |
- name: Get User Permission | |
id: checkAccess | |
uses: actions-cool/check-user-permission@v2 | |
with: | |
require: write | |
username: ${{ github.actor }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Otherwise, get triggering user's permissions | |
- name: Get Triggering User Permission | |
if: steps.checkAccess.outputs.require-result == 'false' | |
id: checkTriggeringAccess | |
uses: actions-cool/check-user-permission@v2 | |
with: | |
require: write | |
username: ${{ github.triggering_actor }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# If neither has permissions and no 'safe to test' label throw error | |
- name: Check User Permission | |
if: steps.checkAccess.outputs.require-result == 'false' && steps.checkTriggeringAccess.outputs.require-result == 'false' && !contains(github.event.pull_request.labels.*.name, 'safe to test') | |
shell: bash | |
run: | | |
echo "${{ github.triggering_actor }} does not have permissions on this repo." | |
echo "Re-run the test yourself if you have write permissions. Alternatively, add the label 'safe to test' to the PR to give the user write permissions (only if you trust them)." | |
exit 1 | |
run: | |
if: | | |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || | |
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) || | |
(github.event_name != 'pull_request_target' && github.event_name != 'pull_request') | |
runs-on: ubuntu-latest | |
needs: check_permissions | |
continue-on-error: ${{ !matrix.latest }} | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.13"] | |
latest: [true] | |
include: | |
- python-version: "3.9" | |
latest: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
pip install .[dev] | |
- uses: ./.github/actions/setup_optimizers_linux | |
with: | |
GUROBI_WLS: ${{ secrets.GUROBI_WLS }} | |
CHECK_LICENSE: true | |
- name: Run tests and collect coverage | |
run: pytest --cov | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4-beta | |
with: | |
name: coverage-python-${{ matrix.python-version }} | |
flags: smart-tests | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |