我正在处理一个运行单元测试和浏览器(黄昏)测试的CircleCi配置文件。每次在php artisan黄昏命令上,CircleCi的测试均失败。如果我添加属性background: true
,则php工匠服务也会被“取消”。
php artisan serve --port=8000
backgroud: true
和php artisan serve &
curl http://localhost:8000
(失败)circleci配置文件
version: 2
jobs:
Test:
docker:
- image: circleci/php:7.2-fpm-node-browsers
- image: circleci/redis:5.0
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: ''
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_DATABASE: homestead
MYSQL_ALLOW_EMPTY_PASSWORD: true
environment:
APP_ENV: testing
APP_URL: http://localhost:8000
APP_KEY: ###
DB_HOST: 127.0.0.1
DB_DATABASE: homestead
DB_USERNAME: homestead
DB_PASSWORD: secret
REDIS_HOST: 127.0.0.1
REDIS_PASSWORD: 'null'
PUSHER_APP_ID: ###
PUSHER_APP_KEY: ###
PUSHER_APP_SECRET: ###
PUSHER_APP_CLUSTER: ###
MIX_PUSHER_APP_KEY: ###
MIX_PUSHER_APP_CLUSTER: ###
working_directory: ~/workspace
steps:
- checkout
- run:
name: Prepare Environment
command: .circleci/kickstart.sh
- restore_cache:
keys:
- composer-v1-{{ checksum "composer.lock" }}
- composer-v1-
- run: composer install -n --prefer-dist
- save_cache:
key: composer-v1-{{ checksum "composer.lock" }}
paths:
- vendor
- restore_cache:
keys:
- node-v1-{{ checksum "package-lock.json" }}
- node-v1-
- run: npm install
- save_cache:
key: node-v1-{{ checksum "package-lock.json" }}
paths:
- node_modules
- run:
name: Build Artifacts
command: npm run dev
- run:
name: Waiting for MySQL to be ready
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
- run: php artisan config:clear
- run: php artisan config:cache
- run: php artisan migrate:refresh --seed --database=mysql --force
- run: php artisan dusk:install
- run:
name: Run PHP Unit Tests
command: ./vendor/bin/phpunit
- run:
name: Run server
command: php artisan serve --port=8000 &
# - run:
# name: Run server
# command: php artisan serve --port=8000
# background: true
- run:
name: Test connection to server
command: curl http://localhost:8000
- run:
name: Run E2E Tests
command: php artisan dusk
environment:
APP_URL: http://localhost:8000
- store_artifacts:
path: ./tests/Browser/console
destination: console
- store_artifacts:
path: ./tests/Browser/screenshots
destination: screenshots
workflows:
version: 2
Build and Test:
jobs:
- Test
卷曲失败
#!/bin/bash -eo pipefail
php artisan serve --port=8000 &
curl http://localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
Exited with code 7
黄昏应在服务器运行后运行