Skip to content

Create Link Validator workflow#81

Merged
Adammatthiesen merged 6 commits into
mainfrom
link-validator-workflow
Apr 17, 2025
Merged

Create Link Validator workflow#81
Adammatthiesen merged 6 commits into
mainfrom
link-validator-workflow

Conversation

@Adammatthiesen
Copy link
Copy Markdown
Member

@Adammatthiesen Adammatthiesen commented Apr 17, 2025

Description

  • Closes #
  • What does this PR change? Give us a brief description.

Summary by CodeRabbit

  • Chores
    • Introduced automated link validation during pull request workflows to ensure all links are checked before merging.
    • Updated internal configuration to enable or disable link validation based on environment settings, improving workflow flexibility.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2025

Walkthrough

A new GitHub Actions workflow for link validation has been added, which runs on pull requests targeting the main branch. The Astro configuration was updated to conditionally include the starlightLinksValidator plugin only when a specific environment variable is set. Additionally, the TypeDoc configuration now disables production mode during link checking by adjusting environment variable handling. No changes were made to exported or public entity declarations; all modifications are internal to configuration and automation.

Changes

File(s) Change Summary
.github/workflows/ci-link-validator.yml Added a GitHub Actions workflow to automate link validation on pull requests targeting the main branch.
astro.config.mts Made the inclusion of the starlightLinksValidator plugin conditional based on the CHECK_LINKS env variable.
typedoc.config.ts Updated environment variable logic to disable production mode during link checking runs.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant CI Workflow
    participant Astro Config
    participant TypeDoc Config

    Developer->>GitHub Actions: Open PR to main branch
    GitHub Actions->>CI Workflow: Trigger "CI - Link Validator"
    CI Workflow->>Astro Config: Set CHECK_LINKS=true
    CI Workflow->>TypeDoc Config: Set CHECK_LINKS=true
    Astro Config->>Astro Config: Conditionally include starlightLinksValidator
    TypeDoc Config->>TypeDoc Config: Disable production mode if CHECK_LINKS is set
    CI Workflow->>CI Workflow: Run link validation steps
Loading

Possibly related PRs

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@Adammatthiesen Adammatthiesen marked this pull request as ready for review April 17, 2025 05:14
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner April 17, 2025 05:14
Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (6)
typedoc.config.ts (2)

62-62: Consider simplifying the condition.

The condition isLinkCheck === false could be simplified to !isLinkCheck for better readability.

-const isProd = isLinkCheck === false && process.env.NODE_ENV === 'production';
+const isProd = !isLinkCheck && process.env.NODE_ENV === 'production';

60-62: Add a comment explaining the link checking logic.

It would be helpful to add a comment explaining why TypeDoc plugins should be disabled during link checking.

+// When CHECK_LINKS is set, we disable TypeDoc plugins (isProd becomes false)
+// to improve performance and prevent link validation errors in generated docs
 const isLinkCheck = !!process.env.CHECK_LINKS;

 const isProd = isLinkCheck === false && process.env.NODE_ENV === 'production';
.github/workflows/ci-link-validator.yml (3)

17-17: Pin action version with a comment.

While using a hash-pinned version of actions/checkout is good for security, it would be helpful to add a comment indicating which version this hash corresponds to.

-        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
+        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.1

18-18: Remove trailing whitespace.

There's unnecessary trailing whitespace on this line.

-  
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 18-18: trailing spaces

(trailing-spaces)


22-23: Consider adding output handling for link check results.

The workflow would benefit from explaining how link validation results are processed and reported.

 - name: Run Link Check
   run: pnpm ci:build
+  # Link validation errors will cause the build to fail automatically
astro.config.mts (1)

19-23: Add a comment explaining TypeDoc exclusion.

It would be helpful to explain why TypeDoc paths are excluded from link checking.

 starlightLinksValidator({
 	errorOnFallbackPages: false,
 	errorOnInconsistentLocale: true,
+	// Exclude TypeDoc paths as they contain auto-generated content with many internal links
 	exclude: ['/*/typedoc/**/*'],
 }),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a41ad1c and d289615.

