ci: skip redundant test run during publish (#645) #1008
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
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: ["**"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| MPLBACKEND: Agg | |
| PLOTLY_RENDERER: json | |
| FLIXOPT_CI: false | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.10.9" | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Run Ruff | |
| run: | | |
| uvx ruff check . --output-format=github | |
| uvx ruff format --check --diff . | |
| test: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| needs: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.10.9" | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv pip install --system .[dev] | |
| - name: Run tests | |
| run: pytest -v --numprocesses=auto | |
| test-examples: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 45 | |
| needs: lint | |
| # Only run on main branch or when called by release workflow (not on PRs) | |
| if: github.event_name != 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.10.9" | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install dependencies | |
| run: uv pip install --system .[dev] | |
| - name: Run example tests | |
| run: pytest -v -m examples --numprocesses=auto | |
| security: | |
| runs-on: ubuntu-24.04 | |
| needs: lint | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.10.9" | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Run Bandit | |
| run: | | |
| uvx bandit -r flixopt/ -c pyproject.toml -f json -o bandit-report.json -q --severity-level high --confidence-level medium | |
| uvx bandit -r flixopt/ -c pyproject.toml -q --exit-zero | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: security-report | |
| path: bandit-report.json | |
| retention-days: 30 |