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
4 changes: 3 additions & 1 deletion Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RUN apt-get update \
&& git -C "$(rbenv root)"/plugins/ruby-build pull \
&& rbenv install 2.7.1 \
&& rbenv global 2.7.1 \
&& gem install shopify-cli -N
&& gem install shopify-cli -N \
&& wget https://github.com/mikefarah/yq/releases/download/v4.13.5/yq_linux_386 -O /usr/bin/yq \
&& chmod +x /usr/bin/yq

###
# Chrome in Docker fix
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ inputs:
description: 'Minimum accessibility score'
required: false
default: 0.9
lhci_config_path:
description: 'Path to custom Lighthouse CI config'
required: false
default: '.lighthouserc.yml'
runs:
using: 'docker'
image: 'Dockerfile'
17 changes: 16 additions & 1 deletion 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
[[ -n "$INPUT_LHCI_CONFIG_PATH" ]] && export LHCI_CONFIG_PATH="$INPUT_LHCI_CONFIG_PATH"

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

Expand Down Expand Up @@ -167,7 +170,9 @@ query_string="?_fd=0&pb=0"
min_score_performance="${LHCI_MIN_SCORE_PERFORMANCE:-0.6}"
min_score_accessibility="${LHCI_MIN_SCORE_ACCESSIBILITY:-0.9}"

cat <<- EOF > lighthouserc.yml
# Prepare the default Lighthouse CI config
default_config="$(mktemp XXXXX.yml)"
cat <<- EOF > $default_config
ci:
collect:
url:
Expand Down Expand Up @@ -195,6 +200,16 @@ ci:
aggregationMethod: median-run
EOF

# Merge custom Lighthouse CI config, if provided
custom_config="${LHCI_CONFIG_PATH:-.lighthouserc.yml}"

if [[ -f "$custom_config" ]]; then
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' "$default_config" "$custom_config" > .lighthouserc.yml.tmp
mv .lighthouserc.yml.tmp .lighthouserc.yml
else
mv $default_config .lighthouserc.yml
fi

cat <<-EOF > setPreviewCookies.js
module.exports = async (browser) => {
// launch browser for LHCI
Expand Down