config.yml
在我将其升级到 2.1 版后,我在设置我的 CircleCI 文件以适应赛普拉斯 e2e 测试时遇到了一些问题。它不断失败并出现以下错误:
#!/bin/sh -eo pipefail
# ERROR IN CONFIG FILE:
# [#/jobs/build] 0 subschemas matched instead of one
# 1. [#/jobs/build] only 1 subschema matches out of 2
# | 1. [#/jobs/build] 2 schema violations found
# | | 1. [#/jobs/build] extraneous key [branches] is not permitted
# | | | Permitted keys:
# | | | - description
# | | | - parallelism
# | | | - macos
# | | | - resource_class
# | | | - docker
# | | | - steps
# | | | - working_directory
# | | | - machine
# | | | - environment
# | | | - executor
# | | | - shell
# | | | - parameters
# | | | Passed keys:
# | | | - working_directory
# | | | - docker
# | | | - steps
# | | | - branches
# | | 2. [#/jobs/build/docker/0] extraneous key [env] is not permitted
# | | | Permitted keys:
# | | | - image
# | | | - name
# | | | - entrypoint
# | | | - command
# | | | - user
# | | | - environment
# | | | - aws_auth
# | | | - auth
# | | | Passed keys:
# | | | - image
# | | | - env
# 2. [#/jobs/build] expected type: String, found: Mapping
# | Job may be a string reference to another job
#
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
这是我的 yml 文件:
version: 2.1
jobs:
build:
working_directory: ~/myapp-web
docker:
- image: node:10.13.0-stretch
env:
- DISPLAY=:99
- CHROME_BIN=/usr/bin/google-chrome
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install Dependencies
command: |
npm install -g @angular/cli
npm install
npm install -g firebase-tools
apt-get -y -qq update
apt-get -y -qq install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
apt-get -y -qq update
apt-get -y -qq install python-dev
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
echo 'export PATH=/root/.local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
pip install awscli --upgrade --user
~/.local/bin/aws configure set default.s3.signature_version s3v4
fi
cd /root/myapp-web/src/app/functions/ && npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Run Tests
command:
npm run test-headless
- run:
name: Deploy to AWS
command: |
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
ng build --prod --configuration=production --progress=false
~/.local/bin/aws --region eu-west-2 s3 sync /root/myapp-web/dist/myapp-web/ s3://$AWS_BUCKET_TARGET --delete --exclude '.git/*'
fi
- run:
name: Deploy to Firebase
command: |
cd /root/myapp-web/src/app/functions/
if [[ "$CIRCLE_BRANCH" == "develop" ]]; then
firebase use myapp-dev
fi
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
firebase use myapp-live
fi
firebase deploy --token=$FIREBASE_TOKEN --non-interactive
branches:
only:
- develop
- master
orbs:
cypress: cypress-io/cypress@1
workflows:
test_then_build:
jobs:
- cypress/run:
start: npm run serve
wait-on: 'http://localhost:4200'