Skip to content

Commit

Permalink
Add initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Nov 28, 2023
1 parent cf37b05 commit acae936
Show file tree
Hide file tree
Showing 26 changed files with 3,351 additions and 1 deletion.
81 changes: 81 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"ignorePatterns": [
"src/**"
],
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2022
},
"env": {
"node": true,
"es6": true
},
"rules": {
"arrow-parens": ["error", "always"],
"no-trailing-spaces": [
"error",
{
"skipBlankLines": true
}
],
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"operator-linebreak": [
"error",
"after",
{
"overrides": {
"?": "before",
":": "before"
}
}
],
"max-len": ["error", 110],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-multiple-empty-lines": ["error", { "max": 3, "maxEOF": 1, "maxBOF": 1 }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"space-before-blocks": ["error"],
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
"camelcase": ["error"],
"no-tabs": [0],
"global-require": [0],
"no-underscore-dangle": [0],
"no-plusplus": [0],
"no-shadow": [0],
"node/no-unpublished-require": [0],
"no-process-exit": [0],
"linebreak-style": [0],
"node/no-missing-require": [0],
"no-console": [0],
"node/no-unsupported-features/es-builtins": [
"error",
{ "version": ">=18.16.0" }
],
"node/no-unsupported-features/node-builtins": [
"error",
{ "version": ">=18.16.0" }
],
"func-names": [
"error",
"never",
{
"generators": "never"
}
]
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/binding.gyp linguist-vendored
src/include/** linguist-vendored
93 changes: 93 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build Binaries
defaults:
run:
shell: bash

on:
workflow_dispatch

jobs:
create_release:
name: Create Release
if: contains('["raub"]', github.actor)
runs-on: ubuntu-latest

outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Get Package Version
id: package-version
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT

- name: Create Draft Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}
body: Binaries at ${{ github.sha }}

build:
name: Build
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-11, [self-hosted, linux, ARM64]]

runs-on: ${{ matrix.os }}

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Install Modules
run: npm ci

- name: Fix Python
if: matrix.os == 'macos-11'
run: pip install setuptools

- name: Build Current Binary
run: npm run build

- name: Get Package Version
id: package-version
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT

- name: Pack Files
id: pack-files
run: node -e "require('addon-tools-raub').actionPack()" >> $GITHUB_OUTPUT

- name: Store Binaries
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}
files: ${{ steps.pack-files.outputs.pack }}
46 changes: 46 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Cpplint
defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
eslint:
name: Cpplint
runs-on: ubuntu-20.04

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Install Modules
run: npm ci

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Cpplint
run: pip install cpplint

- name: Run Cpplint
run: |
node -e "require('addon-tools-raub').cpcpplint()"
cpplint --recursive ./src/cpp
36 changes: 36 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ESLint
defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
eslint:
name: ESLint
runs-on: ubuntu-20.04

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Install Modules
run: npm ci

- name: Run ESLint
run: npm run eslint
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish to NPM
defaults:
run:
shell: bash

on:
workflow_dispatch

jobs:
Publish:
if: contains('["raub"]', github.actor)
runs-on: ubuntu-latest

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Get Package Version
id: package-version
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT

- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test
defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
unit-tests:
name: Unit Tests
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-11, [self-hosted, linux, ARM64]]

runs-on: ${{ matrix.os }}

steps:

- name: Fetch Repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.0
cache: 'npm'

- name: Install Modules
run: npm ci

- name: Fix Python
if: matrix.os == 'macos-11'
run: pip install setuptools

- name: Build Current Binary
run: npm run build

- name: Audio Device - Unix
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-11'
uses: LABSN/sound-ci-helpers@v1

- name: Audio Device - Windows
if: matrix.os == 'windows-2022'
shell: powershell
run: |
Start-Service audio*
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.6/Scream3.6.zip -OutFile C:\Scream3.6.zip
Extract-7Zip -Path C:\Scream3.6.zip -DestinationPath C:\Scream
$cert = (Get-AuthenticodeSignature C:\Scream\Install\driver\Scream.sys).SignerCertificate
$store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine")
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()
cd C:\Scream\Install\driver
C:\Scream\Install\helpers\devcon install Scream.inf *Scream
- name: Run Unit Tests
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'windows-2022' || matrix.os == 'macos-11'
run: npm test
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.cproject
.idea
.lock-wscript
.DS_Store
.project
.vscode
node_modules/
src/build/
src/node_modules/
bin-*/
*.log

0 comments on commit acae936

Please sign in to comment.