Skip to content

Commit

Permalink
Add Jenkins file for JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sprsquish committed Aug 10, 2018
1 parent e4e6a23 commit b192cd3
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -34,5 +34,5 @@ docker-wait:
dockerize -wait $(FAUNA_SCHEME)://$(FAUNA_DOMAIN):$(FAUNA_PORT)/ping -timeout $(FAUNA_TIMEOUT)

docker-test:
docker build -f Dockerfile.test -t faunadb-js-test:latest --build-arg RUNTIME_IMAGE=$(RUNTIME_IMAGE) .
docker build -f test/Dockerfile -t faunadb-js-test:latest --build-arg RUNTIME_IMAGE=$(RUNTIME_IMAGE) .
docker run $(DOCKER_RUN_FLAGS) faunadb-js-test:latest
File renamed without changes.
97 changes: 97 additions & 0 deletions test/Jenkinsfile
@@ -0,0 +1,97 @@
def notify = new com.fauna.jenkins.Notify(this, env, currentBuild, 'drivers', 'Drivers', '#eng-notify')

pipeline {
agent {
node { label 'drivers' }
}

stages {
stage('Run JS Tests') {
when {
changeset 'js/**'
}

stages {
stage('Setup') {
environment {
GCP_DOCKER_AUTH = credentials('gcp-jenkins-auth')
}

steps {
sh 'sudo docker login -u _json_key --password-stdin https://gcr.io < `echo $GCP_DOCKER_AUTH`'

script { notify.started() }
}
}

stage("Node v4") {
steps {
sh "sed -i'' 's/CORE_IMAGE_REPLACE/gcr.io\\/faunadb-cloud\\/faunadb\\/developer:latest/g' js/test/docker-compose.yml"
sh "sed -i'' 's/RUNTIME_IMAGE_REPLACE/node:4-alpine/g' js/test/docker-compose.yml"
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" pull'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" build driver_test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" run -T driver_test make docker-wait jenkins-test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" rm -f -s -v'
}
}

stage("Node v6") {
steps {
sh "sed -i'' 's/CORE_IMAGE_REPLACE/gcr.io\\/faunadb-cloud\\/faunadb\\/developer:latest/g' js/test/docker-compose.yml"
sh "sed -i'' 's/RUNTIME_IMAGE_REPLACE/node:6-alpine/g' js/test/docker-compose.yml"
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" pull'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" build driver_test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" run -T driver_test make docker-wait jenkins-test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" rm -f -s -v'
}
}

stage("Node v8") {
steps {
sh "sed -i'' 's/CORE_IMAGE_REPLACE/gcr.io\\/faunadb-cloud\\/faunadb\\/developer:latest/g' js/test/docker-compose.yml"
sh "sed -i'' 's/RUNTIME_IMAGE_REPLACE/node:8-alpine/g' js/test/docker-compose.yml"
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" pull'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" build driver_test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" run -T driver_test make docker-wait jenkins-test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" rm -f -s -v'
}
}

stage("Node v10") {
steps {
sh "sed -i'' 's/CORE_IMAGE_REPLACE/gcr.io\\/faunadb-cloud\\/faunadb\\/developer:latest/g' js/test/docker-compose.yml"
sh "sed -i'' 's/RUNTIME_IMAGE_REPLACE/node:10-alpine/g' js/test/docker-compose.yml"
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" pull'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" build driver_test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" run -T driver_test make docker-wait jenkins-test'
sh 'sudo docker-compose -f "$WORKSPACE/js/test/docker-compose.yml" rm -f -s -v'
}
}

stage('Publish code coverage') {
steps {
sh 'bash <(curl -s https://codecov.io/bash) -R js -e driver_runtime,core_version'
}
}
}
}
}

post {
always {
junit 'js/test/results/report.xml'
}

aborted {
script { notify.aborted() }
}

failure {
script { notify.failed() }
}

success {
script { notify.succeeded() }
}
}
}
22 changes: 22 additions & 0 deletions test/docker-compose.yml
@@ -0,0 +1,22 @@
---
version: "3"
services:
core:
image: "CORE_IMAGE_REPLACE"
driver_test:
build:
context: '..'
dockerfile: "./test/Dockerfile"
args:
RUNTIME_IMAGE: "RUNTIME_IMAGE_REPLACE"
depends_on:
- core
environment:
FAUNA_ROOT_KEY: secret
FAUNA_DOMAIN: core
FAUNA_SCHEME: http
FAUNA_PORT: 8443
FAUNA_TIMEOUT: 60s
volumes:
- ./results:/fauna/faunadb-js/results
- ./coverage:/fauna/faunadb-js/coverage

0 comments on commit b192cd3

Please sign in to comment.