📒 Files selected for processing (3)
  • .github/workflows/ci-link-validator.yml (1 hunks)
  • astro.config.mts (3 hunks)
  • typedoc.config.ts (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/ci-link-validator.yml

[error] 18-18: trailing spaces

(trailing-spaces)

🔇 Additional comments (5)
typedoc.config.ts (1)

60-61: Good addition for conditional link checking.

The addition of the isLinkCheck variable provides a clean way to detect when link validation is happening.

.github/workflows/ci-link-validator.yml (1)

1-24: Good implementation of the link validator workflow.

The workflow is properly set up to run on PRs to the main branch and correctly sets the CHECK_LINKS environment variable.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 18-18: trailing spaces

(trailing-spaces)

astro.config.mts (3)

5-5: Good import addition.

The import for starlightLinksValidator is correctly added.


17-25: Good implementation of conditional link validation.

The conditional inclusion of the link validator plugin is well-structured, making it only active when the CHECK_LINKS environment variable is set.


147-147: Correctly integrated the conditional link validator.

The spread operator is properly used to conditionally include the link validator in the plugins array.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2025
Copy link
Copy Markdown
Contributor

@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: 1

🧹 Nitpick comments (3)
.github/workflows/ci-link-validator.yml (3)

3-7: Consider expanding triggers
Currently, link validation only runs on pull requests targeting main. If you also want to catch broken links on direct pushes or merges (e.g., fast‐forwards to main), consider adding a push event or a workflow_run trigger to cover those cases.


12-14: Ensure Node setup & caching for performance
This workflow relies on your custom install action to provision Node and dependencies, but it may benefit from an explicit actions/setup-node step (to lock down the Node version) and caching of the PNPM store or node_modules to speed up subsequent runs.


17-18: Remove trailing spaces and standardize checkout pinning
Line 18 has trailing whitespace (YAMLlint error). Also, instead of a raw commit SHA, you could reference actions/checkout@v4 for clarity and maintainability.

Apply this diff:

-      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4  
+      uses: actions/checkout@v4
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 18-18: trailing spaces

(trailing-spaces)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d289615 and 809e48f.

📒 Files selected for processing (3)
  • .github/workflows/ci-link-validator.yml (1 hunks)
  • astro.config.mts (3 hunks)
  • typedoc.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • astro.config.mts
  • typedoc.config.ts
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/ci-link-validator.yml

[error] 18-18: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/ci-link-validator.yml (2)

8-11: Descriptive job configuration
The job name (Run Starlight Link Check) and runs-on: ubuntu-latest are clear and appropriate. No issues here.


22-23: Verify build command invokes link checker
This step runs pnpm ci:build, which should respect CHECK_LINKS=true to activate your link‐validation plugin. Please confirm that ci:build actually performs link validation (and not just a standard production build). If you only need link checking here, consider a dedicated script like pnpm link:check.

Comment thread .github/workflows/ci-link-validator.yml
Copy link
Copy Markdown
Contributor

@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: 1

♻️ Duplicate comments (1)
.github/workflows/ci-link-validator.yml (1)

19-19: Pin the install action for reproducibility
Using …/install@main may introduce breaking changes if the action’s default branch is updated. Pin to a released tag or specific commit SHA (e.g., @v1.2.3 or a known SHA).

🧹 Nitpick comments (3)
.github/workflows/ci-link-validator.yml (3)

15-15: Use a stable checkout action version
Pinning to a named tag (e.g., actions/checkout@v4) is clearer and easier to update than a raw commit SHA:

-      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
+      - uses: actions/checkout@v4

16-16: Remove trailing whitespace
YAMLLint reports a trailing space here. Please remove any extraneous spaces to satisfy linting.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 16-16: trailing spaces

(trailing-spaces)


20-22: Optimize dependency installation and caching
Consider adding a cache step to speed up pnpm installs between runs and reduce network usage. For example:

      - name: Cache pnpm store
        uses: actions/cache@v3
        with:
          path: ~/.pnpm-store
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
      - name: Install dependencies
        run: pnpm install --frozen-lockfile

Also verify that pnpm ci:build indeed invokes the link checker (pnpm run ci:build).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 809e48f and d4a6632.

📒 Files selected for processing (1)
  • .github/workflows/ci-link-validator.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/ci-link-validator.yml

[error] 16-16: trailing spaces

(trailing-spaces)

🔇 Additional comments (1)
.github/workflows/ci-link-validator.yml (1)

1-2: Workflow name is descriptive
The name: CI - Link Validator clearly communicates the purpose of this workflow.

Comment thread .github/workflows/ci-link-validator.yml
@Adammatthiesen Adammatthiesen merged commit 69ca7ea into main Apr 17, 2025
8 checks passed
@Adammatthiesen Adammatthiesen deleted the link-validator-workflow branch April 17, 2025 06:19
@coderabbitai coderabbitai Bot mentioned this pull request May 10, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants