Skip to content

feat: add support for custom working dir#5

Merged
georgeciubotaru merged 3 commits intomainfrom
feat/support-working-dir
Apr 7, 2026
Merged

feat: add support for custom working dir#5
georgeciubotaru merged 3 commits intomainfrom
feat/support-working-dir

Conversation

@georgeciubotaru
Copy link
Copy Markdown
Contributor

@georgeciubotaru georgeciubotaru commented Apr 7, 2026

ref: https://github.com/holdex/wizard/issues/1080

Summary by CodeRabbit

  • New Features

    • Added configurable working-directory support across PR checks so actions can run in a specified subdirectory; workflow/action input and environment propagation make this optional and default to the repository root.
  • Documentation

    • Updated docs and README with a new "Working Directory" section, examples, and guidance for using the working-directory input with reusable workflows and composed actions.

@georgeciubotaru georgeciubotaru self-assigned this Apr 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Warning

Rate limit exceeded

@georgeciubotaru has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 23 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 23 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8554489e-ef08-4017-a741-52c8d2db7185

📥 Commits

Reviewing files that changed from the base of the PR and between f6d644a and bf32402.

📒 Files selected for processing (2)
  • .github/actions/composed/pr-checks/action.yml
  • ACTIONS.md

Walkthrough

Adds a configurable working-directory that flows from the reusable workflow → composed pr-checks action → base composite actions via HOLDEX_WORKING_DIR, and sets shell step working-directory in base actions so commands run in the specified subdirectory.

Changes

Cohort / File(s) Summary
Base actions
.github/actions/base/commit-check/action.yml, .github/actions/base/markdown-check/action.yml, .github/actions/base/prettier/action.yml, .github/actions/base/setup-runtime/action.yml
Added `working-directory: ${{ env.HOLDEX_WORKING_DIR
Composed action & workflow
.github/actions/composed/pr-checks/action.yml, .github/workflows/pr-checks.yml
Added working-directory input (default ".") to composed action and workflow; write HOLDEX_WORKING_DIR into environment early so downstream base actions use it.
Docs / README
ACTIONS.md, README.md
Documented working-directory/HOLDEX_WORKING_DIR usage and examples for the composed action and reusable workflow.

Sequence Diagram

sequenceDiagram
    participant Workflow as pr-checks.yml
    participant Composed as composed/pr-checks
    participant Base as Base Actions
    participant Shell as Shell/Runner

    Workflow->>Workflow: receive inputs (working-directory)
    Workflow->>Workflow: export HOLDEX_WORKING_DIR to $GITHUB_ENV
    Workflow->>Composed: call composed/pr-checks (with working-directory)
    Composed->>Composed: set HOLDEX_WORKING_DIR (input or existing)
    Composed->>Base: invoke base actions (commit-check, prettier, markdown-check, setup-runtime)
    Base->>Base: set step working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
    Base->>Shell: run commands in configured directory (e.g., package.json checks, linters)
    Shell-->>Base: command results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • zolotokrylin
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: adding support for configurable working directory across GitHub Actions workflows and base actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/support-working-dir

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 and usage tips.

@holdex
Copy link
Copy Markdown

holdex bot commented Apr 7, 2026

Time Submission Status

Member Status Time Action Last Update
georgeciubotaru ✅ Submitted 30min Update time Apr 7, 2026, 9:19 AM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@georgeciubotaru
Copy link
Copy Markdown
Contributor Author

@holdex pr submit-time 30m

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 (2)
.github/actions/base/prettier/action.yml (1)

22-33: ⚠️ Potential issue | 🟠 Major

Rebase/filter changed file paths to the working directory before running Prettier.

Line 29/32 stores file paths as-is, while Line 98 executes from HOLDEX_WORKING_DIR. With subdirectory runs, root-relative paths become invalid and checks can fail incorrectly. Normalize to paths relative to the active working directory (and drop out-of-scope files).

Suggested fix in resolve step
     - name: Resolve changed files
       id: resolved-files
       shell: bash
       working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
       run: |
+        WORKDIR="${{ env.HOLDEX_WORKING_DIR || '.' }}"
         if [ -n "${{ inputs.changed-files }}" ]; then
-          echo "any-changed=true" >> "$GITHUB_OUTPUT"
-          echo "files=${{ inputs.changed-files }}" >> "$GITHUB_OUTPUT"
+          RAW_FILES="${{ inputs.changed-files }}"
         else
-          echo "any-changed=${{ steps.changed-files.outputs.any_changed }}" >> "$GITHUB_OUTPUT"
-          echo "files=${{ steps.changed-files.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT"
+          RAW_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
+        fi
+
+        normalized_files=()
+        for file in $RAW_FILES; do
+          if [ "$WORKDIR" = "." ]; then
+            normalized_files+=("$file")
+          elif [[ "$file" == "$WORKDIR/"* ]]; then
+            normalized_files+=("${file#"$WORKDIR"/}")
+          fi
+        done
+
+        if [ "${`#normalized_files`[@]}" -eq 0 ]; then
+          echo "any-changed=false" >> "$GITHUB_OUTPUT"
+          echo "files=" >> "$GITHUB_OUTPUT"
+        else
+          echo "any-changed=true" >> "$GITHUB_OUTPUT"
+          echo "files=${normalized_files[*]}" >> "$GITHUB_OUTPUT"
         fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/base/prettier/action.yml around lines 22 - 33, The resolve
