Skip to content

Conversation

@misrasaurabh1
Copy link
Contributor

@misrasaurabh1 misrasaurabh1 commented Oct 9, 2025

PR Type

Documentation, Enhancement


Description

  • Improve GitHub Actions setup guidance

  • Add concurrency and paths filters

  • Clarify Codeflash PR optimization wording

  • Advise on working-directory and tests setup


Diagram Walkthrough

flowchart LR
  Docs["Docs: Codeflash GitHub Actions guide"]
  Wording["Clearer PR optimization wording"]
  WorkflowTips["Workflow config tips (paths, concurrency)"]
  SetupNotes["Setup notes (working-directory, tests)"]

  Docs -- "revise text" --> Wording
  Docs -- "add examples" --> WorkflowTips
  Docs -- "add notes" --> SetupNotes
Loading

File Walkthrough

Relevant files
Documentation
codeflash-github-actions.mdx
Improve workflow guidance and clarity for GitHub Actions 

docs/optimizing-with-codeflash/codeflash-github-actions.mdx

  • Clarify PR optimization phrasing.
  • Add paths filter to pull_request trigger.
  • Add concurrency group and cancel-in-progress.
  • Note working-directory and test setup requirements.
+16/-4   

Signed-off-by: Saurabh Misra <misra.saurabh1@gmail.com>
@misrasaurabh1 misrasaurabh1 changed the title revert the init selection arrow to default. Update the docs for pr optimizations Oct 9, 2025
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

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

Ambiguous phrasing

The sentence "Automating optimization in the Pull Request stage is how most teams use Codeflash, to continuously find optimizations..." reads slightly awkward with a comma splice; consider rephrasing for clarity (e.g., replace comma with "and" or split into two sentences).

Automating optimization in the Pull Request stage is how most teams use Codeflash, to
continuously find optimizations for their new code.
Paths filter caveat

Adding a top-level 'paths: **' may be redundant; consider clarifying examples for mono-repo vs single-repo, and remind users that 'paths' restricts triggering to only those paths which might prevent optimization if config or tests live elsewhere.

  paths:
    - '**'  # Modify this to the path of your project in a mono-repo. Codeflash will only run when code in this directory is modified.
workflow_dispatch:
Working-directory placement

Guidance mentions setting 'working-directory' but example YAML does not show it; consider adding a concrete snippet showing 'defaults.run.working-directory' or per-step 'working-directory' to reduce confusion.

  Set the `working-directory` parameter in the yaml file, if the commands are meant to be run from some other directory.
</Step>

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Ensure step fails on errors

Running a CLI without failing the job on non-zero exit can hide errors. Ensure the
step fails on error and optionally add basic logging to surface diagnostics in CI.

docs/optimizing-with-codeflash/codeflash-github-actions.mdx [104-106]

 - name: Run Codeflash to find optimizations
   id: optimize_code
   run: |
-    codeflash
+    set -euo pipefail
+    codeflash 2>&1 | tee codeflash.log
Suggestion importance[1-10]: 7

__

Why: Adding 'set -euo pipefail' improves robustness and visibility by failing fast and logging; aligns with typical CI best practices. The existing snippet maps to the new hunk lines 104-106.

Medium
Possible issue
Tighten path filters safely

Using a blanket '' path filter can suppress runs on important workflow-only
changes (e.g., config, tests) and may also miss PRs where only workflow files change
but should still run. Add an explicit include for the workflow file or narrow the
glob to your source directory while including critical paths like tests.**

docs/optimizing-with-codeflash/codeflash-github-actions.mdx [70-72]

 on:
   pull_request:
     paths:
-      - '**'  # Modify this to the path of your project in a mono-repo. Codeflash will only run when code in this directory is modified.
+      - 'src/**'        # Narrow to your code directory in a monorepo
+      - 'tests/**'      # Ensure test changes still trigger optimization
+      - '.github/workflows/codeflash.yml'  # Always rerun if this workflow changes
Suggestion importance[1-10]: 6

__

Why: Suggestion is valid and can reduce unnecessary runs while ensuring important paths still trigger; it's context-dependent but improves workflow relevance. The existing code matches the new hunk lines 70-72.

Low
Prevent cross-PR cancellations

Using github.ref in pull_request events can group runs by branch ref across forks,
potentially cancelling unrelated PR runs. Use github.event.pull_request.head.sha to
scope grouping per PR commit to avoid cross-cancellation.

docs/optimizing-with-codeflash/codeflash-github-actions.mdx [74-77]

 concurrency:
-  # Any new push to the PR will cancel the previous run, so that only the latest code is optimized
-  group: ${{ github.workflow }}-${{ github.ref }}
+  # Cancel only prior runs for the same PR commit series
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
   cancel-in-progress: true
Suggestion importance[1-10]: 5

__

Why: The concern about grouping by ref is reasonable, but the proposed expression may not behave as intended for pull_request (uses number or ref, not head sha). Moderate improvement but not clearly superior.

Low

<Warning>
**Replace the TODOs** in the workflow file above with your project's specific setup commands.
</Warning>
Set the `working-directory` parameter in the yaml file, if the commands are meant to be run from some other directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the working-directory in the above yaml?

@misrasaurabh1 misrasaurabh1 merged commit 1f31b08 into main Oct 9, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants