File tree 17 files changed +245
-36
lines changed
17 files changed +245
-36
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
2
+ .git
3
+ .gitignore
4
+ TEST-RESULTS.xml
Original file line number Diff line number Diff line change 2
2
logs
3
3
* .log
4
4
npm-debug.log *
5
- yarn-debug.log *
6
- yarn-error.log *
7
5
8
6
# Runtime data
9
7
pids
10
8
* .pid
11
9
* .seed
12
- * .pid.lock
13
10
14
11
# Directory for instrumented libs generated by jscoverage/JSCover
15
12
lib-cov
16
13
17
14
# Coverage directory used by tools like istanbul
18
15
coverage
19
16
20
- # nyc test coverage
21
- .nyc_output
22
-
23
17
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24
18
.grunt
25
19
26
- # Bower dependency directory (https://bower.io/)
27
- bower_components
28
-
29
20
# node-waf configuration
30
21
.lock-wscript
31
22
32
- # Compiled binary addons (https ://nodejs.org/api/addons.html)
23
+ # Compiled binary addons (http ://nodejs.org/api/addons.html)
33
24
build /Release
34
25
35
- # Dependency directories
36
- node_modules /
37
- jspm_packages /
38
-
39
- # TypeScript v1 declaration files
40
- typings /
41
-
42
- # Optional npm cache directory
43
- .npm
44
-
45
- # Optional eslint cache
46
- .eslintcache
47
-
48
- # Optional REPL history
49
- .node_repl_history
50
-
51
- # Output of 'npm pack'
52
- * .tgz
53
-
54
- # Yarn Integrity file
55
- .yarn-integrity
56
-
57
- # dotenv environment variables file
58
- .env
26
+ # Dependency directory
27
+ # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
28
+ node_modules
29
+ /package-lock.json
59
30
60
- # next.js build output
61
- .next
31
+ TEST-RESULTS.xml
Original file line number Diff line number Diff line change
1
+ # Build Docker image for this app
2
+ # https://docs.microsoft.com/vsts/pipelines/languages/docker?view=vsts
3
+
4
+ queue : ' Hosted Linux Preview'
5
+
6
+ variables :
7
+ imageName : ' $(Build.DefinitionName):$(Build.BuildId)'
8
+ # define two more variables dockerId and dockerPassword in the build pipeline in UI
9
+
10
+ steps :
11
+ - script : |
12
+ npm install
13
+ npm test
14
+ docker build -t $(dockerId).azurecr.io/$(imageName) .
15
+ docker login -u $(dockerId).azurecr.io -p $pswd $(dockerId).azurecr.io
16
+ docker push $(dockerId).azurecr.io/$(imageName)
17
+ env :
18
+ pswd : $(dockerPassword)
19
+
20
+ - task : PublishTestResults@2
21
+ inputs :
22
+ testRunner : JUnit
23
+ testResultsFiles : ' **/TEST-RESULTS.xml'
Original file line number Diff line number Diff line change
1
+ # Build Docker image for this app
2
+ # https://docs.microsoft.com/vsts/pipelines/languages/docker?view=vsts
3
+
4
+ queue : ' Hosted Linux Preview'
5
+
6
+ variables :
7
+ imageName : ' $(Build.DefinitionName):$(Build.BuildId)'
8
+ # define two more variables dockerId and dockerPassword in the build pipeline in UI
9
+
10
+ steps :
11
+ - script : |
12
+ npm install
13
+ npm test
14
+ docker build -t $(dockerId)/$(imageName) .
15
+ docker login -u $(dockerId) -p $pswd
16
+ docker push $(dockerId)/$(imageName)
17
+ env :
18
+ pswd : $(dockerPassword)
19
+
20
+ - task : PublishTestResults@2
21
+ inputs :
22
+ testRunner : JUnit
23
+ testResultsFiles : ' **/TEST-RESULTS.xml'
Original file line number Diff line number Diff line change
1
+ # Build NodeJS Express app using VSTS
2
+ # https://docs.microsoft.com/vsts/pipelines/languages/javascript?view=vsts
3
+
4
+ queue : ' Hosted Linux Preview'
5
+
6
+ steps :
7
+ - script : |
8
+ npm install
9
+ npm test
10
+
11
+ - task : PublishTestResults@2
12
+ inputs :
13
+ testRunner : JUnit
14
+ testResultsFiles : ' **/TEST-RESULTS.xml'
15
+
16
+ - task : ArchiveFiles@2
17
+ inputs :
18
+ rootFolderOrFile : ' $(System.DefaultWorkingDirectory)'
19
+ includeRootFolder : false
20
+
21
+ - task : PublishBuildArtifacts@1
Original file line number Diff line number Diff line change
1
+ # Create a container image for the NodeJS sample app
2
+ # See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3
+ FROM node:boron
4
+
5
+ # Create app directory
6
+ WORKDIR /app
7
+
8
+ # Copy files
9
+ COPY . .
10
+
11
+ # Install app dependencies
12
+ RUN npm install
13
+
14
+ EXPOSE 3000 80
15
+ CMD ["npm" , "start" ]
Original file line number Diff line number Diff line change
1
+ * text =auto
2
+ * .sh text eol =lf
Original file line number Diff line number Diff line change
1
+ # First stage of multi-stage build
2
+ FROM node:boron
3
+ WORKDIR /app
4
+
5
+ # copy the contents of agent working directory on host to workdir in container
6
+ COPY . .
7
+
8
+ # dotnet commands to build, test, and publish
9
+ RUN npm install
10
+ RUN npm test
11
+
12
+ # Second stage - Build runtime image
13
+ FROM node:boron
14
+ WORKDIR /app
15
+ COPY . .
16
+ RUN npm install
17
+ EXPOSE 3000 80
18
+ CMD ["npm", "start"]
Original file line number Diff line number Diff line change
1
+ # This Dockerfile is for a test container to demonstrate use of docker-compose with VSTS or TFS
2
+ # See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3
+
4
+ FROM ubuntu:trusty
5
+ RUN apt-get update && apt-get install -yq curl && apt-get clean
6
+ WORKDIR /app
7
+ ADD docs/test.sh /app/test.sh
8
+ CMD ["bash", "test.sh"]
Original file line number Diff line number Diff line change
1
+ # Script to deploy the app
2
+ # This file is needed only when you want to deploy the app to a Linux VM
3
+
4
+ # install node
5
+ pushd .
6
+ cd ~
7
+ curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
8
+ sudo bash nodesource_setup.sh
9
+ sudo apt-get install nodejs -y
10
+ sudo apt-get install build-essential -y
11
+
12
+ # install express
13
+ sudo npm install express -y -g
14
+ popd
15
+
16
+ # configure nginx
17
+ sudo rm -f /etc/nginx/sites-enabled/default
18
+ sudo cp -f ./nginx-config /etc/nginx/sites-available/example
19
+ sudo ln -fs /etc/nginx/sites-available/example /etc/nginx/sites-enabled
20
+ sudo service nginx reload
21
+
22
+ # install pm2 and start the node server as a daemon
23
+ cd ..
24
+ sudo npm install pm2 -g -y
25
+ pm2 delete example -s
26
+ pm2 start server.js -n example
Original file line number Diff line number Diff line change
1
+ # Docker compose file to bring up app and test containers
2
+ # See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3
+ sut :
4
+ build : .
5
+ dockerfile : docs/Dockerfile.test
6
+ links :
7
+ - web
8
+ web :
9
+ build : .
10
+ dockerfile : Dockerfile
Original file line number Diff line number Diff line change
1
+ server {
2
+ server_name your.domain.com;
3
+ listen 80;
4
+
5
+ location / {
6
+ proxy_set_header X-Real-IP $remote_addr;
7
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
8
+ proxy_set_header Host $http_host;
9
+ proxy_set_header X-NginX-Proxy true;
10
+ proxy_pass http://127.0.0.1:3000;
11
+ proxy_redirect off;
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ # Test driver script to be used in a container
2
+ # See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3
+ sleep 5
4
+ if curl web | grep -q ' Hello world' ; then
5
+ echo " Tests passed!"
6
+ exit 0
7
+ else
8
+ echo " Tests failed!"
9
+ exit 1
10
+ fi
11
+
Original file line number Diff line number Diff line change
1
+ var gulp = require ( 'gulp' ) ;
2
+ var mocha = require ( 'gulp-mocha' ) ;
3
+ var fs = require ( 'fs' ) ;
4
+
5
+ gulp . task ( 'default' , function ( ) {
6
+ gulp . src ( 'tests/**/*.js' )
7
+ . pipe ( mocha ( {
8
+ reporter : 'mocha-junit-reporter' ,
9
+ reporterOptions : {
10
+ mochaFile : './TEST-RESULTS.xml'
11
+ }
12
+ } ) ) ;
13
+ } ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " HelloWorld" ,
3
+ "private" : true ,
4
+ "version" : " 0.0.0" ,
5
+ "description" : " Hello World" ,
6
+ "main" : " server.js" ,
7
+ "author" : {
8
+ "name" : " " ,
9
+ "email" : " "
10
+ },
11
+ "dependencies" : {
12
+ "express" : " ^4.13.3" ,
13
+ "mocha" : " ^3.0.0"
14
+ },
15
+ "devDependencies" : {
16
+ "gulp" : " ^3.9.0" ,
17
+ "gulp-mocha" : " ^2.2.0" ,
18
+ "mocha-junit-reporter" : " ^1.12.0"
19
+ },
20
+ "scripts" : {
21
+ "test" : " ./node_modules/.bin/mocha tests/**/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=./TEST-RESULTS.xml"
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const express = require ( 'express' ) ;
4
+
5
+ // Constants
6
+ const PORT = 3000 ;
7
+ const HOST = '0.0.0.0' ;
8
+
9
+ // App
10
+ const app = express ( ) ;
11
+ app . get ( '/' , ( req , res ) => {
12
+ res . send ( 'Hello Node.js Sample!\n' ) ;
13
+ } ) ;
14
+
15
+ var port = process . env . PORT || PORT ;
16
+ app . listen ( port ) ;
17
+ console . log ( `Running on http://${ HOST } :${ PORT } ` ) ;
Original file line number Diff line number Diff line change
1
+ var assert = require ( 'assert' ) ;
2
+
3
+ describe ( 'String' , function ( ) {
4
+ describe ( '#indexOf' , function ( ) {
5
+ it ( 'should return -1 when the substring is not present' , function ( ) {
6
+ var myString = 'test' ;
7
+
8
+ assert . equal ( - 1 , myString . indexOf ( 'x' ) ) ;
9
+ assert . equal ( - 1 , myString . indexOf ( 'y' ) ) ;
10
+ } ) ;
11
+ } ) ;
12
+ } ) ;
You can’t perform that action at this time.
0 commit comments