Skip to content

🔧 For monorepo use both frontend and backend labels#17

Merged
rickyheijnen merged 1 commit into
mainfrom
feat/set-labels-for-monorepo
Aug 13, 2025
Merged

🔧 For monorepo use both frontend and backend labels#17
rickyheijnen merged 1 commit into
mainfrom
feat/set-labels-for-monorepo

Conversation

@rickyheijnen

Copy link
Copy Markdown
Member

🔍 Samenvatting

Deze PR voegt label configuratie toe voor monorepo's waardoor meer bruikbare labels worden toegevoegd aan de repository

📝 Beschrijving

  • Als de codebase_type van een repository is ingesteld op monorepo, dan moeten zowel general.yaml, frontend.yaml en backend.yaml ingeladen worden

✅ Checklist

  • Code is lokaal getest
  • Tests zijn toegevoegd/aangepast
  • Documentatie bijgewerkt (indien nodig)

@rickyheijnen rickyheijnen self-assigned this Aug 13, 2025
@coderabbitai

coderabbitai Bot commented Aug 13, 2025

Copy link
Copy Markdown

Walkthrough

Adds monorepo handling to .github/workflows/label-sync.yml by appending labels/frontend.yml and labels/backend.yml to CONFIG_FILES when REPO_TYPE is "monorepo", in addition to labels/general.yml.

Changes

Cohort / File(s) Change summary
Label sync workflow
.github/workflows/label-sync.yml
Introduces a "monorepo" REPO_TYPE case that appends frontend.yml and backend.yml to CONFIG_FILES alongside general.yml for label-sync processing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Possibly related PRs

Suggested labels

type: ci

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/set-labels-for-monorepo

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rickyheijnen rickyheijnen added the type: 🔧 maintenance General maintenance and codebase health label Aug 13, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (2)
.github/workflows/label-sync.yml (2)

10-11: Self-hosted runner portability: pin OS label or force bash shell

The script relies on bash features ($'\n'). On self-hosted Windows runners, default shell is PowerShell and this will break. Either:

  • Add an OS label to ensure Linux (recommended), or
  • Force shell: bash on the run steps.

Add either of the following:

Option A (runner labels):

runs-on: [self-hosted, Linux]

Option B (force bash per step):

- name: Determine repository type from custom properties
  id: determine-type
  shell: bash
  run: |
    ...
- name: Determine config files
  id: config
  shell: bash
  run: |
    ...

1-9: Missing permissions block may prevent label updates

EndBug/label-sync needs write access to labels (issues scope). With GitHub’s default read-only GITHUB_TOKEN permissions, the action can fail to update labels, especially on PR events. Declare explicit permissions.

Add this at the workflow top level (sibling of “on”):

permissions:
  contents: read
  issues: write
🧹 Nitpick comments (2)
.github/workflows/label-sync.yml (2)

34-57: Normalize repo type to lowercase to make matching resilient

If the custom property comes in with different casing (e.g., Monorepo, MONOREPO), the case statement won’t match.

Add normalization after reading REPO_TYPE:

- name: Determine config files
  id: config
  shell: bash
  run: |
    BASE_URL="https://raw.githubusercontent.com/brixion/.github/main/labels"
    REPO_TYPE="${{ steps.determine-type.outputs.repo_type }}"
    REPO_TYPE="$(echo "$REPO_TYPE" | tr '[:upper:]' '[:lower:]')"
    # Always include general labels
    CONFIG_FILES="$BASE_URL/general.yml"
    case "$REPO_TYPE" in
      frontend)  CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/frontend.yml" ;;
      backend)   CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/backend.yml" ;;
      monorepo)  CONFIG_FILES="$CONFIG_FILES"$'\n'"$BASE_URL/frontend.yml"$'\n'"$BASE_URL/backend.yml" ;;
      general)   : ;; # no-op; keep only general
      *)         echo "Unknown repo type '$REPO_TYPE', using only general labels" ;;
    esac
    ...

55-56: Avoid confusing log when repo type is 'general'

If codebase_type is literally "general", this falls into the default case and logs “Unknown repo type 'general'...”.

Consider adding an explicit general) case (no-op) to keep logs clean (see previous suggestion’s snippet).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 768ef86 and 72ec8f2.

📒 Files selected for processing (1)
  • .github/workflows/label-sync.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/label-sync.yml (2)

51-53: Monorepo handling: logic is correct; verify label precedence and merge order

Newline-separated config URLs are supported by EndBug/label-sync. Please double-check that the intended precedence is frontend then backend (i.e., backend definitions overriding duplicates from frontend due to later position). If the opposite is desired, swap their order.


12-33: Dependency on gh CLI on self-hosted runner

This step requires gh to be installed/configured on the runner. On self-hosted machines that’s not guaranteed.

If gh is not guaranteed, replace with curl (jq optional but convenient):

- name: Determine repository type from custom properties
  id: determine-type
  shell: bash
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    echo "Fetching repo type from custom properties..."
    RESP=$(curl -sSf -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer ${GITHUB_TOKEN}" \
      -H "X-GitHub-Api-Version: 2022-11-28" \
      "https://api.github.com/repos/${{ github.repository }}/properties/values")

    REPO_TYPE=$(printf '%s' "$RESP" | jq -r '.[] | select(.property_name=="codebase_type") | .value // empty')

    if [ -z "$REPO_TYPE" ] || [ "$REPO_TYPE" = "null" ]; then
      echo "No custom property 'codebase_type' found. Exiting workflow."
      exit 1
    fi

    echo "Found custom property codebase_type: $REPO_TYPE"
    echo "repo_type=$REPO_TYPE" >> "$GITHUB_OUTPUT"

@rickyheijnen
rickyheijnen merged commit 2398856 into main Aug 13, 2025
2 of 3 checks passed
@rickyheijnen
rickyheijnen deleted the feat/set-labels-for-monorepo branch August 13, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: 🔧 maintenance General maintenance and codebase health

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants