Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The `shopify/lighthouse-ci-action` accepts the following arguments:
* `collection_handle` - (optional) Collection handle to run the product page Lighthouse run on. Defaults to the first collection.
* `lhci_min_score_performance` - (optional, default: 0.6) Minimum performance score for a passed audit (must be between 0 and 1).
* `lhci_min_score_accessibility` - (optional, default: 0.9) Minimum accessibility score for a passed audit
* `shop_app_api_frequency` - (optional, default: 2) Frequency at which to perform Shopify API requests. You should override this value to to 4 for Shopify Plus stores.

For the GitHub Status Checks on PR. One of the two arguments is required:

Expand Down
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
[[ -n "$INPUT_LHCI_MIN_SCORE_PERFORMANCE" ]] && export LHCI_MIN_SCORE_PERFORMANCE="$INPUT_LHCI_MIN_SCORE_PERFORMANCE"
[[ -n "$INPUT_LHCI_MIN_SCORE_ACCESSIBILITY" ]] && export LHCI_MIN_SCORE_ACCESSIBILITY="$INPUT_LHCI_MIN_SCORE_ACCESSIBILITY"

# Optional, used to override the default Shopify API rate limit
[[ -n "$INPUT_SHOP_APP_API_FREQUENCY" ]] && export SHOP_APP_API_FREQUENCY="$INPUT_SHOP_APP_API_FREQUENCY"

# Add global node bin to PATH (from the Dockerfile)
export PATH="$PATH:$npm_config_prefix/bin"

Expand Down Expand Up @@ -61,6 +64,10 @@ api_request() {
local err="$(mktemp)"
local out="$(mktemp)"

# Use a default API request frequency of 2 for non-Plus
local api_frequency="${SHOP_APP_API_FREQUENCY:-2}"
local sleep_time="$(bc <<< "scale=2; 1/$api_frequency")"

set +e
curl -sS -f -X GET -u "$username:$password" "$url" \
1> "$out" 2> "$err"
Expand All @@ -78,6 +85,9 @@ api_request() {
log "$errors"
cat "$err" 1>&2
return 1
else
# Linear back-off for Shopify API requests
sleep $sleep_time
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this but there's also no loop. Shouldn't there be a loop if you're trying to do a backoff? A retry?

fi

cat "$out"
Expand Down