Skip to content

Conversation

@aseembits93
Copy link
Contributor

@aseembits93 aseembits93 commented Aug 15, 2025

PR Type

Enhancement


Description

  • Prevent workflows running on draft pull requests

  • Add draft-check if to optimize job

  • Add draft-check if to all e2e workflows

  • Add draft-check if to CI and label workflows


Diagram Walkthrough

flowchart LR
  PR["Pull Request opened"] --> C["Check draft status"]
  C -- "draft == false" --> R["Run workflows"]
  C -- "draft == true" --> S["Skip workflows"]
Loading

File Walkthrough

Relevant files
Configuration changes
14 files
codeflash-optimize.yaml
Include draft check in optimize job                                           
+1/-1     
e2e-bubblesort-benchmark.yaml
Add draft-check `if` to benchmark job                                       
+1/-0     
e2e-bubblesort-pytest-nogit.yaml
Add draft-check `if` to pytest job                                             
+1/-0     
e2e-bubblesort-unittest.yaml
Add draft-check `if` to unittest job                                         
+1/-0     
e2e-coverage-optimization.yaml
Add draft-check `if` to coverage job                                         
+1/-0     
e2e-futurehouse-structure.yaml
Add draft-check `if` to structure job                                       
+1/-0     
e2e-init-optimization.yaml
Add draft-check `if` to init job                                                 
+1/-0     
e2e-topological-sort.yaml
Add draft-check `if` to topological job                                   
+1/-0     
e2e-tracer-replay.yaml
Add draft-check `if` to tracer job                                             
+1/-0     
label-workflow-changes.yml
Skip labeling on draft pull requests                                         
+1/-0     
mypy.yml
Skip type-check on draft pull requests                                     
+1/-0     
pr_agent.yml
Skip PR agent on draft pull requests                                         
+1/-1     
pre-commit.yaml
Skip pre-commit hooks on draft pull requests                         
+1/-0     
unit-tests.yaml
Skip unit tests on draft pull requests                                     
+1/-0     

@github-actions github-actions bot added workflow-modified This PR modifies GitHub Actions workflows Review effort 2/5 labels Aug 15, 2025
@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Context Guard

The new if condition uses github.event.pull_request.draft without verifying the event type. On non-pull_request triggers this context is undefined, causing the optimize job to always skip or fail. Add a guard for github.event_name == 'pull_request'.

if: ${{ github.actor != 'codeflash-ai[bot]' && github.event.pull_request.draft == false }}
Context Guard

The unconditional if: ${{ github.event.pull_request.draft == false }} applies to push and workflow_dispatch events where pull_request is undefined, leading to unexpected skips. Wrap or conditionally apply the check only on pull_request events.

if: ${{ github.event.pull_request.draft == false }}
Context Guard

The added if on github.event.pull_request.draft will skip the unit-tests job for push and workflow_dispatch events. Consider restricting this check to pull_request triggers to avoid unintended skips.

if: ${{ github.event.pull_request.draft == false }}

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Guard draft check on event type

Prevent evaluation errors on push events by checking that the workflow is running on
a pull request before accessing github.event.pull_request.draft. Add
github.event_name == 'pull_request' to the condition.

.github/workflows/mypy.yml [11]

-if: ${{ github.event.pull_request.draft == false }}
+if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
Suggestion importance[1-10]: 8

__

Why: Since this workflow is triggered on both push and pull_request, adding the github.event_name == 'pull_request' guard avoids evaluation failures when pull_request.draft is undefined.

Medium
Add pull request event guard

Guard the draft check by ensuring the event is a pull request to avoid null context
errors when this workflow runs on other event types. Prepend github.event_name ==
'pull_request' to the condition. This prevents evaluation failures in non-PR
triggers.

.github/workflows/codeflash-optimize.yaml [17]

-if: ${{ github.actor != 'codeflash-ai[bot]' && github.event.pull_request.draft == false }}
+if: ${{ github.event_name == 'pull_request' && github.actor != 'codeflash-ai[bot]' && github.event.pull_request.draft == false }}
Suggestion importance[1-10]: 7

__

Why: Guarding with github.event_name == 'pull_request' prevents null context errors when this workflow runs on non-PR events, making the draft check safe.

Medium

@aseembits93 aseembits93 deleted the ci-for-nondraft-pr branch August 17, 2025 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 2/5 workflow-modified This PR modifies GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants