1. Orbs
  2. orbies/[email protected]
Sections
Circle CI jobs for Lighthouse CI
Created: September 7, 2020Version Published: July 16, 2021Releases: 8
Org Usage:
< 25

Orb Quick Start Guide

  1. Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

    version: 2.1

  2. Add the orbs stanza below your version, invoking the orb:

    orbs:
      lighthouse-ci: orbies/[email protected]

  3. Use lighthouse-ci elements in your existing workflows and jobs.

  4. Opt-in to use of uncertified orbs on your organization’s Security settings page.

Commands

run_lhci_collect

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
path_to_config_template
-
Yes
-
string
host_name
-
Yes
-
string
build_token
-
Yes
-
string
github_token
-
Yes
-
string
user
-
Yes
-
string
password
-
Yes
-
string
clone
-
No
moteefe
string

validate_test_exit_codes

checks the exit codes from the tests executions, only in one of the nodes

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
clone
-
No
moteefe
string

run_lhci_assert_and_upload

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
project
-
Yes
-
string
clone
-
No
moteefe
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing version: 2.1 description: Circle CI jobs for Lighthouse CI orbs: aws-cli: circleci/[email protected] aliases: - &lhci_install name: Install lhci command: | echo 'export PATH=$(yarn global bin):$PATH' >> $BASH_ENV source $BASH_ENV yarn global add @lhci/cli@^0.5.0 commands: run_lhci_collect: parameters: path_to_config_template: type: string host_name: type: string build_token: type: string github_token: type: string user: type: string password: type: string clone: type: string default: moteefe steps: - run: name: Generate Lighthouse CI config to lighthouserc.yml from the template command: | export LHCI_HOST_NAME=<< parameters.host_name >> export LHCI_USER=<< parameters.user >> export LHCI_PASSWORD=<< parameters.password >> export LHCI_BUILD_TOKEN=<< parameters.build_token >> export LHCI_GITHUB_TOKEN=<< parameters.github_token >> mkdir -p /tmp/output/exit_codes_for_nodes eval "cat \<< EOF $(< << parameters.path_to_config_template >>) EOF" > ./lighthouserc.yml - run: *lhci_install - aws-cli/setup - run: name: Collect lhci and create file with exit code for node command: | lhci collect --settings.chromeFlags='--disable-dev-shm-usage'; \ echo $? >> /tmp/output/exit_codes_for_nodes/exit_codes_for_node_${CIRCLE_NODE_INDEX} aws s3 cp /tmp/output/exit_codes_for_nodes s3://${AWS_S3_BUCKET}/test-reports-circle/lhci/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/<< parameters.clone >>/${CIRCLE_BUILD_NUM}/output --recursive validate_test_exit_codes: description: checks the exit codes from the tests executions, only in one of the nodes parameters: clone: type: string default: moteefe steps: - run: name: "Check exit codes from other jobs" shell: /bin/sh command: | if [ $CIRCLE_NODE_INDEX -ne 0 ]; then echo "Only the node 0 will create the report for the tests. Will skip for this node ${CIRCLE_NODE_INDEX}." circleci step halt else retries=0 until [ $((++retries)) -ge 200 ]; do number_of_exit_codes=$(aws s3api list-objects --bucket ${AWS_S3_BUCKET} --prefix test-reports-circle/lhci/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/<< parameters.clone >>/${CIRCLE_BUILD_NUM}/output/exit_codes_for_node_ --query "[length(Contents[])]" --output text) if [ $number_of_exit_codes -eq $CIRCLE_NODE_TOTAL ]; then break fi echo $number_of_exit_codes sleep 5 done fi run_lhci_assert_and_upload: parameters: project: type: string clone: type: string default: moteefe steps: - run: *lhci_install - aws-cli/setup - run: name: restore tests output from s3 command: | aws s3 cp s3://${AWS_S3_BUCKET}/test-reports-circle/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/<< parameters.clone >>/${CIRCLE_BUILD_NUM}/output \ ~/lhci/.lighthouseci \ --recursive - run: name: Run lhci assert command: lhci assert - run: name: Copy lighthouse reports command: | mkdir -p /tmp/reports cp ~/lhci/.lighthouseci/lhr-*.html /tmp/reports - run: name: Create link to lhci report command: | mkdir -p /tmp/reports LHCI_SERVER_BASE_URL=$(npx --yes -q js-yaml ~/lhci/lighthouserc.yml | node -e "console.log(JSON.parse(require('fs').readFileSync(0).toString()).ci.upload.serverBaseUrl )") LHCI_PROJECT=<< parameters.project >> echo "<html><script>location.replace('${LHCI_SERVER_BASE_URL}app/projects/${LHCI_PROJECT}/dashboard?branch=${CIRCLE_BRANCH}')</script></html>" > ./report.html cp ./report.html /tmp/reports - store_artifacts: path: /tmp/reports destination: lhci - run: name: Run lhci upload command: lhci upload
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.