Skip to content

Commit 1cba71c

Browse files
author
Eric Stroczynski
authored
hack/check-links.sh: add 'ignore' check options (#4205)
hack/check-links.sh: ignore urls containing github.com/operator-framework/operator-sdk/edit/master/ hack/*: move test_lib.sh functions into common.sh and import common.sh where applicable
1 parent 17c0af8 commit 1cba71c

File tree

7 files changed

+52
-50
lines changed

7 files changed

+52
-50
lines changed

hack/check-error-log-msg-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -o nounset
44
set -o pipefail
55

6-
source "hack/lib/test_lib.sh"
6+
source "hack/lib/common.sh"
77

88
echo "Checking format of error and log messages..."
99
allfiles=$(listFiles|grep -v ./internal/bindata/...)

hack/check-license.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7-
source "hack/lib/test_lib.sh"
7+
source "hack/lib/common.sh"
88

99
echo "Checking for license header..."
1010
allfiles=$(listFiles|grep -v ./internal/bindata/...)

hack/check-links.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ set -e
44

55
source ./hack/lib/common.sh
66

7-
header_text "Building the site and checking links"
7+
header_text "Building the website"
88
docker volume create sdk-html
9+
trap_add "docker volume rm sdk-html" EXIT
910
docker run --rm -v "$(pwd):/src" -v sdk-html:/src/website/public klakegg/hugo:0.73.0-ext-ubuntu -s website
10-
docker run --rm -v sdk-html:/target mtlynch/htmlproofer /target --empty-alt-ignore --http-status-ignore 429 --allow_hash_href
11-
docker volume rm sdk-html
11+
12+
header_text "Checking links"
13+
# For config explanation: https://github.com/gjtorikian/html-proofer#special-cases-for-the-command-line
14+
docker run --rm -v sdk-html:/target klakegg/html-proofer:latest /target \
15+
--empty-alt-ignore \
16+
--http-status-ignore 429 \
17+
--allow_hash_href \
18+
--url-ignore "/github.com\/operator-framework\/operator-sdk\/edit\/master\//"

hack/lib/common.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,43 @@ function header_text {
2424
function error_text {
2525
echo "$error_color$*$reset_color"
2626
}
27+
28+
#===================================================================
29+
# FUNCTION trap_add ()
30+
#
31+
# Purpose: prepends a command to a trap
32+
#
33+
# - 1st arg: code to add
34+
# - remaining args: names of traps to modify
35+
#
36+
# Example: trap_add 'echo "in trap DEBUG"' DEBUG
37+
#
38+
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
39+
#===================================================================
40+
function trap_add() {
41+
trap_add_cmd=$1; shift || fatal "${FUNCNAME} usage error"
42+
new_cmd=
43+
for trap_add_name in "$@"; do
44+
# Grab the currently defined trap commands for this trap
45+
existing_cmd=`trap -p "${trap_add_name}" | awk -F"'" '{print $2}'`
46+
47+
# Define default command
48+
[ -z "${existing_cmd}" ] && existing_cmd="echo exiting @ `date`"
49+
50+
# Generate the new command
51+
new_cmd="${trap_add_cmd};${existing_cmd}"
52+
53+
# Assign the test
54+
trap "${new_cmd}" "${trap_add_name}" || \
55+
fatal "unable to add to trap ${trap_add_name}"
56+
done
57+
}
58+
59+
function listPkgDirs() {
60+
go list -f '{{.Dir}}' ./cmd/... ./test/... ./internal/... | grep -v generated
61+
}
62+
63+
function listFiles() {
64+
# pipeline is much faster than for loop
65+
listPkgDirs | xargs -I {} find {} -name '*.go' | grep -v generated
66+
}

hack/lib/test_lib.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

hack/tests/e2e-ansible-molecule.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env bash
22

33
source hack/lib/common.sh
4-
source hack/lib/test_lib.sh
54
source hack/lib/image_lib.sh
65

76
set -eu

hack/tests/integration.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -eu
44

55
source hack/lib/common.sh
6-
source hack/lib/test_lib.sh
76
source hack/lib/image_lib.sh
87

98
TMPDIR="$(mktemp -d -p /tmp memcached-operator-XXXX)"

0 commit comments

Comments
 (0)