-
Notifications
You must be signed in to change notification settings - Fork 9
ci: run only fast tests and skip slow notebooks on draft PRs #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b7c4936
ecf9265
cfaeda0
a594b56
80e52e5
9609435
2cc84c2
ee49258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,19 @@ name: Tests | |
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'flixopt/**' | ||
| - 'tests/**' | ||
| - 'pyproject.toml' | ||
| - '.github/workflows/**' | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: ["**"] | ||
| paths: | ||
| - 'flixopt/**' | ||
| - 'tests/**' | ||
| - 'pyproject.toml' | ||
| - '.github/workflows/**' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
|
|
@@ -61,7 +72,14 @@ jobs: | |
| run: uv pip install --system .[dev] | ||
|
|
||
| - name: Run tests | ||
| run: pytest -v --numprocesses=auto | ||
| 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 | ||
|
Comment on lines
+75
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.yamlRepository: flixOpt/flixopt Length of output: 3440 🌐 Web query:
💡 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 🧰 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 AgentsSource: Linters/SAST tools |
||
|
|
||
| test-examples: | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
There was a problem hiding this comment.
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:
Repository: flixOpt/flixopt
Length of output: 6367
🏁 Script executed:
Repository: flixOpt/flixopt
Length of output: 1563
🏁 Script executed:
Repository: flixOpt/flixopt
Length of output: 1670
🏁 Script executed:
Repository: flixOpt/flixopt
Length of output: 6307
Separate draft and full notebook caches. The cache key only hashes notebooks and
flixoptsource, so a draft PR run can save fast-only outputs under the same key that a laterready_for_reviewrun will hit and then skip the slow notebooks. Include execution mode/slow_notebooks.txtin the key, or prevent draft runs from saving the cache.🤖 Prompt for AI Agents