Skip to content

Instantly share code, notes, and snippets.

@m4nu56
Created November 12, 2019 10:25
Show Gist options
  • Save m4nu56/d0e0a5d8bde57551c2aa1fc3222e39b9 to your computer and use it in GitHub Desktop.
Save m4nu56/d0e0a5d8bde57551c2aa1fc3222e39b9 to your computer and use it in GitHub Desktop.
Pipeline tests nodejs+mongodb + integration tests avec postman
image: docker:19.03.1
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
PROJECT_IMAGE: registry.dev1-0.com/project
PROJECT_RELEASE_IMAGE: $PROJECT_IMAGE:$CI_COMMIT_REF_NAME
DOCKER_TLS_CERTDIR: ""
services:
- docker:19.03.1-dind
stages:
- test
- release
- integration_test
test:
stage: test
except:
- schedules
script:
- docker network rm projectnetwork || true && docker network create projectnetwork
- pwd
- docker run -d --name mongo-db --network flowbox -v /builds/project/mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js -e MONGO_INITDB_DATABASE='project' -e MONGO_INITDB_ROOT_USERNAME='root' -e MONGO_INITDB_ROOT_PASSWORD='root' mongo:4.0
- docker build --pull --network projectnetwork -t $PROJECT_RELEASE_IMAGE node/
- docker run -d --env-file node/.env_tests --network projectnetwork --name nodejs_test $PROJECT_RELEASE_IMAGE
- docker exec nodejs_test npm test
- docker stop nodejs_test && docker rm nodejs_test
- docker stop mongo-db || true
- docker network rm projectnetwork
release:
stage: release
except:
- schedules
before_script:
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token --password-stdin registry.domain.com
script:
- docker build --pull -t $PROJECT_RELEASE_IMAGE node/
- docker push $PROJECT_RELEASE_IMAGE
integration_test:
stage: integration_test
when: delayed
start_in: 5 minutes
image:
name: postman/newman_alpine33
entrypoint: [""]
script:
- cp node/src/assets/img.png /tmp/img.png
- newman run node/src/__tests__/postman/XXX.postman_collection.json --environment node/src/__tests__/postman/ci.postman_environment.json --insecure --timeout-request 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment