Skip to content

ci: run only fast tests and skip slow notebooks on draft PRs#562

Merged
FBumann merged 8 commits into
mainfrom
feature/faster-ci
Jul 22, 2026
Merged

ci: run only fast tests and skip slow notebooks on draft PRs#562
FBumann merged 8 commits into
mainfrom
feature/faster-ci

Conversation

@FBumann

@FBumann FBumann commented Jan 10, 2026

Copy link
Copy Markdown
Member

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Related Issues

Closes #(issue number)

Testing

  • I have tested my changes
  • Existing tests still pass

Checklist

  • My code follows the project style
  • I have updated documentation if needed
  • I have added tests for new functionality (if applicable)

Summary by CodeRabbit

  • Chores
    • Expanded CI workflow triggers and added path-based filters for documentation and test runs.
    • Documentation builds now run slow notebooks in parallel when the executed-notebooks cache is missing, skipping this step for draft pull requests.
  • Tests
    • Test execution is draft-aware: draft pull requests exclude non-essential test categories, while non-draft/ready builds run the full suite.

@coderabbitai

coderabbitai Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

GitHub Actions documentation and test workflows now monitor workflow-file changes, use explicit pull request event types, execute slow notebooks for eligible documentation builds, and exclude selected test categories for draft pull requests.

Changes

CI workflow execution

