Switch CI to Semaphore
parent
58cab34895
commit
25ce6da768
@ -0,0 +1,24 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
mongodb:
|
||||||
|
image: mongo:3.6
|
||||||
|
environment:
|
||||||
|
- MONGO_DATA_DIR=/data/db
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
|
command: mongod --smallfiles
|
||||||
|
rust:
|
||||||
|
image: rust:latest
|
||||||
|
container_name: "rust"
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
environment:
|
||||||
|
CARGO_HOME: "/tmp/_cargo"
|
||||||
|
RUST_TEST_THREADS: "1"
|
||||||
|
RUST_BACKTRACE: "full"
|
||||||
|
LIBCLANG_PATH: "/usr/lib/llvm-7/lib"
|
||||||
|
SKIP_SSL_CONNECTION_TESTS: "true"
|
||||||
|
MONGODB_CONNECTION_STRING: "mongodb://mongodb:27017"
|
||||||
|
working_dir: /project
|
||||||
|
command: tail -f /dev/null
|
@ -0,0 +1,58 @@
|
|||||||
|
version: v1.0
|
||||||
|
name: Mongo Rust Driver tests
|
||||||
|
|
||||||
|
agent:
|
||||||
|
machine:
|
||||||
|
type: e1-standard-8
|
||||||
|
os_image: ubuntu1804
|
||||||
|
|
||||||
|
# Cancel all running and queued workflows before this one
|
||||||
|
auto_cancel:
|
||||||
|
running:
|
||||||
|
# Ignore main AND develop branch as we want it to build all workflows
|
||||||
|
when: "branch != 'main' AND branch != 'develop'"
|
||||||
|
|
||||||
|
global_job_config:
|
||||||
|
env_vars:
|
||||||
|
- name: "CONTAINER_NAME"
|
||||||
|
value: rust
|
||||||
|
- name: "COMPOSE_OPTIONS"
|
||||||
|
value: "-f .semaphore/docker-compose.yml"
|
||||||
|
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
blocks:
|
||||||
|
- name: Build & Test
|
||||||
|
dependencies: []
|
||||||
|
task:
|
||||||
|
prologue:
|
||||||
|
commands:
|
||||||
|
# Create containers but don't start them yet. We first want to copy the caches onto it
|
||||||
|
- docker-compose $COMPOSE_OPTIONS up --no-start
|
||||||
|
# Copy cargo cache to main test container
|
||||||
|
- cache restore v3-cargo-$(checksum Cargo.lock),v3-cargo
|
||||||
|
- "[ -d \"/tmp/_cargo\" ] && docker cp /tmp/_cargo $CONTAINER_NAME:/tmp/_cargo || echo 'No cache to copy'"
|
||||||
|
# Copy project to main test container
|
||||||
|
- cache restore v3-project-$(cat PACKAGES_CHECKSUM),v3-project
|
||||||
|
- docker cp . $CONTAINER_NAME:/project
|
||||||
|
|
||||||
|
# Then start the containers so we can run the test on it
|
||||||
|
- docker-compose $COMPOSE_OPTIONS up -d --no-recreate
|
||||||
|
jobs:
|
||||||
|
- name: Test
|
||||||
|
commands:
|
||||||
|
- docker-compose $COMPOSE_OPTIONS exec $CONTAINER_NAME cargo test
|
||||||
|
epilogue:
|
||||||
|
always:
|
||||||
|
commands:
|
||||||
|
# Pull artifacts from containers and cache them
|
||||||
|
- rm -rf target
|
||||||
|
- docker cp $CONTAINER_NAME:/project/target target
|
||||||
|
- cache store v3-project-$(cat PACKAGES_CHECKSUM) target
|
||||||
|
|
||||||
|
# Pull cargo dir and cache it
|
||||||
|
- rm -rf /tmp/_cargo
|
||||||
|
- docker cp $CONTAINER_NAME:/tmp/_cargo /tmp/_cargo
|
||||||
|
- cache store v3-cargo-$(checksum Cargo.lock) /tmp/_cargo
|
@ -1,9 +0,0 @@
|
|||||||
language: rust
|
|
||||||
rust:
|
|
||||||
- stable
|
|
||||||
- beta
|
|
||||||
- nightly
|
|
||||||
services:
|
|
||||||
- mongodb
|
|
||||||
env:
|
|
||||||
- SKIP_SSL_CONNECTION_TESTS=true SKIP_EXTENDED_BULK_OPERATION_TESTS=true
|
|
@ -0,0 +1,8 @@
|
|||||||
|
use std::env;
|
||||||
|
|
||||||
|
pub fn mongodb_test_connection_string() -> &'static str {
|
||||||
|
match env::var("MONGODB_CONNECTION_STRING") {
|
||||||
|
Ok(value) => Box::leak(value.into_boxed_str()),
|
||||||
|
Err(_) => "mongodb://localhost:27017",
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue