diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 265745f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,98 +0,0 @@ -version: 2.1 -tagged_build_filters: &tagged_build_filters - branches: - ignore: /.*/ - tags: - only: /v[0-9]+\.[0-9]+\.[0-9]+/ -test_build_filters: &test_build_filters - branches: - only: /.*/ - tags: - ignore: /v[0-9]+\.[0-9]+\.[0-9]+/ -jobs: - test: - docker: - - image: circleci/node:10 - steps: - - checkout - - run: npm install - - run: npm run lint - build: - docker: - - image: circleci/node:10 - steps: - - checkout - - run: - name: Check Tagged Push - command: | - PKG_VERSION=$(grep version package.json | cut -d'"' -f4) - if [[ "${CIRCLE_TAG}" != "v${PKG_VERSION}" ]]; then - echo "There is mismatch:" - echo " TAG_VERSION: ${CIRCLE_TAG}" - echo " PKG_VERSION: v${PKG_VERSION}" - exit 1 - fi - - run: npm install --production - - run: zip logdna-winston.zip -r node_modules/ index.js package.json - - persist_to_workspace: - root: . - paths: - - ./logdna-winston.zip - release: - docker: - - image: circleci/golang:1.12 - steps: - - attach_workspace: - at: . - - run: go get -u github.com/tcnksm/ghr - - run: - name: Create a Release - command: | - ghr \ - -n "LogDNA Winston Support ${CIRCLE_TAG}" \ - -t ${GITHUB_TOKEN} \ - -u ${CIRCLE_PROJECT_USERNAME} \ - -r ${CIRCLE_PROJECT_REPONAME} \ - -draft ${CIRCLE_TAG} ./logdna-winston.zip - approve: - machine: true - steps: - - attach_workspace: - at: . - - persist_to_workspace: - root: . - paths: - - ./logdna-winston.zip - publish: - docker: - - image: circleci/node:10 - steps: - - checkout - - run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc - - run: npm publish -workflows: - update: - jobs: - - test: - filters: *tagged_build_filters - - build: - requires: - - test - filters: *tagged_build_filters - - release: - requires: - - build - filters: *tagged_build_filters - - approve: - type: approval - requires: - - release - filters: *tagged_build_filters - - publish: - requires: - - approve - filters: *tagged_build_filters - test: - jobs: - - test: - filters: *test_build_filters diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e919261 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,149 @@ +library 'magic-butler-catalogue' + +def projectName = "logdna-winston" +def repo = "logdna/${projectName}" + +pipeline { + agent none + + options { + timestamps() + ansiColor 'xterm' + } + + stages { + stage('Test Suite') { + matrix { + axes { + axis { + name 'NODE_VERSION' + values '10', '12', '14' + } + } + + agent { + docker { + image "us.gcr.io/logdna-k8s/node:${NODE_VERSION}-ci" + } + } + + environment { + NPM_CONFIG_CACHE = '.npm' + NPM_CONFIG_USERCONFIG = '.npm/rc' + SPAWN_WRAP_SHIM_ROOT = '.npm' + } + + stages { + stage('Install') { + environment { + GITHUB_PACKAGES_TOKEN = credentials('github-api-token') + } + + steps { + sh 'mkdir -p .npm' + + script { + npm.auth token: "${GITHUB_PACKAGES_TOKEN}" + } + + sh """ + npm install + """ + } + } + + stage('Test') { + steps { + sh 'node -v' + sh 'npm -v' + sh 'npm test' + } + + post { + always { + sh 'cat .tap-output | ./node_modules/.bin/tap-mocha-reporter xunit > coverage/test.xml' + + junit 'coverage/test.xml' + + publishHTML target: [ + allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'coverage/lcov-report', + reportFiles: 'index.html', + reportName: "coverage-node-v${NODE_VERSION}" + ] + } + } + } + } + } + } + + stage('Test Release') { + when { + beforeAgent true + not { + branch 'master' + } + } + + agent { + docker { + image "us.gcr.io/logdna-k8s/node:12-ci" + } + } + + environment { + NPM_CONFIG_CACHE = '.npm' + NPM_CONFIG_USERCONFIG = '.npm/rc' + SPAWN_WRAP_SHIM_ROOT = '.npm' + GITHUB_PACKAGES_TOKEN = credentials('github-api-token') + } + + steps { + sh 'mkdir -p .npm' + + versioner( + token: "${GITHUB_PACKAGES_TOKEN}" + , dry: true + , repo: repo + ) + } + } + + stage('Release') { + when { + beforeAgent true + branch 'master' + } + + agent { + docker { + image "us.gcr.io/logdna-k8s/node:12-ci" + } + } + + environment { + GITHUB_PACKAGES_TOKEN = credentials('github-api-token') + NPM_PUBLISH_TOKEN = credentials('npm-publish-token') + NPM_CONFIG_CACHE = '.npm' + NPM_CONFIG_USERCONFIG = '.npm/rc' + SPAWN_WRAP_SHIM_ROOT = '.npm' + } + + steps { + sh 'mkdir -p .npm' + + sh "git checkout -b ${GIT_BRANCH} origin/${GIT_BRANCH}" + + versioner( + token: "${GITHUB_PACKAGES_TOKEN}" + , dry: false + , repo: repo + , NPM_PUBLISH_TOKEN: "${NPM_PUBLISH_TOKEN}" + ) + } + } + } +}