Skip to content

Commit

Permalink
chore: bazel run //:format
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Dec 9, 2023
1 parent 69fe0d9 commit 7458b24
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 291 deletions.
2 changes: 1 addition & 1 deletion .aspect/workflows/terraform/workflows.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module "aspect_workflows" {

# Warming set definitions
warming_sets = {
default = {}
default = {}
}

# Resource types for use by runner groups
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.sh]
indent_style = space
indent_size = 4
10 changes: 5 additions & 5 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ echo >.git/info/attributes "examples export-ignore"
# But **do** include e2e/bzlmod since the BCR wants to run presubmit test
# and it only sees our release artifact.
# shellcheck disable=2010
ls e2e | grep -v bzlmod | awk 'NF{print "e2e/" $0 " export-ignore"}' >> .git/info/attributes
ls e2e | grep -v bzlmod | awk 'NF{print "e2e/" $0 " export-ignore"}' >>.git/info/attributes

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_js-${TAG:1}"
ARCHIVE="rules_js-$TAG.tar.gz"
git archive --format=tar --prefix="${PREFIX}/" "${TAG}" | gzip > "$ARCHIVE"
git archive --format=tar --prefix="${PREFIX}/" "${TAG}" | gzip >"$ARCHIVE"
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')

cat << EOF
cat <<EOF
Many companies are successfully building with rules_js.
If you're getting value from the project, please let us know!
Expand Down Expand Up @@ -65,9 +65,9 @@ http_archive(
EOF

awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE
echo "\`\`\`"
echo "\`\`\`"

cat << EOF
cat <<EOF
To use rules_js with bazel-lib 2.x, you must additionally register the coreutils toolchain.
Expand Down
4 changes: 2 additions & 2 deletions e2e/js_image_docker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ BZLMOD_FLAG="${BZLMOD_FLAG:-}"

# shellcheck disable=SC2086
if ! bazel test $BZLMOD_FLAG --nobuild_runfile_links //...; then
echo "ERROR: expected 'bazel test $BZLMOD_FLAG --nobuild_runfile_links //...' to pass"
exit 1
echo "ERROR: expected 'bazel test $BZLMOD_FLAG --nobuild_runfile_links //...' to pass"
exit 1
fi
4 changes: 2 additions & 2 deletions e2e/js_image_oci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ BZLMOD_FLAG="${BZLMOD_FLAG:-}"

# shellcheck disable=SC2086
if ! bazel test $BZLMOD_FLAG --nobuild_runfile_links //...; then
echo "ERROR: expected 'bazel test $BZLMOD_FLAG --nobuild_runfile_links //...' to pass"
exit 1
echo "ERROR: expected 'bazel test $BZLMOD_FLAG --nobuild_runfile_links //...' to pass"
exit 1
fi
127 changes: 63 additions & 64 deletions e2e/js_run_devserver/multirun_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ PORT2=8081

# sedi makes `sed -i` work on both OSX & Linux
# See https://stackoverflow.com/questions/2320564/i-need-my-sed-i-command-for-in-place-editing-to-work-with-both-gnu-sed-and-bsd
_sedi () {
case $(uname) in
_sedi() {
case $(uname) in
Darwin*) sedi=('-i' '') ;;
*) sedi=('-i') ;;
esac
esac

sed "${sedi[@]}" "$@"
sed "${sedi[@]}" "$@"
}

echo "$$: TEST - $0: $TARGET @ $PORT1 & $PORT2"
Expand All @@ -25,11 +25,11 @@ echo "$$: TEST - $0: $TARGET @ $PORT1 & $PORT2"
ibazel_pid="$!"

function _exit {
echo "$$: Cleanup..."
kill "$ibazel_pid"
wait "$ibazel_pid"
git checkout src/index.html src/BUILD.bazel
rm -f src/new.html
echo "$$: Cleanup..."
kill "$ibazel_pid"
wait "$ibazel_pid"
git checkout src/index.html src/BUILD.bazel
rm -f src/new.html
}
trap _exit EXIT

