diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..2361617 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,31 @@ +name: Node CI +on: + push: + branches: + - develop + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm install mocha -g + mocha --version + npm install --save-dev chai + mocha exit + env: + CI: true diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..cac421b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,8 @@ +node('docker') { + stage('SCM') { + checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: 'refs/heads/develop']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/CodeBabel/MEANStackApp.git']]] + } + stage('SonarQube Analysis') { + sh "/home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqubescanner/bin/sonar-scanner -Dsonar.host.url=http://192.168.0.14:9000 -Dsonar.projectName=meanstackapp -Dsonar.projectVersion=1.0 -Dsonar.projectKey=meanstack:app -Dsonar.sources=. -Dsonar.projectBaseDir=/home/jenkins/workspace/sonarqube_test_pipeline" + } + } diff --git a/app/app.js b/app/app.js index c1a3533..73b146b 100644 --- a/app/app.js +++ b/app/app.js @@ -10,4 +10,4 @@ angular.module('app').controller('testCtrl', function($scope, $resource) { //$scope.authors = [{name: 'Ravindranath Barathy', role:'Admin1'},{name: 'Kaviya Kulothungan', role:'Admin2'},{name: 'Vivek Cherarajan', role:'Admin3'}]; $scope.authors = $resource('/api/authors').query(); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 0e2b214..48f3a54 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Sample Dashboard App", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "mocha 'test/**/*.js' --recursive --timeout 60000 --exit" }, "author": "Kaviya Kulothungan", "license": "ISC",