Skip to content

Commit

Permalink
hack/check-links.sh: add 'ignore' check options (operator-framework#4205
Browse files Browse the repository at this point in the history
)

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
  • Loading branch information
Eric Stroczynski authored Nov 9, 2020
1 parent 17c0af8 commit 1cba71c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 50 deletions.
2 changes: 1 addition & 1 deletion hack/check-error-log-msg-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -o nounset
set -o pipefail

source "hack/lib/test_lib.sh"
source "hack/lib/common.sh"

echo "Checking format of error and log messages..."
allfiles=$(listFiles|grep -v ./internal/bindata/...)
Expand Down
2 changes: 1 addition & 1 deletion hack/check-license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o errexit
set -o nounset
set -o pipefail

source "hack/lib/test_lib.sh"
source "hack/lib/common.sh"

echo "Checking for license header..."
allfiles=$(listFiles|grep -v ./internal/bindata/...)
Expand Down
13 changes: 10 additions & 3 deletions hack/check-links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ set -e

source ./hack/lib/common.sh

header_text "Building the site and checking links"
header_text "Building the website"
docker volume create sdk-html
trap_add "docker volume rm sdk-html" EXIT
docker run --rm -v "$(pwd):/src" -v sdk-html:/src/website/public klakegg/hugo:0.73.0-ext-ubuntu -s website
docker run --rm -v sdk-html:/target mtlynch/htmlproofer /target --empty-alt-ignore --http-status-ignore 429 --allow_hash_href
docker volume rm sdk-html

header_text "Checking links"
# For config explanation: https://github.com/gjtorikian/html-proofer#special-cases-for-the-command-line
docker run --rm -v sdk-html:/target klakegg/html-proofer:latest /target \
--empty-alt-ignore \
--http-status-ignore 429 \
--allow_hash_href \
--url-ignore "/github.com\/operator-framework\/operator-sdk\/edit\/master\//"
40 changes: 40 additions & 0 deletions hack/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,43 @@ function header_text {
function error_text {
echo "$error_color$*$reset_color"
}

#===================================================================
# FUNCTION trap_add ()
#
# Purpose: prepends a command to a trap
#
# - 1st arg: code to add
# - remaining args: names of traps to modify
#
# Example: trap_add 'echo "in trap DEBUG"' DEBUG
#
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
#===================================================================
function trap_add() {
trap_add_cmd=$1; shift || fatal "${FUNCNAME} usage error"
new_cmd=
for trap_add_name in "$@"; do
# Grab the currently defined trap commands for this trap
existing_cmd=`trap -p "${trap_add_name}" | awk -F"'" '{print $2}'`

# Define default command
[ -z "${existing_cmd}" ] && existing_cmd="echo exiting @ `date`"

# Generate the new command
new_cmd="${trap_add_cmd};${existing_cmd}"

# Assign the test
trap "${new_cmd}" "${trap_add_name}" || \
fatal "unable to add to trap ${trap_add_name}"
done
}

function listPkgDirs() {
go list -f '{{.Dir}}' ./cmd/... ./test/... ./internal/... | grep -v generated
}

function listFiles() {
# pipeline is much faster than for loop
listPkgDirs | xargs -I {} find {} -name '*.go' | grep -v generated
}
43 changes: 0 additions & 43 deletions hack/lib/test_lib.sh

This file was deleted.

1 change: 0 additions & 1 deletion hack/tests/e2e-ansible-molecule.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

source hack/lib/common.sh
source hack/lib/test_lib.sh
source hack/lib/image_lib.sh

set -eu
Expand Down
1 change: 0 additions & 1 deletion hack/tests/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -eu

source hack/lib/common.sh
source hack/lib/test_lib.sh
source hack/lib/image_lib.sh

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

0 comments on commit 1cba71c

Please sign in to comment.