Skip to content

Commit

Permalink
ci[pr-check-links]: dump links from baseline commit for pr link check…
Browse files Browse the repository at this point in the history
…ing (#180)

* ci[pr-check-links]: dump links from baseline commit for pr link checking

* ci[pr-check-links]: remove stash and clean up changes after check

* fix: update an invalid link

* feat: update note for pr-reject-png-jpg

* ci[pr-check-links]: add checks for modified and renamed anchors
  • Loading branch information
f-hollow authored Nov 5, 2024
1 parent 3510d38 commit 56d3737
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 19 deletions.
73 changes: 56 additions & 17 deletions .github/workflows/pr-check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Check out main branch
run: git checkout main
- 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 feature-baseline
# Reset the new branch to the base commit
git reset --hard ${{ env.base_commit }}
- name: Dump all links from main
id: dump_links_from_main
- name: Dump all links from feature-baseline
uses: lycheeverse/[email protected]
with:
args: |
Expand All @@ -28,25 +43,43 @@ jobs:
--exclude-path ./themes/
--exclude-path ./layouts/
.
output: ./links-main.txt

- name: Print links-main.txt in main
run: cat links-main.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: 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: Append links-main.txt to .lycheeignore
run: cat links-main.txt >> .lycheeignore
- 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: Check .lycheeignore content
- 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
Expand All @@ -67,3 +100,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
3 changes: 2 additions & 1 deletion .github/workflows/pr-reject-png-jpg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56d3737

Please sign in to comment.