Circle CI CLI在结帐步骤中挂起

时间:2018-09-07 17:49:08

标签: circleci

我正在使用Circle CI CLI尝试重现远程CI环境。我一直陷在结帐步骤。没有错误,只是挂在那里。

我用--skip-checkout=false尝试过,它要求输入密码,然后同样的事情...只是挂起。

====>> Checkout code
#!/bin/bash -eo pipefail
mkdir -p /home/circleci/app && cp -r /tmp/_circleci_local_build_repo/. /home/circleci/app



    aliases:
    - &ecr-login
        name: ecr-login
        command: |
        export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY}
        export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_KEY}
        sudo apt-get update
        sudo apt-get install -y python-pip python-dev
        sudo pip install awscli
        sudo $(aws ecr get-login --no-include-email --region us-east-1)

    - &ecr-login-cypress
        name: ecr-login-cypress
        command: |
        export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY}
        export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_KEY}
        apt-get update
        apt-get install -y python-pip python-dev
        pip install awscli
        $(aws ecr get-login --no-include-email --region us-east-1)

    - &save_cache
        paths:
        # we need both yarn cache and node_modules
        # also make sure that working dir is app
        - ~/.cache/yarn
        - node_modules
        key: yarn-packages-v4-{{ checksum "yarn.lock" }}

    - &restore_cache
        name: Restore Yarn Package Cache
        keys:
            # only restores cache if the yarn file is the same
            - yarn-packages-v4-{{ checksum "yarn.lock" }}

    - &pull_site
        name: Pull from Docker
        command: docker pull "241884713626.dkr.ecr.us-east-1.amazonaws.com/website:latest"

    - &start_app
        name: Start App
        command: |
            docker run -td  -e DOCKER=1 \
                            -e CIRCLE_NODE_TOTAL=$CIRCLE_NODE_TOTAL \
                            -e CIRCLE_NODE_INDEX=$CIRCLE_NODE_INDEX \
                            -e NODE_ENV=development \
                            --name="app" \
                            --expose 5006 \
                            "241884713626.dkr.ecr.us-east-1.amazonaws.com/website:latest" \
                            sh -c "tail -f /dev/null"

    - &copy_app
        name: Copy Local app
        command: docker cp . app:/usr/src/app

    - &build_site
        name: Build Site
        command: |
            docker exec -t app sh -c "gulp clean && gulp buildonly &&  yarn generate-assets"

    - &start_site
        name: Start App
        command: |
            docker exec -td app sh -c "gulp server --docker --local"

    - &install_deps
        name: Install Dev Yarn deps
        command:  yarn install --production=false

    version: 2
    jobs:
    clone_and_install:
        <<: *defaults
        working_directory: ~/app

        steps:
        - checkout
        - restore_cache: *restore_cache
        - run: *install_deps
        - save_cache: *save_cache

    cypress_tests:
        docker:
        - image: circleci/node:9.11.1-browsers

        parallelism: 4

        working_directory: ~/app
        steps:
        - setup_remote_docker:
            docker_layer_caching: true
        - run: *ecr-login

        - checkout
        # - restore_cache: *restore_cache

        - run: *pull_site
        - run: *start_app
        - run: *start_site
        - run: *copy_app
        - run: *build_site
        - run:
            name: Install Cypress
            command: sudo apt-get -y install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 && yarn cypress install
        - run:
            name: Run tests
            command: yarn run cypress:ci --ci-build-id ${CIRCLE_BUILD_NUM}
        - store_artifacts:
            path: /usr/src/app/cypress/videos
        - store_artifacts:
            path: /usr/src/app/cypress/screenshots
        - store_artifacts:
            path: /usr/src/app/cypress/snapshots

2 个答案:

答案 0 :(得分:0)

结果证明它可以运行...仅需10分钟以上。我不确定是什么原因导致了极慢的速度,但是当我删除本地的node_modules时,速度会稍快一些。

答案 1 :(得分:0)

由于检出步骤将仅克隆整个本地目录(而不仅仅是使用git检出的目录),因此您需要当心隐藏和未跟踪的文件。

在运行作业之前,请确保您git gc。 如果这还不够,请通过删除不必要的本地分支来清理git repo,然后运行.git。这将使{{1}} dir较小。