Skip to content

Commit b388504

Browse files
authored
Update Caddy and Muffet (#23)
1 parent 686dd7b commit b388504

6 files changed

Lines changed: 50 additions & 31 deletions

File tree

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.11
1+
FROM alpine:3.12
22

33
LABEL maintainer="Petr Ruzicka <petr.ruzicka@gmail.com>"
44
LABEL repository="https://github.com/ruzickap/action-my-broken-link-checker"
@@ -9,10 +9,10 @@ LABEL "com.github.actions.description"="Check broken links on web pages stored l
99
LABEL "com.github.actions.icon"="list"
1010
LABEL "com.github.actions.color"="blue"
1111

12-
ENV MUFFET_VERSION="1.3.3"
12+
ENV MUFFET_VERSION="2.0.4"
1313
#ENV MUFFET_VERSION="latest"
1414

15-
ENV CADDY_VERSION="2.1.1"
15+
ENV CADDY_VERSION="2.2.0"
1616
#ENV CADDY_VERSION="latest"
1717

1818
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
@@ -28,7 +28,7 @@ RUN set -eux && \
2828
if [ "${MUFFET_VERSION}" = "latest" ]; then \
2929
MUFFET_URL=$(wget -qO- https://api.github.com/repos/raviqqe/muffet/releases/latest | grep "browser_download_url.*muffet_.*_Linux_x86_64.tar.gz" | cut -d \" -f 4) ; \
3030
else \
31-
MUFFET_URL="https://github.com/raviqqe/muffet/releases/download/${MUFFET_VERSION}/muffet_${MUFFET_VERSION}_Linux_x86_64.tar.gz" ; \
31+
MUFFET_URL="https://github.com/raviqqe/muffet/releases/download/v${MUFFET_VERSION}/muffet_${MUFFET_VERSION}_Linux_x86_64.tar.gz" ; \
3232
fi && \
3333
wget -qO- "${MUFFET_URL}" | tar xzf - -C /usr/local/bin/ muffet && \
3434
if [ "${CADDY_VERSION}" = "latest" ]; then \

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ parameter and serving the web pages (see the details in [entrypoint.sh](./entryp
4747
with:
4848
url: https://www.example.com/test123
4949
pages_path: ./build/
50-
cmd_params: --buffer-size=8192 --concurrency=10 --skip-tls-verification --limit-redirections=5 --timeout=20 # muffet parameters
50+
cmd_params: --buffer-size=8192 --max-connections=10 --skip-tls-verification --limit-redirections=5 --timeout=20 # muffet parameters
5151
run_timeout: 600 # maximum amount of time to run muffet (default is set to 300 seconds)
5252
```
5353

@@ -58,21 +58,21 @@ Do you want to skip the docker build step? OK, the script mode is also available
5858
env:
5959
INPUT_URL: https://www.example.com/test123
6060
INPUT_PAGES_PATH: ./build/
61-
INPUT_CMD_PARAMS: --buffer-size=8192 --concurrency=10 --skip-tls-verification # --skip-tls-verification is mandatory parameter when using https and "PAGES_PATH"
61+
INPUT_CMD_PARAMS: --buffer-size=8192 --max-connections=10 --skip-tls-verification # --skip-tls-verification is mandatory parameter when using https and "PAGES_PATH"
6262
run: wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v1/entrypoint.sh | bash
6363
```
6464

6565
## Parameters
6666

6767
Environment variables used by `./entrypoint.sh` script.
6868

69-
| Variable | Default | Description |
70-
| ------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
71-
| `INPUT_CMD_PARAMS` | `--buffer-size=8192 --concurrency=10` | Command line parameters for URL checker [muffet](https://github.com/raviqqe/muffet) - details [here](https://github.com/raviqqe/muffet/blob/master/arguments.go#L16-L34) |
72-
| `INPUT_DEBUG` | false | Enable debug mode for the `./entrypoint.sh` script (`set -x`) |
73-
| `INPUT_PAGES_PATH` | | Relative path to the directory with local web pages |
74-
| `INPUT_RUN_TIMEOUT` | 300 | Maximum number of seconds that URL checker can be running |
75-
| `INPUT_URL` | (**Mandatory / Required**) | URL which will be checked |
69+
| Variable | Default | Description |
70+
| ------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
71+
| `INPUT_CMD_PARAMS` | `--buffer-size=8192 --max-connections=10` | Command line parameters for URL checker [muffet](https://github.com/raviqqe/muffet) - details [here](https://github.com/raviqqe/muffet/blob/master/arguments.go#L16-L34) |
72+
| `INPUT_DEBUG` | false | Enable debug mode for the `./entrypoint.sh` script (`set -x`) |
73+
| `INPUT_PAGES_PATH` | | Relative path to the directory with local web pages |
74+
| `INPUT_RUN_TIMEOUT` | 300 | Maximum number of seconds that URL checker can be running |
75+
| `INPUT_URL` | (**Mandatory / Required**) | URL which will be checked |
7676

7777
## Full example
7878

@@ -183,7 +183,7 @@ jobs:
183183
env:
184184
INPUT_URL: https://${{ github.event.repository.name }}
185185
INPUT_PAGES_PATH: public
186-
INPUT_CMD_PARAMS: --verbose --buffer-size=8192 --concurrency=10 --skip-tls-verification --exclude=linkedin.com
186+
INPUT_CMD_PARAMS: --verbose --buffer-size=8192 --max-connections=10 --skip-tls-verification --exclude=linkedin.com
187187
run: |
188188
wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v1/entrypoint.sh | bash
189189
@@ -250,7 +250,7 @@ jobs:
250250
env:
251251
INPUT_URL: https://${{ github.event.repository.owner.name }}.github.io/${{ github.event.repository.name }}
252252
INPUT_PAGES_PATH: .
253-
INPUT_CMD_PARAMS: --buffer-size=8192 --concurrency=10 --skip-tls-verification
253+
INPUT_CMD_PARAMS: --buffer-size=8192 --max-connections=10 --skip-tls-verification
254254
run: |
255255
ln -s docs/.vuepress/dist ${{ github.event.repository.name }}
256256
wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v1/entrypoint.sh | bash
@@ -285,7 +285,7 @@ are not already installed on your system.
285285

286286
```bash
287287
export INPUT_URL="https://google.com"
288-
export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --concurrency=10 --verbose"
288+
export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --max-connections=10 --verbose"
289289
./entrypoint.sh
290290
```
291291

@@ -323,7 +323,7 @@ without touching your system:
323323

324324
```bash
325325
export INPUT_URL="https://google.com"
326-
export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --concurrency=10 --verbose"
326+
export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --max-connections=10 --verbose"
327327
docker run --rm -t -e INPUT_URL -e INPUT_CMD_PARAMS peru/my-broken-link-checker
328328
```
329329

demo/my-broken-link-checker-demo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pe 'export INPUT_URL="https://google.com"'
4747
p ''
4848

4949
p 'Add some extra muffet parameters to INPUT_CMD_PARAMS variable:'
50-
pe 'export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --concurrency=10 --verbose"'
50+
pe 'export INPUT_CMD_PARAMS="--ignore-fragments --one-page-only --max-connections=10 --verbose"'
5151

5252
p ''
5353

entrypoint.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env bash
22

3-
set -euo pipefail
3+
set -Eeuo pipefail
4+
5+
export MUFFET_VERSION="2.0.4"
6+
export CADDY_VERSION="2.2.0"
47

58
# Command line parameters for muffet
6-
export CMD_PARAMS="${INPUT_CMD_PARAMS:- --buffer-size=8192 --concurrency=10}"
9+
export CMD_PARAMS="${INPUT_CMD_PARAMS:- --buffer-size=8192 --max-connections=10}"
710
# Set path variable containing web pages
811
export PAGES_PATH=${INPUT_PAGES_PATH:-}
912
# URL to scan / check
@@ -18,6 +21,10 @@ export PAGES_URI
1821
export RUN_TIMEOUT="${INPUT_RUN_TIMEOUT:-300}"
1922
# Debug variable - enable by setting non-empty value
2023
export DEBUG=${INPUT_DEBUG:-}
24+
# Create caddy log file where will be all the log messages form the caddy server
25+
CADDY_LOG=$( mktemp /tmp/Caddy-log.XXXXXX )
26+
# Create caddy configuration to run web server using the domain set in PAGES_DOMAIN + /etc/hosts
27+
CADDYFILE=$( mktemp /tmp/Caddyfile.XXXXXX )
2128

2229
if [ $EUID != 0 ]; then
2330
sudo_cmd="sudo"
@@ -40,12 +47,14 @@ cleanup() {
4047
if ! grep -q -E '(docker|containerd)' /proc/self/cgroup ; then
4148
$sudo_cmd sed -i "/127.0.0.1 ${PAGES_DOMAIN} # Created by my-broken-link-checker/d" /etc/hosts
4249
fi
43-
$sudo_cmd caddy stop > /dev/null
50+
$sudo_cmd caddy stop &> /dev/null
4451
[ -f "${CADDYFILE}" ] && rm "${CADDYFILE}"
52+
[ -f "${CADDY_LOG}" ] && rm "${CADDY_LOG}"
4553
fi
4654
}
4755

4856
error_trap() {
57+
cat "${CADDY_LOG}"
4958
cleanup
5059
print_error "[$(date +'%F %T')] Something went wrong - see the errors above..."
5160
}
@@ -60,14 +69,26 @@ trap error_trap ERR
6069

6170
# Install muffet if needed
6271
if ! hash muffet &> /dev/null ; then
63-
MUFFET_URL=$(wget --quiet https://api.github.com/repos/raviqqe/muffet/releases/latest -O - | grep "browser_download_url.*muffet_.*_Linux_x86_64.tar.gz" | cut -d \" -f 4)
64-
wget --quiet "${MUFFET_URL}" -O - | $sudo_cmd tar xzf - -C /usr/local/bin/ muffet
72+
73+
if [ "${MUFFET_VERSION}" = "latest" ]; then
74+
MUFFET_URL=$(wget -qO- https://api.github.com/repos/raviqqe/muffet/releases/latest | grep "browser_download_url.*muffet_.*_Linux_x86_64.tar.gz" | cut -d \" -f 4)
75+
else
76+
MUFFET_URL="https://github.com/raviqqe/muffet/releases/download/v${MUFFET_VERSION}/muffet_${MUFFET_VERSION}_Linux_x86_64.tar.gz"
77+
fi
78+
79+
wget -qO- "${MUFFET_URL}" | $sudo_cmd tar xzf - -C /usr/local/bin/ muffet
6580
fi
6681

6782
# Install caddy if needed
6883
if ! hash caddy &> /dev/null && [ -n "${PAGES_PATH}" ] ; then
69-
LATEST_CADDY_URL=$(wget --quiet https://api.github.com/repos/caddyserver/caddy/releases/latest -O - | grep "browser_download_url.*caddy_.*_linux_amd64.tar.gz" | cut -d \" -f 4)
70-
wget --quiet "${LATEST_CADDY_URL}" -O - | $sudo_cmd tar xzf - -C /usr/local/bin/ caddy
84+
85+
if [ "${CADDY_VERSION}" = "latest" ]; then
86+
CADDY_URL=$(wget --quiet https://api.github.com/repos/caddyserver/caddy/releases/latest -O - | grep "browser_download_url.*caddy_.*_linux_amd64.tar.gz" | cut -d \" -f 4)
87+
else
88+
CADDY_URL="https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz"
89+
fi
90+
91+
wget --quiet "${CADDY_URL}" -O - | $sudo_cmd tar xzf - -C /usr/local/bin/ caddy
7192
fi
7293

7394
IFS=' ' read -r -a CMD_PARAMS <<< "$CMD_PARAMS"
@@ -93,8 +114,6 @@ else
93114
$sudo_cmd bash -c "echo \"127.0.0.1 ${PAGES_DOMAIN} # Created by my-broken-link-checker\" >> /etc/hosts"
94115
fi
95116

96-
# Create caddy configuration to run web server using the domain set in PAGES_DOMAIN + /etc/hosts
97-
CADDYFILE=$( mktemp /tmp/Caddyfile.XXXXXX )
98117
{
99118
echo "${PAGES_URI} {"
100119
echo " root * ${PAGES_PATH}"
@@ -104,7 +123,7 @@ else
104123
} > "${CADDYFILE}"
105124

106125
# Run caddy web server on the background
107-
$sudo_cmd caddy start -config "${CADDYFILE}" > /dev/null
126+
$sudo_cmd caddy start -config "${CADDYFILE}" &> "${CADDY_LOG}"
108127
sleep 1
109128

110129
# Run check

tests/fail_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export INPUT_DEBUG="true"
44

55
echo -e "\n\n\e[32m!!! Test when RUN_TIMEOUT is too tight\e[m"
66

7-
export INPUT_CMD_PARAMS="--one-page-only --concurrency=1 --verbose"
7+
export INPUT_CMD_PARAMS="--one-page-only --max-connections=1 --verbose"
88
export INPUT_RUN_TIMEOUT="1"
99
export INPUT_URL="https://google.com"
1010
../entrypoint.sh

tests/run_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export INPUT_DEBUG="true"
55

66

77
echo -e "\n\n\e[32m!!! Check differnet URLs types\e[m"
8-
export INPUT_CMD_PARAMS="--one-page-only --buffer-size=8192 --concurrency=10 --verbose"
8+
export INPUT_CMD_PARAMS="--one-page-only --buffer-size=8192 --max-connections=10 --verbose"
99

1010
export INPUT_URL="https://google.com"
1111
../entrypoint.sh
@@ -33,7 +33,7 @@ echo -e "\n\n\e[32m!!! Test docker image\e[m"
3333
docker build .. -t my-broken-link-checker-test
3434

3535
export INPUT_URL="https://google.com"
36-
export INPUT_CMD_PARAMS="--one-page-only --buffer-size=8192 --concurrency=10 --verbose"
36+
export INPUT_CMD_PARAMS="--one-page-only --buffer-size=8192 --max-connections=10 --verbose"
3737
docker run --rm -t -e INPUT_DEBUG -e INPUT_URL -e INPUT_CMD_PARAMS my-broken-link-checker-test
3838

3939
export INPUT_URL="https://my-testing-domain.com"

0 commit comments

Comments
 (0)