From b49e255f7a2b8a33dc68b2d3ff5ec26e77c63a5b Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Thu, 31 Oct 2024 19:28:57 +0800 Subject: [PATCH 1/5] ci[pr-check-links]: dump links from baseline commit for pr link checking --- .github/workflows/pr-check-links.yml | 32 +++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr-check-links.yml b/.github/workflows/pr-check-links.yml index d178e0058..0fbbbe623 100644 --- a/.github/workflows/pr-check-links.yml +++ b/.github/workflows/pr-check-links.yml @@ -11,15 +11,27 @@ jobs: - name: Clone repository uses: actions/checkout@v4 with: - fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 0 + + - name: Fetch all branches + run: git fetch --all + + - name: Create baseline branch by reverting feature branch changes + run: | + # Create a copy of the feature branch + git checkout -b baseline-copy + + # git checkout ${{ github.event.pull_request.head.sha }} + + # Find the base commit where the feature branch diverged from main + base_commit=$(git merge-base origin/main baseline-copy) - - name: Check out main branch - run: git checkout main + # Reset the new branch to the base commit + git reset --hard $base_commit - - name: Dump all links from main - id: dump_links_from_main + - name: Dump all links from baseline-copy uses: lycheeverse/lychee-action@v2.0.2 with: args: | @@ -28,10 +40,10 @@ jobs: --exclude-path ./themes/ --exclude-path ./layouts/ . - output: ./links-main.txt + output: ./links-baseline.txt - - name: Print links-main.txt in main - run: cat links-main.txt + - name: Print links-baseline.txt + run: cat links-baseline.txt - name: Stash untracked files run: git stash push --include-untracked @@ -43,8 +55,8 @@ jobs: # Apply stashed changes, ignore errors if stash is empty run: git stash pop || true - - name: Append links-main.txt to .lycheeignore - run: cat links-main.txt >> .lycheeignore + - name: Append links-baseline.txt to .lycheeignore + run: cat links-baseline.txt >> .lycheeignore - name: Check .lycheeignore content run: cat .lycheeignore From c3b79cf9137d9b01406231c931b286bbbadbb8ee Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Fri, 1 Nov 2024 15:00:37 +0800 Subject: [PATCH 2/5] ci[pr-check-links]: remove stash and clean up changes after check --- .github/workflows/pr-check-links.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr-check-links.yml b/.github/workflows/pr-check-links.yml index 0fbbbe623..c2713550a 100644 --- a/.github/workflows/pr-check-links.yml +++ b/.github/workflows/pr-check-links.yml @@ -15,16 +15,11 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 - - name: Fetch all branches - run: git fetch --all - - name: Create baseline branch by reverting feature branch changes run: | # Create a copy of the feature branch git checkout -b baseline-copy - # git checkout ${{ github.event.pull_request.head.sha }} - # Find the base commit where the feature branch diverged from main base_commit=$(git merge-base origin/main baseline-copy) @@ -40,25 +35,15 @@ jobs: --exclude-path ./themes/ --exclude-path ./layouts/ . - output: ./links-baseline.txt - - - name: Print links-baseline.txt - run: cat links-baseline.txt - - - name: Stash untracked files - run: git stash push --include-untracked + output: links-baseline.txt - name: Check out feature branch run: git checkout ${{ github.head_ref }} - - name: Apply stashed changes - # Apply stashed changes, ignore errors if stash is empty - run: git stash pop || true - - name: Append links-baseline.txt to .lycheeignore run: cat links-baseline.txt >> .lycheeignore - - name: Check .lycheeignore content + - name: Print .lycheeignore run: cat .lycheeignore - name: Check links @@ -79,3 +64,9 @@ jobs: echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc.," echo -e "consider adding such links to the .lycheeignore file to bypass future checks.\n" exit 1 + + - name: Clean up all changes + if: always() + run: | + git reset --hard HEAD + git clean -df From 917e7e24ea6fc02a0bc6f9327e18e4be4fa5b85c Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Fri, 1 Nov 2024 15:01:41 +0800 Subject: [PATCH 3/5] fix: update an invalid link --- .../index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/blog/making-the-fancy-user-interface-on-esp-has-never-been-easier/index.md b/content/blog/making-the-fancy-user-interface-on-esp-has-never-been-easier/index.md index 439bc217e..3071f07fa 100644 --- a/content/blog/making-the-fancy-user-interface-on-esp-has-never-been-easier/index.md +++ b/content/blog/making-the-fancy-user-interface-on-esp-has-never-been-easier/index.md @@ -35,7 +35,7 @@ SquareLine studio version 1.1 introduce new feature — __board templates__ . Th ## ESP Boards in SquareLine Studio -Espressif has prepared two boards in SquareLine Studio for you: [__ESP-BOX__ ](hhttps://github.com/espressif/esp-bsp/tree/master/bsp/esp-box) and [__ESP-WROVER-KIT__ ](https://github.com/espressif/esp-bsp/tree/master/bsp/esp_wrover_kit). You can select the board after launch the application in Create tab and then in Espressif tab (Figure 2). Each board has pre-filled size of screen, rotation and color depth, which is corresponding with [ESP-BSP](https://github.com/espressif/esp-bsp) which is used in generated code. +Espressif has prepared two boards in SquareLine Studio for you: [__ESP-BOX__ ](https://github.com/espressif/esp-bsp/tree/master/bsp/esp-box) and [__ESP-WROVER-KIT__ ](https://github.com/espressif/esp-bsp/tree/master/bsp/esp_wrover_kit). You can select the board after launch the application in Create tab and then in Espressif tab (Figure 2). Each board has pre-filled size of screen, rotation and color depth, which is corresponding with [ESP-BSP](https://github.com/espressif/esp-bsp) which is used in generated code. {{< figure default=true From 099525d1c206911814b0e4539b415b4aaa370bcf Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Fri, 1 Nov 2024 17:50:39 +0800 Subject: [PATCH 4/5] feat: update note for pr-reject-png-jpg --- .github/workflows/pr-reject-png-jpg.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-reject-png-jpg.yml b/.github/workflows/pr-reject-png-jpg.yml index b971a8396..aa60035d3 100644 --- a/.github/workflows/pr-reject-png-jpg.yml +++ b/.github/workflows/pr-reject-png-jpg.yml @@ -21,7 +21,8 @@ jobs: if [ -n "$IMAGE_FILES" ]; then echo "Rejecting merge. PR contains the following JPEG or PNG files:" echo "$IMAGE_FILES" - echo "Please convert these files to WebP format." + echo "Please convert these files to WebP format. For details, see" + echo "https://developer.espressif.com/pages/contribution-guide/writing-content/#use-webp-for-raster-images." exit 1 else From d70afda972d3529e51f5766cf24e13c12b2acc91 Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Mon, 4 Nov 2024 17:56:51 +0800 Subject: [PATCH 5/5] ci[pr-check-links]: add checks for modified and renamed anchors --- .github/workflows/pr-check-links.yml | 50 ++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-check-links.yml b/.github/workflows/pr-check-links.yml index c2713550a..5f6c99cb4 100644 --- a/.github/workflows/pr-check-links.yml +++ b/.github/workflows/pr-check-links.yml @@ -11,22 +11,30 @@ jobs: - name: Clone repository uses: actions/checkout@v4 with: + fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} - fetch-depth: 0 + + - name: Set environment variables + id: set-env + run: | + # Extract the base commit ID where the feature branch diverged from main + base_commit=$(git merge-base origin/main ${{ github.event.pull_request.head.ref }}) + echo "base_commit=$base_commit" >> $GITHUB_ENV + + # Extract the head commit ID on the feature branch + head_commit=${{ github.event.pull_request.head.sha }} + echo "head_commit=$head_commit" >> $GITHUB_ENV - name: Create baseline branch by reverting feature branch changes run: | # Create a copy of the feature branch - git checkout -b baseline-copy - - # Find the base commit where the feature branch diverged from main - base_commit=$(git merge-base origin/main baseline-copy) + git checkout -b feature-baseline # Reset the new branch to the base commit - git reset --hard $base_commit + git reset --hard ${{ env.base_commit }} - - name: Dump all links from baseline-copy + - name: Dump all links from feature-baseline uses: lycheeverse/lychee-action@v2.0.2 with: args: | @@ -46,6 +54,34 @@ jobs: - name: Print .lycheeignore run: cat .lycheeignore + - name: Dump names of files altered in PR and append hash sign to find links with anchors + run: | + git diff --name-only --diff-filter=DM ${{ env.base_commit }} ${{ env.head_commit }} > altered-files.txt + sed -i 's|$|#|' altered-files.txt + git diff --name-status --diff-filter=R ${{ env.base_commit }} ${{ env.head_commit }} | awk '{print $2}' > renamed-files.txt + sed -i 's|$|#|' renamed-files.txt + + - name: Print altered-files.txt + run: cat altered-files.txt + + - name: Print renamed-files.txt + run: cat renamed-files.txt + + - name: In .lycheeignore, remove links with anchors referring to altered files + run: | + while IFS= read -r line; do + sed -i "\|$line|d" .lycheeignore + done < altered-files.txt + + - name: In .lycheeignore, remove links with anchors referring to renamed files + run: | + while IFS= read -r line; do + sed -i "\|$line|d" .lycheeignore + done < renamed-files.txt + + - name: Print .lycheeignore with unaffected links + run: cat .lycheeignore + - name: Check links uses: lycheeverse/lychee-action@v2.0.2 with: