Skip to content

Commit

Permalink
ci: add commitlint tooling and config
Browse files Browse the repository at this point in the history
This brings in the standardized commitlint config, along with some
tidying up of dependencies and Jenkins moderization.

Closes #7
  • Loading branch information
mdeltito committed Jun 29, 2022
1 parent e44acb1 commit 56f4c8b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 69 deletions.
18 changes: 0 additions & 18 deletions .taprc

This file was deleted.

85 changes: 46 additions & 39 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
library 'magic-butler-catalogue'

def PROJECT_NAME = "pino-logdna"
def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null}
def REPO = "logdna/${PROJECT_NAME}"
def TRIGGER_PATTERN = ".*@logdnabot.*"
def DEFAULT_BRANCH = 'main'
def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null}

pipeline {
agent none
agent {
node {
label 'ec2-fleet'
customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}"
}
}

options {
timestamps()
Expand All @@ -16,6 +23,13 @@ pipeline {
issueCommentTrigger(TRIGGER_PATTERN)
}

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

stages {
stage('Validate PR Source') {
when {
Expand All @@ -34,35 +48,30 @@ pipeline {
axes {
axis {
name 'NODE_VERSION'
values '12', '14', '15'
values '12', '14', '16', '18'
}
}

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

environment {
GITHUB_TOKEN = credentials('github-api-token')
NPM_CONFIG_CACHE = '.npm'
NPM_CONFIG_USERCONFIG = '.npm/rc'
SPAWN_WRAP_SHIM_ROOT = '.npm'
}

stages {

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

post {
always {
junit 'coverage/test.xml'
junit checksName: 'Test Results', testResults: 'coverage/*.xml'

publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
Expand All @@ -80,66 +89,64 @@ pipeline {

stage('Test Release') {
when {
beforeAgent true
not {
branch 'main'
branch DEFAULT_BRANCH
}
}

agent {
docker {
image "us.gcr.io/logdna-k8s/node:12-ci"
label 'ec2-fleet'
image "us.gcr.io/logdna-k8s/node:16-ci"
customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}"
}
}

environment {
GITHUB_TOKEN = credentials('github-api-token')
NPM_TOKEN = credentials('npm-publish-token')
NPM_CONFIG_CACHE = '.npm'
NPM_CONFIG_USERCONFIG = '.npm/rc'
SPAWN_WRAP_SHIM_ROOT = '.npm'
GIT_BRANCH = "${CURRENT_BRANCH}"
BRANCH_NAME = "${CURRENT_BRANCH}"
CHANGE_ID = ""
NPM_TOKEN = credentials('npm-publish-token')
}

steps {
sh 'mkdir -p .npm'
sh 'npm install'
sh "npm run release -- --dry-run --no-ci --branches ${CURRENT_BRANCH}"
script {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh 'npm install'
sh "npm run release:dry"
}
}
}

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

agent {
docker {
image "us.gcr.io/logdna-k8s/node:12-ci"
label 'ec2-fleet'
image "us.gcr.io/logdna-k8s/node:16-ci"
customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}"
}
}

environment {
GITHUB_TOKEN = credentials('github-api-token')
GIT_BRANCH = "${CURRENT_BRANCH}"
BRANCH_NAME = "${CURRENT_BRANCH}"
CHANGE_ID = ""
NPM_TOKEN = credentials('npm-publish-token')
NPM_CONFIG_CACHE = '.npm'
NPM_CONFIG_USERCONFIG = '.npm/rc'
SPAWN_WRAP_SHIM_ROOT = '.npm'
GIT_AUTHOR_NAME = 'LogDNA Bot'
GIT_AUTHOR_EMAIL = '[email protected]'
GIT_COMMITTER_NAME = 'LogDNA Bot'
GIT_COMMITTER_EMAIL = '[email protected]'
}

steps {
sh 'mkdir -p .npm'
sh 'npm install'
sh 'npm run release'
script {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh 'npm install'
sh 'npm run release'
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- [Options](#options)
- [Legacy Transport](#legacy-transport)
- [CLI Options](#cli-options)
- [Contributing](#contributing)
- [Commit Format](#commit-format)
- [Contributors ✨](#contributors-)
- [License](#license)

Expand Down Expand Up @@ -100,6 +102,20 @@ Options:
-p, --proxy The full URL of an http or https proxy to pass through
```
## Contributing
This project is open-sourced, and accepts PRs from the public for bugs or feature
enhancements. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
### Commit Format
The project uses [Commitlint][] and enforces [Conventional Commit Standard][]. Please format your commits based on these guidelines.
An [issue must be opened](https://github.com/logdna/tail-file-node/issues) in the repository for any bug, feature, or anything else that will have a PR.
The commit message must reference the issue with an [acceptable action tag](https://github.com/logdna/commitlint-config/blob/41aef3b69f292e39fb41a5ef24bcd7043e0fceb3/index.js#L12-L20) in the commit footer, e.g. `Fixes: #5`.


## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down Expand Up @@ -131,3 +147,5 @@ Copyright © [LogDNA](https://logdna.com), released under an MIT license. See th
[legacy transport]: https://getpino.io/#/docs/transports?id=legacy-transports
[`@logdna/logger`]: https://github.com/logdna/logger-node#api
[`createLogger` options]: https://github.com/logdna/logger-node#createloggerkey-options
[Commitlint]: https://commitlint.js.org
[Conventional Commit Standard]: https://www.conventionalcommits.org/en/v1.0.0/
51 changes: 43 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"tap": "tap",
"lint": "eslint ./",
"lint:fix": "npm run lint -- --fix",
"commitlint": "commitlint --from=origin/main --to=HEAD",
"test": "tap",
"test:ci": "tools/test-ci.sh",
"test:watch": "tap --no-coverage-report -w",
"pretest": "npm run lint",
"pretest": "npm run lint && npm run commitlint",
"pretest:ci": "npm run lint",
"release": "semantic-release"
"release": "semantic-release",
"release:dry": "semantic-release --dry-run --no-ci --branches ${BRANCH_NAME:-main}"
},
"release": {
"branches": [
Expand All @@ -43,8 +45,8 @@
"pino"
],
"author": {
"name": "LogDNA, Inc.",
"email": "help@logdna.com"
"name": "Mike Del Tito.",
"email": "mike.deltito@mezmo.com"
},
"license": "SEE LICENSE IN LICENSE",
"bugs": {
Expand All @@ -57,12 +59,13 @@
"pino-abstract-transport": "^0.5.0"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-logdna": "^5.1.0",
"@logdna/commitlint-config": "^2.0.0",
"eslint": "^8.18.0",
"eslint-config-logdna": "^6.1.0",
"execa": "^4.1.0",
"pino": "^7.0.5",
"semantic-release": "^17.3.9",
"semantic-release-config-logdna": "^1.1.0",
"semantic-release": "^17.4.7",
"semantic-release-config-logdna": "^1.3.0",
"tap": "^15.0.10",
"tap-parser": "^10.1.0",
"tap-xunit": "^2.4.1"
Expand All @@ -79,5 +82,37 @@
"parserOptions": {
"ecmaVersion": 2020
}
},
"commitlint": {
"extends": [
"@logdna/commitlint-config"
]
},
"tap": {
"100": true,
"ts": false,
"jsx": false,
"check-coverage": true,
"jobs": 1,
"timeout": 60,
"browser": false,
"coverage-report": [
"text",
"text-summary",
"json",
"json-summary",
"html"
],
"reporter": "tap",
"nyc-arg": [
"--exclude=test/",
"--exclude=tools/",
"--exclude=coverage/",
"--all"
],
"files": [
"test/**/*.js"
],
"output-file": ".tap"
}
}
3 changes: 2 additions & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ test('cli', async (t) => {
t.match(
err.message
, "invalid: [ [ 'url', 'invalid-url' ], [ 'timeout', 'invalid-timeout' ]"
, 'error includes list of invalid options')
, 'error includes list of invalid options'
)
}
})

Expand Down
9 changes: 6 additions & 3 deletions test/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ test('pinoLogdna', async (t) => {
t.equal(
body.ls[0].meta
, `{"pid":${process.pid},"foo":"bar","hostname":"test.local"}`
, 'unindexed meta contains expected properties')
, 'unindexed meta contains expected properties'
)
t.ok(query.now, 'timestamp present in query')
t.equal(query.hostname, oshost, 'os.hostname present in query')
})
Expand Down Expand Up @@ -170,7 +171,8 @@ test('pinoLogdna', async (t) => {
t.equal(
body.ls[0].meta
, `{"pid":${process.pid},"foo":"bar","hostname":"${oshost}"}`
, 'unindexed meta contains expected properties')
, 'unindexed meta contains expected properties'
)
t.ok(query.now, 'timestamp present in query')
t.equal(query.hostname, oshost, 'os.hostname present in query')
})
Expand Down Expand Up @@ -215,7 +217,8 @@ test('pinoLogdna', async (t) => {
t.equal(
body.ls[0].meta
, `{"pid":${process.pid},"foo":"bar","hostname":"${oshost}"}`
, 'unindexed meta contains expected properties')
, 'unindexed meta contains expected properties'
)
t.ok(query.now, 'timestamp present in query')
t.equal(query.hostname, oshost, 'os.hostname present in query')
})
Expand Down

0 comments on commit 56f4c8b

Please sign in to comment.