Skip to content

Commit

Permalink
Merge pull request #60 from LCMApps/add-github-action-for-npm-releases
Browse files Browse the repository at this point in the history
Add GitHub action for NPM releases
  • Loading branch information
oleh-poberezhets authored Jan 23, 2020
2 parents 2496352 + e9dcb18 commit c6a34e2
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 183 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: NPM Release

on:
release:
types: [published, edited]

jobs:
check:
name: Check version and tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get package version
shell: bash
id: package_version
run: |
ver=$(jq .version package.json | sed -e "s/^\"//" -e "s/\"//")
echo "::set-output name=version::$ver"
- name: Compare package version and release tag
if: steps.package_version.outputs.version != github.event.release.tag_name
env:
TAG: "${{ github.event.release.tag_name }}"
PKG_VER: ${{ steps.package_version.outputs.version }}
run: |
echo "Mismatch NPM version $PKG_VER and git tag $TAG"
exit 1
build:
name: Lint and test
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install --frozen-lock-file
- run: yarn lint
- run: yarn tests

publish-npm:
name: Publish to NPM
needs: [check, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lock-file
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 1.0.4

IMPROVEMENTS:

- Dependencies was bumped

### 1.0.3

IMPROVEMENTS:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# dns-lookup-cache - DNS cache to replace NodeJS `dns.lookup` standard method

[![NPM version](https://img.shields.io/npm/v/dns-lookup-cache.svg)](https://www.npmjs.com/package/dns-lookup-cache)
[![Release Status](https://github.com/LCMApps/lcm-requester/workflows/NPM%20Release/badge.svg)](https://github.com/LCMApps/dns-lookup-cache/releases)
[![Build Status](https://travis-ci.org/LCMApps/dns-lookup-cache.svg?branch=master)](https://travis-ci.org/LCMApps/dns-lookup-cache)
[![Coverage Status](https://coveralls.io/repos/github/LCMApps/dns-lookup-cache/badge.svg?branch=master)](https://coveralls.io/github/LCMApps/dns-lookup-cache?branch=master)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dns-lookup-cache",
"version": "1.0.3",
"version": "1.0.4",
"description": "An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values",
"main": "index.js",
"engines": {
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Lookup/_innerResolve.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const dns = require('dns');
const sinon = require('sinon');
const {assert} = require('chai');

Expand Down Expand Up @@ -120,14 +121,14 @@ describe('Func: Lookup::_innerResolve', () => {
const firstRequestResult = lookup._innerResolve(addresses.INVALID_HOST, ipVersion)
.catch(err => {
assert.isPrototypeOf(err, Error);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.oneOf(err.code, [dns.NOTFOUND, dns.SERVFAIL]);
resolveErrorCount++;
});

const secondRequestResult = lookup._innerResolve(addresses.INVALID_HOST, ipVersion)
.catch(err => {
assert.isPrototypeOf(err, Error);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.oneOf(err.code, [dns.NOTFOUND, dns.SERVFAIL]);
resolveErrorCount++;
});

Expand Down
25 changes: 20 additions & 5 deletions tests/Functional/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@ describe("Func: must correct process 'hostname' param", () => {
it('must throw an error, cuz `hostname` param has invalid value', done => {
lookup(addresses.INVALID_HOST, error => {
assert.instanceOf(error, Error);
assert.strictEqual(error.code, dns.NOTFOUND);
/*
In Ubuntu 18.04 command:
$ host something.invalid
returns:
"Host something.invalid not found: 2(SERVFAIL)"
*/

assert.oneOf(error.code, [dns.NOTFOUND, dns.SERVFAIL]);
assert.strictEqual(error.hostname, addresses.INVALID_HOST);
assert.match(
error.message,
new RegExp(`${dns.NOTFOUND} ${addresses.INVALID_HOST}`)
);

if (error.code === dns.NOTFOUND) {
assert.match(
error.message,
new RegExp(`${dns.NOTFOUND} ${addresses.INVALID_HOST}`)
);
} else {
assert.match(
error.message,
new RegExp(`${dns.SERVFAIL} ${addresses.INVALID_HOST}`)
);
}

done();
});
Expand Down
Loading

0 comments on commit c6a34e2

Please sign in to comment.