当连接到 Postgres 服务器版本 10.5 时,我有在本地工作的测试,但是 fail on Travis ,显然是由于使用了 IF NOT EXISTS
syntax那显然是added in Postgres 9.1 .
我的 .travis.yml
是:
language: node_js
node_js:
- "8"
- "9"
- "10"
- "stable"
# Use faster Docker architecture on Travis.
sudo: false
services:
- postgresql
script: ./scripts/validate.sh
after_success: npm run coveralls
我尝试了“Using a different postgresql version”的几种变体:
The Travis CI build environments use version 9.2 by default on Trusty images, but other versions from the official PostgreSQL APT repository are also available. To use a version other than the default, specify only the major.minor version in your
.travis.yml
:
但随后在 which postgres
上构建开始失败,所以看起来 PATH
上不再有 postgres
。
我尝试手动附加到 before_script
中的路径以将 /usr/lib/postgresql/10/bin/
添加到 PATH per postgresql-10但这没有帮助。
我不需要在众所周知的端口上启动数据库服务——我的测试和本地开发脚本运行 initdb
并启动测试通过命名连接到的本地数据库管道。
如何获得现代版本的 postgres 服务器二进制文件和相关工具(如 initdb)以供我的测试脚本使用?
最佳答案
我在 Github 上搜索了提到 postgres 的 .travis.yml 文件。
我发现下面的魔法咒语对我有用,但我不知道为什么。
我换了
services:
- postgresql
与
addons:
postgresql: "9.6"
以前我用过addons,但是除了服务而不是代替。
关于postgresql - 在 travis-ci 上查找 postgres 可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52708767/