From b58c4c9577d203081018d7b3711179fdea97d5c0 Mon Sep 17 00:00:00 2001 From: Esha Noronha Date: Mon, 1 Sep 2025 09:47:31 +0200 Subject: [PATCH] updated config files --- .github/lychee.toml | 5 +- .github/workflows/check-pr-links.yml | 76 ++++++---------------------- 2 files changed, 16 insertions(+), 65 deletions(-) diff --git a/.github/lychee.toml b/.github/lychee.toml index 37c5817e35f..976d16ee418 100644 --- a/.github/lychee.toml +++ b/.github/lychee.toml @@ -11,10 +11,7 @@ no_progress = false ############################# Cache ############################### # Enable link caching. This can be helpful to avoid checking the same links on # multiple runs. -cache = true - -# Discard all cached requests older than this duration. -max_cache_age = "1d" +cache = false ############################# Runtime ############################# # Maximum number of concurrent link checks. diff --git a/.github/workflows/check-pr-links.yml b/.github/workflows/check-pr-links.yml index 80c117e1b5e..ce7d91a6ff1 100644 --- a/.github/workflows/check-pr-links.yml +++ b/.github/workflows/check-pr-links.yml @@ -5,23 +5,18 @@ on: branches: - main paths: - - '**/*.md' # Only trigger workflow if any Markdown files change + - '**/*.md' jobs: check-links: runs-on: ubuntu-latest steps: - # Step 1: Checkout the repository - - name: Checkout GitHub repo - uses: actions/checkout@v4 + # Checkout repo + - uses: actions/checkout@v4 with: fetch-depth: 0 - # Step 2: Check out base branch - - name: Check out base branch - run: git checkout ${{ github.event.pull_request.base.ref }} - - # Step 3: Get changed Markdown files + # Find changed Markdown files - name: Get changed Markdown files id: changed-files run: | @@ -30,39 +25,14 @@ jobs: echo "Changed Markdown files:" echo "$files" - # Step 4: Skip workflow if no Markdown files changed + # Skip if no Markdown files - name: Skip if no Markdown files changed if: ${{ env.changed_files == '' }} run: | - echo "No Markdown files changed in this PR. Skipping link check." + echo "No Markdown files changed. Skipping link check." exit 0 - # Step 5: Dump base branch links for changed files only (no fragments) - - name: Dump base branch links - uses: lycheeverse/lychee-action@v2 - with: - args: "--dump ${{ env.changed_files }}" - output: ./existing-links.txt - continue-on-error: true - - # Step 6: Stash untracked files and switch back to feature branch - - name: Stash untracked files - run: git stash push --include-untracked - - - name: Check out feature branch - run: git checkout ${{ github.head_ref }} - - - name: Apply stashed changes - run: git stash pop || true - - # Step 7: Add base branch links to .lycheeignore - - name: Update ignore file - run: | - if [ -f "existing-links.txt" ]; then - cat existing-links.txt >> .lycheeignore - fi - - # Step 8: Run Lychee on changed files one by one and extract broken links + # Run Lychee - name: Run Lychee link checker id: lychee continue-on-error: true @@ -73,33 +43,17 @@ jobs: lychee --no-progress --include-fragments "$f" >> lychee-full-report.txt || true done - # Extract only broken links - if [ -f lychee-full-report.txt ]; then - grep -E "❌|ERROR" lychee-full-report.txt > lychee-broken.txt || true + # Extract only broken links for log + if grep -qE "❌|ERROR" lychee-full-report.txt; then + echo "❌ Broken links found:" + grep -E "❌|ERROR" lychee-full-report.txt else - echo "No report generated." > lychee-broken.txt + echo "✅ No broken links found." fi - echo "full_report=lychee-full-report.txt" >> $GITHUB_ENV - echo "broken_report=lychee-broken.txt" >> $GITHUB_ENV - - # Step 9: Upload full report for debugging (optional) - - name: Upload full Lychee report + # Upload full report as artifact + - name: Upload Lychee full report uses: actions/upload-artifact@v4 with: name: lychee-full-report - path: ${{ env.full_report }} - - # Step 10: Post PR comment with only broken links - - name: Comment broken links on PR - if: always() - uses: marocchino/sticky-pull-request-comment@v2 - with: - path: ${{ env.broken_report }} - - # Step 11: Fail if broken links exist - - name: Fail on broken links - if: steps.lychee.outcome == 'failure' - run: | - echo "::error::Broken links detected. See the PR comment above for details." - exit 1 + path: lychee-full-report.txt