Skip to content

Commit

Permalink
node-addon-api (n-api) instead NAN (#14)
Browse files Browse the repository at this point in the history
* Remove inherits & safe-buffer

* Add hooks via husky

* Add clang-format

* Make code more es6

* Update dev dependencies

* Use n-api instead nan

* Update years in LICENSE file

* Remove appveyor and travis

* Remove husky

* Use prebuildify instead node-gyp

* Add lint workflow for GH Actions

* Add test workflow for GH Actions

* Build package for publishing in GitHub Actions

* Adjust README
  • Loading branch information
fanatid authored Dec 28, 2019
1 parent 06710bc commit 18befd9
Show file tree
Hide file tree
Showing 29 changed files with 602 additions and 284 deletions.
111 changes: 111 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
105 changes: 105 additions & 0 deletions .github/workflows/build-test-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build addon, run tests and package

on:
push:
pull_request:

jobs:
build-and-test:
name: Build addon
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- name: Fetch code
uses: actions/checkout@v1
with:
submodules: true

- name: Install dependencies
run: yarn install --ignore-scripts

- name: Build addon
run: make build-addon

- name: Get minimal Node.js version from package.json (Linux & macOS)
id: node-version-nix
if: runner.os != 'Windows'
run: echo "::set-output name=version::$(node -p 'require("./package.json").engines.node.match(/(\d.*)$/)[0]')"

- name: Use Node.js ${{ steps.node-version-nix.outputs.version }} (Linux & macOS)
if: runner.os != 'Windows'
uses: actions/setup-node@v1
with:
node-version: ${{ steps.node-version-nix.outputs.version }}

- name: Get minimal Node.js version from package.json (Windows)
id: node-version-win
if: runner.os == 'Windows'
run: echo "::set-output name=version::$(node -p 'require(\"./package.json\").engines.node.match(/(\d.*)$/)[0]')"

- name: Use Node.js ${{ steps.node-version-win.outputs.version }} (Windows)
if: runner.os == 'Windows'
uses: actions/setup-node@v1
with:
node-version: ${{ steps.node-version-win.outputs.version }}

- name: Run tests for addon
run: make test-tap

- name: Upload prebuilds
uses: actions/upload-artifact@v1
with:
name: addon-${{ runner.os }}
path: prebuilds

package:
name: Build package
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Fetch code
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install dependencies
run: yarn install --ignore-scripts

- name: Download macOS addon
uses: actions/download-artifact@v1
with:
name: addon-macOS

- name: Download Linux addon
uses: actions/download-artifact@v1
with:
name: addon-Linux

- name: Download Windows addon
uses: actions/download-artifact@v1
with:
name: addon-Windows

- name: Move addons to one folder
run: mkdir prebuilds && mv ./addon-*/* ./prebuilds/

- name: list
run: find prebuilds

- name: Build package
run: make package

- name: Get package version from package.json
id: pkg-version
run: echo "::set-output name=version::$(node -p 'require("./package.json").version')"

- name: Upload package
uses: actions/upload-artifact@v1
with:
name: package
path: keccak-${{ steps.pkg-version.outputs.version }}.tgz
45 changes: 45 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint C/C++ and JS code

on:
push:
pull_request:

jobs:
cpp:
name: Lint C/C++ code
runs-on: ubuntu-latest
steps:
- name: Fetch code
uses: actions/checkout@v1
with:
fetch-depth: 1

- uses: actions/cache@v1
id: cache
with:
path: clang
key: clang-llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04

- name: Download clang-format
if: steps.cache.outputs.cache-hit != 'true'
run: wget -O- -q http://releases.llvm.org/9.0.0/$VER.tar.xz | tar xfJ - $VER/bin/clang-format && mv $VER clang
env:
VER: clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04

- name: Run lint command
run: PATH=$PATH:./clang/bin/ make lint-cpp-ci

js:
name: Lint JS code
runs-on: ubuntu-latest
steps:
- name: Fetch code
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install dependencies
run: yarn install --ignore-scripts

- name: Run lint command
run: make lint-js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
coverage
build
node_modules
prebuilds

npm-debug.log
package-lock.json
Expand Down
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 https://github.com/cryptocoinjs/keccak contributors
Copyright (c) 2016-2019 https://github.com/cryptocoinjs/keccak contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 18befd9

Please sign in to comment.