circleci 只有 1 个子模式匹配 2 个

问题描述

我正在尝试为我的电子应用程序创建 circleci 自动化测试。
我遵循了这里的说明:https://circleci.com/blog/electron-testing/
我的仓库:https://github.com/dhanyn10/electron-example/tree/spectron
我的项目文件夹看起来像这样

electron-example
|──/.circleci
|  |──config.yml
|──/bootBox
|──/project1
|──/project2

因为在我的项目中包含许多应用程序,我需要指定我将测试的文件夹中的哪个应用程序。这是我的 circleci 配置

version: 2.1
jobs:
  build:
    working_directory: ~/electron-example/bootBox
    docker:
      - image: circleci/node:11-browsers
    steps:
      - checkout:
        path: ~/electron-example
      - run:
          name: Update NPM
          command: "sudo npm install -g npm"
      - restore_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
      - run:
          name: Install Dependencies
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: Run tests
          command: npm run test

package.json

...
  "devDependencies": {
    "electron": "^11.4.3","electron-builder": "^22.10.4","mocha": "^8.3.2","spectron": "^13.0.0"
  },...

它在下面返回错误

#!/bin/sh -eo pipefail
# ERROR IN CONfig FILE:
# [#/jobs/build] only 1 subschema matches out of 2
# 1. [#/jobs/build/steps/0] 0 subschemas matched instead of one
# |   1. [#/jobs/build/steps/0] extraneous key [path] is not permitted
# |   |   Permitted keys:
# |   |     - persist_to_workspace
# |   |     - save_cache
# |   |     - run
# |   |     - checkout
# |   |     - attach_workspace
# |   |     - store_test_results
# |   |     - restore_cache
# |   |     - store_artifacts
# |   |     - add_ssh_keys
# |   |     - deploy
# |   |     - setup_remote_docker
# |   |   Passed keys:
# |   |     []
# |   2. [#/jobs/build/steps/0] Input not a valid enum value
# |   |   Steps without arguments can be called as strings
# |   |     enum:
# |   |     - checkout
# |   |     - setup_remote_docker
# |   |     - add_ssh_keys
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false

Exited with code exit status 1
CircleCI received exit code 1

如何解决这个错误

解决方法

见:

这里有点晚,但结帐默认为 working_directory

      - checkout:
        path: ~/electron-example

应该是:

      - checkout

我也因为以下原因来到这里,尝试添加浏览器工具:

workflows:
  build-and-test:
    jobs:
      - build
      - pylint
      - tslint
      - karma
      - jest
      - unit-tests
      - functional-tests:
          requires:
            - build
      - deploy:
          requires:
            - build
    orbs:
        browser-tools-blah

应该是:

orbs:
    browser-tools-blah

workflows:
  build-and-test:
    jobs:
      - build
      - pylint
      - tslint
      - karma
      - jest
      - unit-tests
      - functional-tests:
          requires:
            - build
      - deploy:
          requires:
            - build