Expand All @@ -38,118 +38,117 @@ echo "$$: Waiting for $TARGET devserver to launch on $PORT1..."
# Wait for $PORT1 to start the http server
n=0
while ! nc -z localhost $PORT1; do
if [ $n -gt 100 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1 to be available"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 100 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1 to be available"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done

echo "$$: Waiting for $TARGET devserver to launch on $PORT2..."

# Wait for $PORT2 to start the http server
n=0
while ! nc -z localhost $PORT2; do
if [ $n -gt 100 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2 to be available"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 100 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2 to be available"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done


# Verify the initial state of $PORT1 and $PORT2
echo "$$: Devservers ready"

if ! curl http://localhost:$PORT1/index.html --fail 2>/dev/null | grep "My first website"; then
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to contain 'My first website'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to contain 'My first website'"
exit 1
fi

if ! curl http://localhost:$PORT2/index.html --fail 2>/dev/null | grep "My first website"; then
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to contain 'My first website'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to contain 'My first website'"
exit 1
fi

if ! curl http://localhost:$PORT1/other.html --fail 2>/dev/null | grep "My other website"; then
echo "$$: ERROR: Expected http://localhost:$PORT1/other.html to contain 'My other website'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT1/other.html to contain 'My other website'"
exit 1
fi

if ! curl http://localhost:$PORT2/other.html --fail 2>/dev/null | grep "My other website"; then
echo "$$: ERROR: Expected http://localhost:$PORT2/other.html to contain 'My other website'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT2/other.html to contain 'My other website'"
exit 1
fi

if curl http://localhost:$PORT1/new.html --fail 2>/dev/null; then
echo "$$: ERROR: Expected http://localhost:$PORT1/new.html to fail with 404"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT1/new.html to fail with 404"
exit 1
fi

if curl http://localhost:$PORT2/new.html --fail 2>/dev/null; then
echo "$$: ERROR: Expected http://localhost:$PORT2/new.html to fail with 404"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT2/new.html to fail with 404"
exit 1
fi

if curl http://localhost:$PORT1/index.html --fail 2>/dev/null | grep "A second line"; then
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to NOT contain 'A second line'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to NOT contain 'A second line'"
exit 1
fi

if curl http://localhost:$PORT2/index.html --fail 2>/dev/null | grep "A second line"; then
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to NOT contain 'A second line'"
exit 1
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to NOT contain 'A second line'"
exit 1
fi

echo "<div>A second line</div>" >> src/index.html
echo "<div>A second line</div>" >>src/index.html

# Wait for $PORT1 to show the updated file
n=0
while ! curl http://localhost:$PORT1/index.html --fail 2>/dev/null | grep "A second line"; do
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to contain 'A second line'"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1/index.html to contain 'A second line'"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done

# Wait for $PORT2 to show the updated file
n=0
while ! curl http://localhost:$PORT2/index.html --fail 2>/dev/null | grep "A second line"; do
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to contain 'A second line'"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2/index.html to contain 'A second line'"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done

echo "<div>A new file</div>" > src/new.html
echo "<div>A new file</div>" >src/new.html
_sedi 's#"other.html"#"other.html", "new.html"#' src/BUILD.bazel

# Wait for $PORT1 to show the new file
n=0
while ! curl http://localhost:$PORT1/new.html --fail 2>/dev/null | grep "A new file"; do
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1/new.html to contain 'A new file'"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT1/new.html to contain 'A new file'"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done

# Wait for $PORT2 to show the new file
n=0
while ! curl http://localhost:$PORT2/new.html --fail 2>/dev/null | grep "A new file"; do
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2/new.html to contain 'A new file'"
exit 1
fi
sleep 1 # wait before check again
((n=n+1))
if [ $n -gt 30 ]; then
echo "$$: ERROR: Expected http://localhost:$PORT2/new.html to contain 'A new file'"
exit 1
fi
sleep 1 # wait before check again
((n = n + 1))
done

echo "$$: All tests passed"
Loading

0 comments on commit 7458b24

Please sign in to comment.