这是我们第一次尝试使用webpacker编译Vuejs应用程序运行测试。构建冻结在webpacker:compile步骤上,然后因以下消息而超时:
Too long with no output (exceeded 35m0s)Too long with no output (exceeded 35m0s)
默认超时为10分钟,我们认为可能还不够,将其增加到35分钟,但仍然失败。在localhost上,用NODE_ENV = test和RAILS_ENV = test编译不到20秒 我们使用rspec和capybara进行测试。
我们在heroku上成功运行了webpacker,尽管编译时间很长(6-7分钟),但仍然可以完成。有人遇到过这个或类似的问题吗?请帮助解决。
轨距4.2.10
webpacker 4.0.7
circleci配置:
version: 2
jobs:
build:
working_directory: ~/judgeme/judgeme
parallelism: 1
shell: /bin/bash --login
environment:
RAILS_ENV: test
RACK_ENV: test
NODE_ENV: test
#some other variables in here
docker:
- image: circleci/ruby:2.4.4-node-browsers
environment: # environment variables for primary container
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
PGHOST: 127.0.0.1
PGUSER: judgeme-test
RAILS_ENV: test
- image: circleci/postgres:9.5-alpine-ram # database image
environment: # environment variables for database
POSTGRES_USER: judgeme-test
POSTGRES_DB: judgeme_test
POSTGRES_PASSWORD: ""
- image: redis
- image: docker.elastic.co/elasticsearch/elasticsearch:6.0.1
steps:
- checkout
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
# Restore bundle cache
- restore_cache:
keys:
# - rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
# This branch if available
- v1-dep-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
# Default branch if not
- v1-dep-master-{{ checksum "Gemfile.lock" }}
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
- v1-dep-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle gems
command: 'bundle check --path=vendor/bundle || bundle install --path=vendor/bundle'
# Store bundle cache
- save_cache:
# key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
key: v1-dep-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
# This is a broad list of cache paths to include many possible development environments
# You can probably delete some of these entries
- vendor/bundle
- ~/virtualenvs
- ~/.bundle
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Wait for ElasticSearch
command: dockerize -wait tcp://127.0.0.1:9200/ -timeout 1m
- run:
name: Database setup
command: bundle exec rake db:schema:load --trace
- restore_cache:
keys:
- yarn-{{ checksum "yarn.lock" }}
- run:
name: Yarn install
command: yarn install --cache-folder ~/.cache/yarn
# save yarn cache
- save_cache:
key: yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- restore_cache:
keys:
- webpack-{{ .Revision }}
- run:
name: Compile webpacker assets
command: bundle exec rake webpacker:compile
no_output_timeout: 35m
- save_cache:
key: webpack-{{ .Revision }}
paths:
- /home/circleci/project/public/packs-test/
- run:
name: Run rspec with integrations tests at last
command: |
bundle exec rspec --profile 10 --format progress \
spec/controllers \
spec/jobs \
spec/mailers \
spec/models \
spec/policies \
spec/queries \
spec/services \
spec/integrations \
spec
no_output_timeout: 3600s
# Save test results for timing analysis
- store_test_results:
path: test_results
- store_test_results:
path: /tmp/circleci-test-results
# Save artifacts
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results
webpacker.yml:
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: false
resolved_paths: []
cache_manifest: false
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .erb
- .vue
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
check_yarn_integrity: true
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: false
public_output_path: packs-test
production:
<<: *default
compile: false
extract_css: true
cache_manifest: true
答案 0 :(得分:0)
找到了在erb-loader问题here中冻结编译的解决方案。 erb加载器和弹簧相互作用存在一些问题,这会导致冻结。更改erb-loader config(config / webpack / loaders / erb.js)即可解决。 需要添加
env: {
...process.env,
DISABLE_SPRING: 1,
}
到选项,因此整个配置如下:
module.exports = {
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
use: [{
loader: 'rails-erb-loader',
options: {
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner',
env: {
...process.env,
DISABLE_SPRING: 1,
},
}
}]
}