11

我刚开始使用 HerokuCI。我有一些 Selenium 测试,所以我在我的app.json.

{
  "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...

这占用了大部分测试运行时间。

这些安装可以缓存吗?

4

2 回答 2

0

如果您按照此处所述启用了缓存,则似乎您可以做更多的事情来缓存安装。如果这是一个严重的问题,您总是可以指向您从远程存储库克隆的本地包以加快速度。

于 2018-12-05T18:42:53.417 回答
-1

经过各种搜索和尝试,我带来了好消息。

关键问题是您在日志文件中的错误,例如:

bash: /tmp/buildpacks/b5ae60a477f2ba582d00a4ba23348059d40dea69cea6d982947f7c6afa72d2b8d69252449d43cbcf97a23341fd57300a3fef3224ace95482e1c0deaf8a844e4d/export: No such file or directory

这个自动生成的目录显然是一个缓存目录,不固定时自动生成的。

例如,这可以在app.json文件中定义的heroku-buildpack-selenium buildpack 中确认:

# parse and derive params
BUILD_DIR=$1
CACHE_DIR=$2
LP_DIR=`cd $(dirname $0); cd ..; pwd`

我发现的这个官方文档证实了这一点:

CACHE_DIR 的内容将在构建之间持久化。您可以在此处缓存依赖解析等长流程的结果,以加快未来的构建。

所以关键的解决方案是在你的安装中定义这个CACHE_DIR变量;所以我猜它要么直接在您的app.json文件中,要么直接在您的GitHub Hook中。

如果您需要进一步的帮助,请告诉我。

于 2018-12-05T09:32:24.913 回答