step (id resolved-files) currently emits file paths unchanged into the outputs
(files and any-changed) which breaks when working from a subdirectory
(HOLDEX_WORKING_DIR); update the logic in that step to rebase and normalize each
path to be relative to ${HOLDEX_WORKING_DIR:-.} (or drop files that are outside
that directory) before writing "files=" and "any-changed=" to GITHUB_OUTPUT, and
ensure you still set any-changed=false when no in-scope files remain; reference
the resolved-files step and the outputs files/any-changed as the places to
change.
.github/actions/base/markdown-check/action.yml (1)

31-52: ⚠️ Potential issue | 🟠 Major

Normalize markdown file paths to the active working directory.

The resolved files output is not rebased, but Line 77 executes lint from HOLDEX_WORKING_DIR. In subdirectory mode, root-relative paths can break and produce false failures. Rebase/filter files before writing files=....

Suggested fix pattern
       run: |
+        WORKDIR="${{ env.HOLDEX_WORKING_DIR || '.' }}"
         if [ -z "${{ inputs.changed-files }}" ]; then
-          echo "any-changed=${{ steps.changed-markdown-files.outputs.any_changed }}" >> "$GITHUB_OUTPUT"
-          echo "files=${{ steps.changed-markdown-files.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT"
-          exit 0
+          RAW_FILES="${{ steps.changed-markdown-files.outputs.all_changed_files }}"
+        else
+          RAW_FILES="${{ inputs.changed-files }}"
         fi
 
         markdown_files=()
-        for file in ${{ inputs.changed-files }}; do
+        for file in $RAW_FILES; do
+          if [ "$WORKDIR" != "." ] && [[ "$file" == "$WORKDIR/"* ]]; then
+            file="${file#"$WORKDIR"/}"
+          elif [ "$WORKDIR" != "." ]; then
+            continue
+          fi
           case "$file" in
             *.md|*.mdx)
               markdown_files+=("$file")
               ;;
           esac
         done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/base/markdown-check/action.yml around lines 31 - 52, The
outputs written for "files" can be root-relative and break linting when the
action runs from HOLDEX_WORKING_DIR; normalize each entry before adding to
markdown_files and before echoing "files=" by rebasing paths to the action's
working directory (e.g., $GITHUB_WORKSPACE or $PWD). Update the loop that
processes inputs.changed-files to convert each matched file (in the
markdown_files array) to a rebased/relative path (strip leading slashes or use
realpath --relative-to="$PWD" "$file") and then write the normalized list to the
"files" output (keeping the any-changed logic intact).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/actions/composed/pr-checks/action.yml:
- Around line 29-33: Update the "Set working directory" step to validate the
chosen directory before exporting HOLDEX_WORKING_DIR: determine the directory
value from inputs.working-directory or env.HOLDEX_WORKING_DIR, test that it
exists (e.g., [ -d "$dir" ]), and if not print a clear error referencing the
invalid working-directory and exit 1; otherwise export it to $GITHUB_ENV as
before. Use the existing step name "Set working directory" and the variables
HOLDEX_WORKING_DIR and inputs.working-directory to locate where to add this
guard.

In `@ACTIONS.md`:
- Around line 131-137: The markdown lines describing HOLDEX_WORKING_DIR and
usage with pr-checks.yml / composed/pr-checks exceed the repo's MD013 line
length and must be wrapped; update the paragraph(s) that mention
HOLDEX_WORKING_DIR, pr-checks.yml, and composed/pr-checks so each line is within
the configured limit (break sentences or insert soft line breaks between
clauses), keeping wording unchanged except for line breaks to satisfy the
linter.

---

Outside diff comments:
In @.github/actions/base/markdown-check/action.yml:
- Around line 31-52: The outputs written for "files" can be root-relative and
break linting when the action runs from HOLDEX_WORKING_DIR; normalize each entry
before adding to markdown_files and before echoing "files=" by rebasing paths to
the action's working directory (e.g., $GITHUB_WORKSPACE or $PWD). Update the
loop that processes inputs.changed-files to convert each matched file (in the
markdown_files array) to a rebased/relative path (strip leading slashes or use
realpath --relative-to="$PWD" "$file") and then write the normalized list to the
"files" output (keeping the any-changed logic intact).

In @.github/actions/base/prettier/action.yml:
- Around line 22-33: The resolve step (id resolved-files) currently emits file
paths unchanged into the outputs (files and any-changed) which breaks when
working from a subdirectory (HOLDEX_WORKING_DIR); update the logic in that step
to rebase and normalize each path to be relative to ${HOLDEX_WORKING_DIR:-.} (or
drop files that are outside that directory) before writing "files=" and
"any-changed=" to GITHUB_OUTPUT, and ensure you still set any-changed=false when
no in-scope files remain; reference the resolved-files step and the outputs
files/any-changed as the places to change.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6070ef6f-0e8a-4d06-bee6-bced50a18af3

📥 Commits

Reviewing files that changed from the base of the PR and between 05eefbf and c339c43.

📒 Files selected for processing (7)
  • .github/actions/base/commit-check/action.yml
  • .github/actions/base/markdown-check/action.yml
  • .github/actions/base/prettier/action.yml
  • .github/actions/base/setup-runtime/action.yml
  • .github/actions/composed/pr-checks/action.yml
  • .github/workflows/pr-checks.yml
  • ACTIONS.md

Comment thread .github/actions/composed/pr-checks/action.yml
Comment thread ACTIONS.md Outdated
@georgeciubotaru georgeciubotaru merged commit 33c24e4 into main Apr 7, 2026
3 checks passed
@georgeciubotaru georgeciubotaru deleted the feat/support-working-dir branch April 7, 2026 09:28
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