Layer / File(s) Summary
Workflow trigger updates
.github/workflows/docs.yaml, .github/workflows/tests.yaml
Documentation and test workflows add .github/workflows/** or relevant path filters and explicitly handle opened, synchronize, reopened, and ready_for_review pull request events.
Draft-aware notebook and test execution
.github/workflows/docs.yaml, .github/workflows/tests.yaml
Documentation builds execute notebooks listed in docs/notebooks/slow_notebooks.txt in parallel on cache misses for non-draft pull requests; draft pull requests exclude examples, slow, and deprecated_api tests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is just the unfilled template and lacks any substantive summary, issue, or testing details. Replace the template text with a real summary, fill Type of Change, Related Issues, Testing, and complete the checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main CI change to run only fast tests on draft pull requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/faster-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@FBumann FBumann changed the title Speed up ci by only ranning fast tests on drafts Speed up ci by only running fast tests on drafts Jan 10, 2026
@FBumann
FBumann marked this pull request as ready for review January 10, 2026 15:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/docs.yaml (1)

87-93: Consider aligning draft-check syntax with tests.yaml.

The condition uses GitHub Actions expression syntax (!= true), while tests.yaml line 76 uses bash string comparison (== "true"). Both work correctly, but for consistency and explicitness, consider adopting the bash approach used in tests.yaml:

-      - name: Execute slow notebooks
-        if: steps.notebook-cache.outputs.cache-hit != 'true' && github.event.pull_request.draft != true
+      - name: Execute slow notebooks
+        if: steps.notebook-cache.outputs.cache-hit != 'true' && github.event.pull_request.draft != 'true'

Note: Sequential execution (via cat | xargs) is appropriate for slow notebooks to avoid resource contention, unlike the parallel execution (xargs -P 4) used for fast notebooks.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e3a118 and 0176460.

📒 Files selected for processing (2)
  • .github/workflows/docs.yaml
  • .github/workflows/tests.yaml
🔇 Additional comments (3)
.github/workflows/tests.yaml (2)

6-10: LGTM: Path filters enhance workflow precision.

The path filters appropriately trigger the workflow for relevant changes (source code, tests, dependencies, and workflow configs). Including .github/workflows/** ensures the CI re-runs when the workflow definitions themselves change.

Also applies to: 13-17


75-82: The review comment is based on an incorrect assumption.

The pytest configuration in pyproject.toml does not contain addopts settings that exclude examples. The configuration only defines the three markers (slow, examples, deprecated_api) without any default exclusion rules.

In the workflow:

  • Draft PRs: Examples are explicitly excluded via the -m "not examples and not slow and not deprecated_api" flag in the pytest command
  • Non-draft/push: Pytest runs without any marker filters, meaning examples will run

The comment on line 80 stating "examples excluded via addopts" is misleading. Examples are not excluded by default configuration; they're only excluded for draft PRs via the explicit -m flag.

Likely an incorrect or invalid review comment.

.github/workflows/docs.yaml (1)

10-10: LGTM: Path filters aligned with tests workflow.

Adding .github/workflows/** and flixopt/** ensures documentation builds when workflow configs or source code change, maintaining consistency with the tests workflow.

Also applies to: 15-16

@FBumann
FBumann force-pushed the feature/faster-ci branch from 5c97458 to ee49258 Compare July 22, 2026 11:22
@FBumann FBumann changed the title Speed up ci by only running fast tests on drafts ci: run only fast tests and skip slow notebooks on draft PRs Jul 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/docs.yaml (1)

52-54: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Disable persisted checkout credentials in the CI jobs that run repository-controlled code.

actions/checkout persists credentials by default. Set persist-credentials: false at .github/workflows/docs.yaml#L52-L54 and each actions/checkout step in .github/workflows/tests.yaml; leave the deploy checkout authenticated because it pushes with mike.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs.yaml around lines 52 - 54, Disable persisted checkout
credentials by adding persist-credentials: false to the actions/checkout steps
at .github/workflows/docs.yaml lines 52-54 and .github/workflows/tests.yaml
lines 35, 60, 91, and 112. Leave the deploy checkout that uses mike unchanged
because it requires authentication to push.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/docs.yaml:
- Around line 97-103: Update the notebook cache configuration associated with
the “Execute slow notebooks” step so draft and ready-for-review/full runs cannot
share a cache entry containing different notebook outputs. Include the execution
mode and slow_notebooks.txt in the cache key, or disable cache saving for draft
runs, while preserving the existing slow-notebook skip behavior on cache hits.

In @.github/workflows/tests.yaml:
- Around line 75-82: Add a workflow-level permissions block granting only
contents: read, alongside the existing workflow configuration in tests.yaml.
Keep the pytest execution branches unchanged and ensure no broader token scopes
are introduced.

---

Outside diff comments:
In @.github/workflows/docs.yaml:
- Around line 52-54: Disable persisted checkout credentials by adding
persist-credentials: false to the actions/checkout steps at
.github/workflows/docs.yaml lines 52-54 and .github/workflows/tests.yaml lines
35, 60, 91, and 112. Leave the deploy checkout that uses mike unchanged because
it requires authentication to push.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be757317-434c-405e-b012-608aa00a57cc

📥 Commits

Reviewing files that changed from the base of the PR and between 5c97458 and ee49258.

📒 Files selected for processing (2)
  • .github/workflows/docs.yaml
  • .github/workflows/tests.yaml

Comment on lines +97 to +103
- name: Execute slow notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true' && github.event.pull_request.draft != 'true'
run: |
set -eo pipefail
# Execute slow notebooks in parallel (skip on draft PRs)
cd docs/notebooks && cat slow_notebooks.txt | \
xargs -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files .github/workflows/docs.yaml
wc -l .github/workflows/docs.yaml
sed -n '1,220p' .github/workflows/docs.yaml

Repository: flixOpt/flixopt

Length of output: 6367


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect cache-related references in the workflow and nearby docs notebook paths.
rg -n "notebook-cache|slow_notebooks|ready_for_review|draft != 'true'|actions/cache|cache-key|cache-hit" .github/workflows/docs.yaml docs -S

Repository: flixOpt/flixopt

Length of output: 1563


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# If the workflow references separate cache keys or restore-keys, inspect the exact expressions.
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/docs.yaml')
text = p.read_text()
for needle in ['notebook-cache', 'slow_notebooks', 'ready_for_review', 'cache-hit', 'actions/cache', 'restore-keys', 'key:']:
    print(f'## {needle}')
    for i, line in enumerate(text.splitlines(), 1):
        if needle in line:
            print(f'{i}: {line}')
PY

Repository: flixOpt/flixopt

Length of output: 1670


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' .github/workflows/docs.yaml

Repository: flixOpt/flixopt

Length of output: 6307


Separate draft and full notebook caches. The cache key only hashes notebooks and flixopt source, so a draft PR run can save fast-only outputs under the same key that a later ready_for_review run will hit and then skip the slow notebooks. Include execution mode/slow_notebooks.txt in the key, or prevent draft runs from saving the cache.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs.yaml around lines 97 - 103, Update the notebook cache
configuration associated with the “Execute slow notebooks” step so draft and
ready-for-review/full runs cannot share a cache entry containing different
notebook outputs. Include the execution mode and slow_notebooks.txt in the cache
key, or disable cache saving for draft runs, while preserving the existing
slow-notebook skip behavior on cache hits.

Comment on lines +75 to +82
run: |
if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then
# Draft PR: skip examples, slow, and deprecated_api
pytest -v --numprocesses=auto -m "not examples and not slow and not deprecated_api"
else
# Ready PR & main push: examples excluded via addopts
pytest -v --numprocesses=auto
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,220p' .github/workflows/tests.yaml

Repository: flixOpt/flixopt

Length of output: 3440


🌐 Web query:

GitHub Actions GITHUB_TOKEN permissions default contents read upload-artifact permissions required actions/upload-artifact checkout least privilege workflow permissions

💡 Result:

The GitHub Actions GITHUB_TOKEN is a temporary, automatically generated secret used to authenticate API requests within workflows [1][2]. Applying the principle of least privilege is a critical security best practice for GitHub Actions [3][4]. Default Permissions For most new repositories and organizations, the default permission for the GITHUB_TOKEN is set to read-only (specifically for contents and packages) [5][6][2]. You can verify or change this default in your repository or organization settings under Actions > General > Workflow permissions [5][2]. Permissions for Standard Actions 1. actions/checkout: This action typically requires read access to repository contents to fetch the code [1][6]. 2. actions/upload-artifact: This action does not rely on the GITHUB_TOKEN for its core functionality; it uses a separate, internal token managed by the GitHub Actions runner [7]. Therefore, you do not need to grant explicit GITHUB_TOKEN permissions for artifact uploads [7]. Note that "permission denied" errors encountered with this action are almost always related to file system permissions on the runner (e.g., trying to access a file created by a different user, such as root in Docker) rather than GITHUB_TOKEN scopes [8][9][10]. Implementing Least Privilege To enforce the principle of least privilege, explicitly define permissions in your workflow YAML file [3][4]. Any permission not listed under the permissions key is set to none by default [1]. Example of a minimal permissions configuration: permissions: contents: read If a specific job requires more access (e.g., to create an issue), you can scope the permissions for that job specifically: jobs: job_name: permissions: contents: read issues: write steps: - uses: actions/checkout@v4 - run: gh issue create... For complex workflows, you can use monitoring tools to identify the minimum set of permissions required before locking them down [2].

Citations:


Restrict the workflow token here. Add a permissions block with contents: read at the workflow level; none of these jobs need additional scopes.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 51-82: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests.yaml around lines 75 - 82, Add a workflow-level
permissions block granting only contents: read, alongside the existing workflow
configuration in tests.yaml. Keep the pytest execution branches unchanged and
ensure no broader token scopes are introduced.

Source: Linters/SAST tools

@FBumann
FBumann merged commit 5765530 into main Jul 22, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant