我刚刚开始使用HerokuCI。我有一些Selenium测试,所以我在app.json
中添加了buildpack。
{
"buildpacks": [
{ "url": "heroku/ruby" }
],
"environments": {
"test": {
"addons": ["heroku-postgresql:in-dyno", "heroku-redis:in-dyno"],
"buildpacks": [
{ "url": "heroku/ruby" },
{ "url": "https://github.com/notvad/heroku-buildpack-selenium" },
{ "url": "https://github.com/heroku/heroku-buildpack-chromedriver" },
{ "url": "https://github.com/heroku/heroku-buildpack-google-chrome" }
],
"env": {
"REDIS_PROVIDER": "REDIS_URL",
"RAILS_ENV": "test",
"RACK_ENV": "test",
"MALLOC_ARENA_MAX": 2,
"LANG": "en_US.UTF-8",
"TEST_API": 1
},
"scripts": {
"test-setup": "./bin/setup-cc-test-reporter",
"test": "./bin/test-with-cc-test-reporter"
}
}
}
}
这些内容及其所有依赖项都在不断重建。
-----> Selenium app detected
bash: /tmp/buildpacks/b5ae60a477f2ba582d00a4ba23348059d40dea69cea6d982947f7c6afa72d2b8d69252449d43cbcf97a23341fd57300a3fef3224ace95482e1c0deaf8a844e4d/export: No such file or directory
bash: /tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/export: No such file or directory
-----> Updating apt caches
Hit:1 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists...
-----> Fetching .debs for xserver-xorg-core libgl1-mesa-dri xvfb libglide3 xfs unzip
Reading package lists...
Building dependency tree...
Package xfs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'xfs' has no installation candidate
-----> Installing adwaita-icon-theme_3.28.0-1ubuntu1_all.deb
-----> Installing at-spi2-core_2.28.0-1_amd64.deb
...and so on...
-----> Downloading and installing Selenium
-----> Writing profile script
-----> chromedriver app detected
bash: /tmp/buildpacks/b5ae60a477f2ba582d00a4ba23348059d40dea69cea6d982947f7c6afa72d2b8d69252449d43cbcf97a23341fd57300a3fef3224ace95482e1c0deaf8a844e4d/export: No such file or directory
bash: /tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/export: No such file or directory
bash: /tmp/buildpacks/f55d0db8af2b8c70f2c0e028ef5430955852d9e4f07a06e333e54eb5264a81b9d1e77d1cc02851b4c7da30f6da47b13959e18a24c630212b899920d05f32a566/export: No such file or directory
-----> Looking up latest chromedriver version...
-----> Downloading chromedriver v2.43...
Archive: /tmp/chromedriver.zip
inflating: /app/.chromedriver/bin/chromedriver
-----> Creating chromedriver export scripts...
-----> Google Chrome app detected
bash: /tmp/buildpacks/b5ae60a477f2ba582d00a4ba23348059d40dea69cea6d982947f7c6afa72d2b8d69252449d43cbcf97a23341fd57300a3fef3224ace95482e1c0deaf8a844e4d/export: No such file or directory
bash: /tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/export: No such file or directory
bash: /tmp/buildpacks/f55d0db8af2b8c70f2c0e028ef5430955852d9e4f07a06e333e54eb5264a81b9d1e77d1cc02851b4c7da30f6da47b13959e18a24c630212b899920d05f32a566/export: No such file or directory
bash: /tmp/buildpacks/27353aa3b5edb2f8361186206e863f5d481f02805d02f0efdec439f3d30349a4fbdad2951af33a0492023fb0d90d26dafda6fe76f1b2d34f68564a98545f7022/export: No such file or directory
-----> Installing Google Chrome from the stable channel.
-----> Updating apt caches
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists...
-----> Fetching .debs for gconf-service
...and so on...
这占用了大部分测试运行时间。
这些安装可以缓存吗?
答案 0 :(得分:0)
如果您已按照here中的说明启用了缓存,那么似乎可以做更多的事情来缓存安装。如果这是一个严重的问题,您可以始终指向从远程存储库克隆的本地软件包,以加快处理速度。
答案 1 :(得分:-1)
经过各种搜索和尝试,我带来了好消息。
关键问题是您在日志文件中的错误,例如:
bash: /tmp/buildpacks/b5ae60a477f2ba582d00a4ba23348059d40dea69cea6d982947f7c6afa72d2b8d69252449d43cbcf97a23341fd57300a3fef3224ace95482e1c0deaf8a844e4d/export: No such file or directory
此自动生成的目录显然是一个缓存目录,该目录在未修复时会自动生成。
例如,可以在您的 app.json 文件中定义的heroku-buildpack-selenium构建包中对此进行确认:
# parse and derive params
BUILD_DIR=$1
CACHE_DIR=$2
LP_DIR=`cd $(dirname $0); cd ..; pwd`
这是我发现的official documentation的证实:
CACHE_DIR的内容将在两次构建之间保留。您可以 将长流程的结果(如依赖关系解析)缓存到此处 加快将来的构建。
因此,关键的解决方案是在安装过程中定义此 CACHE_DIR 变量;所以我想它要么直接在您的 app.json 文件中,要么直接在您的GitHub Hook中。
让我知道是否需要进一步的帮助。