Skip to content

Commit dcde457

Browse files
committed
Draft for checking URLs
1 parent 15f69ce commit dcde457

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ jobs:
2929
- uses: actions/checkout@v1
3030
- uses: 'ros-industrial/industrial_ci@master'
3131
env: ${{matrix.env}}
32+
33+
34+
check_urls:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v1
38+
- name: check URLs
39+
run: |
40+
echo "$(pwd)"
41+
ls -l
42+
ur_robot_driver/scripts/check_urls.sh -r ur_robot_driver/src/ur
43+
#working-directory: ./ur_robot_driver
44+

ur_robot_driver/scripts/check_urls.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
#Find URLs in code:
6+
urls=$(grep -oP "(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))([a-zA-Z0-9_.,@?^=%&:\/~+#-]*[a-zA-Z0-9_@?^=%&\/~+#-])?" "$@")
7+
8+
fail_counter=0
9+
10+
for item in $urls; do
11+
# echo $item
12+
filename=$(echo "$item" | cut -d':' -f1)
13+
url=$(echo "$item" | cut -d':' -f2-)
14+
# echo "Checking $url from file $filename"
15+
if ! curl --head --silent --fail "$url" 2>&1 > /dev/null; then
16+
echo "Invalid link in file $filename: $url"
17+
((fail_counter=fail_counter+1))
18+
else
19+
echo "$url ok"
20+
fi
21+
done
22+
23+
exit $fail_counter

0 commit comments

Comments
 (0)