灯塔CI:必须为LHCI目标提供令牌

问题描述 投票:0回答:1

我正在尝试基于Lighthouse CI设置/上传this guide结果作为GitHub状态检查。

  1. 根据指南,我安装并授权了GitHub应用灯塔CI。
  2. 然后我将获得的令牌设置为LHCI_GITHUB_APP_TOKEN在Travis环境变量中。

这是我的.travis.yml的一部分。

language: node_js
node_js:
  - "12"

branches:
  only:
    - master

cache: yarn

before_install:
  - yarn global add @lhci/cli

install:
  - yarn install --frozen-lockfile

jobs:
  include:
    # other stages...

    - stage: lighthouse
      script:
        - yarn build
        - lhci autorun
      after_script:
        # Set the results as GitHub status checks
        - lhci upload
      addons:
        chrome: stable

lhci autorun成功运行。

但是,当lhci upload运行时,它返回错误

Error: Must provide token for LHCI target
    at runLHCITarget (/home/travis/.config/yarn/global/node_modules/@lhci/cli/src/upload/upload.js:212:29)
    at Object.runCommand (/home/travis/.config/yarn/global/node_modules/@lhci/cli/src/upload/upload.js:323:14)
    at run (/home/travis/.config/yarn/global/node_modules/@lhci/cli/src/cli.js:90:23)
    at Object.<anonymous> (/home/travis/.config/yarn/global/node_modules/@lhci/cli/src/cli.js:118:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)

这些是我的pull request和对应的Travis error log

如何正确为LHCI目标设置此令牌,以便能够在GitHub状态检查中上载Lighthouse CI结果?谢谢

travis-ci lighthouse
1个回答
0
投票

您需要注意变量的命名,根据指南,它必须是:LIGHTHOUSE_API_KEY而不是您使用的字符串LHCI_GITHUB_APP_TOKEN

您可以从源代码中看到API_KEY也可以使用警告:https://github.com/GoogleChromeLabs/lighthousebot/blob/289d17fa9732b41035196fdcbd3e470cc2980b77/runlighthouse.js#L24-L30

© www.soinside.com 2019 - 2024. All rights reserved.