我在使用 GitHub 操作运行自动化测试时遇到问题。我不明白为什么我无法连接到运行集成测试的 MongoDB 服务。我尝试了不同的主机:localhost、127.0.0.1、0.0.0.0,但它们都无法连接数据库。
它在我的 docker 设置中运行得很好,但由于某种原因不能与 GitHub 操作一起运行。
name: CI master
on: [push, pull_request]
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
APP_ENV: development
APP_MONGO_USER: test
APP_MONGO_PASS: password
APP_MONGO_DB: test
jobs:
# Run tests
test:
name: Test
runs-on: ubuntu-latest
services:
mongo:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: ${APP_MONGO_USER}
MONGO_INITDB_ROOT_PASSWORD: ${APP_MONGO_PASS}
MONGO_INITDB_DATABASE: ${APP_MONGO_DB}
ports:
- 27017:27017
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
Run Code Online (Sandbox Code Playgroud)
配置文件(development.toml)。
[application]
host = "127.0.0.1"
port = 8080 …Run Code Online (Sandbox Code Playgroud)