Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
fix(ci): Switch to Jenkins and semantic-release
Browse files Browse the repository at this point in the history
Use Jenkins for CI and semantic-release for packaging.

Fixes: #110
  • Loading branch information
darinspivey committed Feb 4, 2022
1 parent 022edd6 commit 90ac36e
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 101 deletions.
99 changes: 0 additions & 99 deletions .circleci/config.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ logs
*.log
npm-debug.log*
package-lock.json
.tap-output

# Runtime data
pids
Expand Down
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ts: false
jsx: false
check-coverage: true
reporter: tap
output-file: .tap-output
jobs: 2
nyc-arg:
- --all=true
Expand Down
141 changes: 141 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
library 'magic-butler-catalogue'

def PROJECT_NAME = "nodejs-client-legacy"
def TRIGGER_PATTERN = ".*@logdnabot.*"
def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null}
def DEFAULT_BRANCH = 'master'
def CHANGE_ID = env.CHANGE_ID == null ? '' : env.CHANGE_ID

pipeline {
agent none

options {
timestamps()
ansiColor 'xterm'
}

triggers {
issueCommentTrigger(TRIGGER_PATTERN)
}

environment {
GITHUB_TOKEN = credentials('github-api-token')
NPM_TOKEN = credentials('npm-publish-token')
NPM_CONFIG_CACHE = '.npm'
NPM_CONFIG_USERCONFIG = '.npmrc'
SPAWN_WRAP_SHIM_ROOT = '.npm'
}

stages {
stage('Validate PR Source') {
when {
expression { env.CHANGE_FORK }
not {
triggeredBy 'issueCommentCause'
}
}
steps {
error("A maintainer needs to approve this PR for CI by commenting")
}
}

stage('Test Suite') {
matrix {
axes {
axis {
name 'NODE_VERSION'
values '12', '14', '15'
}
}

when {
not {
changelog '\\[skip ci\\]'
}
}

agent {
docker {
image "us.gcr.io/logdna-k8s/node:${NODE_VERSION}-ci"
}
}

stages {
stage('Test') {
steps {
sh "mkdir -p ${NPM_CONFIG_CACHE} coverage"
sh 'npm install'
sh 'npm run test:ci'
}

post {
always {
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 DEFAULT_BRANCH
}
}

agent {
docker {
image "us.gcr.io/logdna-k8s/node:14-ci"
customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}"
}
}

environment {
GIT_BRANCH = "${CURRENT_BRANCH}"
BRANCH_NAME = "${CURRENT_BRANCH}"
CHANGE_ID = ""
}

steps {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh 'npm install'
sh "npm run release:dry"
}
}

stage('Release') {
when {
beforeAgent true
branch DEFAULT_BRANCH
not {
changelog '\\[skip ci\\]'
}
}

agent {
docker {
image "us.gcr.io/logdna-k8s/node:14-ci"
customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}"
}
}

steps {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh 'npm install'
sh 'npm run release'
}
}
}
}
26 changes: 24 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "tap"
"test": "tap",
"pretest:ci": "npm run lint",
"test:ci": "tools/test-ci.sh",
"release": "semantic-release",
"release:dry": "semantic-release --dry-run --no-ci --branches=${BRANCH_NAME:-master}"
},
"files": [
"lib/",
"index.js",
"types.d.ts",
"README.md",
"LICENSE",
"CHANGELOG.md"
],
"repository": {
"type": "git",
"url": "git+https://github.com/logdna/nodejs.git"
Expand All @@ -28,6 +40,12 @@
"logger",
"javascript"
],
"release": {
"branches": [
"master"
],
"extends": "semantic-release-config-logdna"
},
"author": {
"name": "LogDNA Inc.",
"email": "help@logdna.com"
Expand Down Expand Up @@ -71,6 +89,10 @@
"mocha": "^5.2.0",
"nock": "^13.0.2",
"nyc": "^14.1.1",
"tap": "^14.10.7"
"semantic-release": "^17.4.7",
"semantic-release-config-logdna": "^1.3.0",
"tap": "^14.10.7",
"tap-parser": "^10.1.0",
"tap-xunit": "^2.4.1"
}
}
7 changes: 7 additions & 0 deletions tools/test-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
mkdir -p coverage
tap

code=$?
cat .tap-output | ./node_modules/.bin/tap-parser -t -f | ./node_modules/.bin/tap-xunit > coverage/test.xml
exit $code

0 comments on commit 90ac36e

Please sign in to comment.