Skip to content

Commit 56d3737

Browse files
authored
ci[pr-check-links]: dump links from baseline commit for pr link checking (#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
1 parent 3510d38 commit 56d3737

File tree

3 files changed

+59
-19
lines changed

3 files changed

+59
-19
lines changed

.github/workflows/pr-check-links.yml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@ jobs:
1515
ref: ${{ github.event.pull_request.head.ref }}
1616
repository: ${{ github.event.pull_request.head.repo.full_name }}
1717

18-
- name: Check out main branch
19-
run: git checkout main
18+
- name: Set environment variables
19+
id: set-env
20+
run: |
21+
# Extract the base commit ID where the feature branch diverged from main
22+
base_commit=$(git merge-base origin/main ${{ github.event.pull_request.head.ref }})
23+
echo "base_commit=$base_commit" >> $GITHUB_ENV
24+
25+
# Extract the head commit ID on the feature branch
26+
head_commit=${{ github.event.pull_request.head.sha }}
27+
echo "head_commit=$head_commit" >> $GITHUB_ENV
28+
29+
- name: Create baseline branch by reverting feature branch changes
30+
run: |
31+
# Create a copy of the feature branch
32+
git checkout -b feature-baseline
33+
34+
# Reset the new branch to the base commit
35+
git reset --hard ${{ env.base_commit }}
2036
21-
- name: Dump all links from main
22-
id: dump_links_from_main
37+
- name: Dump all links from feature-baseline
2338
uses: lycheeverse/[email protected]
2439
with:
2540
args: |
@@ -28,25 +43,43 @@ jobs:
2843
--exclude-path ./themes/
2944
--exclude-path ./layouts/
3045
.
31-
output: ./links-main.txt
32-
33-
- name: Print links-main.txt in main
34-
run: cat links-main.txt
35-
36-
- name: Stash untracked files
37-
run: git stash push --include-untracked
46+
output: links-baseline.txt
3847

3948
- name: Check out feature branch
4049
run: git checkout ${{ github.head_ref }}
4150

42-
- name: Apply stashed changes
43-
# Apply stashed changes, ignore errors if stash is empty
44-
run: git stash pop || true
51+
- name: Append links-baseline.txt to .lycheeignore
52+
run: cat links-baseline.txt >> .lycheeignore
53+
54+
- name: Print .lycheeignore
55+
run: cat .lycheeignore
56+
57+
- name: Dump names of files altered in PR and append hash sign to find links with anchors
58+
run: |
59+
git diff --name-only --diff-filter=DM ${{ env.base_commit }} ${{ env.head_commit }} > altered-files.txt
60+
sed -i 's|$|#|' altered-files.txt
61+
git diff --name-status --diff-filter=R ${{ env.base_commit }} ${{ env.head_commit }} | awk '{print $2}' > renamed-files.txt
62+
sed -i 's|$|#|' renamed-files.txt
63+
64+
- name: Print altered-files.txt
65+
run: cat altered-files.txt
4566

46-
- name: Append links-main.txt to .lycheeignore
47-
run: cat links-main.txt >> .lycheeignore
67+
- name: Print renamed-files.txt
68+
run: cat renamed-files.txt
69+
70+
- name: In .lycheeignore, remove links with anchors referring to altered files
71+
run: |
72+
while IFS= read -r line; do
73+
sed -i "\|$line|d" .lycheeignore
74+
done < altered-files.txt
4875
49-
- name: Check .lycheeignore content
76+
- name: In .lycheeignore, remove links with anchors referring to renamed files
77+
run: |
78+
while IFS= read -r line; do
79+
sed -i "\|$line|d" .lycheeignore
80+
done < renamed-files.txt
81+
82+
- name: Print .lycheeignore with unaffected links
5083
run: cat .lycheeignore
5184

5285
- name: Check links
@@ -67,3 +100,9 @@ jobs:
67100
echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc.,"
68101
echo -e "consider adding such links to the .lycheeignore file to bypass future checks.\n"
69102
exit 1
103+
104+
- name: Clean up all changes
105+
if: always()
106+
run: |
107+
git reset --hard HEAD
108+
git clean -df

.github/workflows/pr-reject-png-jpg.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
if [ -n "$IMAGE_FILES" ]; then
2222
echo "Rejecting merge. PR contains the following JPEG or PNG files:"
2323
echo "$IMAGE_FILES"
24-
echo "Please convert these files to WebP format."
24+
echo "Please convert these files to WebP format. For details, see"
25+
echo "https://developer.espressif.com/pages/contribution-guide/writing-content/#use-webp-for-raster-images."
2526
exit 1
2627
2728
else

content/blog/making-the-fancy-user-interface-on-esp-has-never-been-easier/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SquareLine studio version 1.1 introduce new feature — __board templates__ . Th
3535

3636
## ESP Boards in SquareLine Studio
3737

38-
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.
38+
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.
3939

4040
{{< figure
4141
default=true

0 commit comments

Comments
 (0)