Skip to content

Commit

Permalink
Merge pull request #17 from sombriks/test-release-strategy
Browse files Browse the repository at this point in the history
Test release strategy
  • Loading branch information
sombriks committed Nov 21, 2023
2 parents bd5ff55 + 8a23a60 commit d58efba
Show file tree
Hide file tree
Showing 12 changed files with 1,885 additions and 124 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Tests

on:
push:
branches: [ "*" ]

jobs:
build-and-publish:
runs-on: ubuntu-latest
strategy:
matrix:
# removing '14.x', for now
version: ['16.x', '18.x', '20.x']
steps:
- name: Install libgpiod
run: |
sudo apt-get install gpiod libgpiod2 libgpiod-dev libnode-dev -y
- name: Checkout
uses: actions/checkout@v3

- name: Configure Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
registry-url: 'https://registry.npmjs.org'

- name: Run tests against the simulator
run: |
npm ci
npm run build
npm run test:coverage
11 changes: 8 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ on:
push:
branches: [ "main" ]

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Install libgpiod
run: |
sudo apt-get install gpiod libgpiod2 libgpiod-dev libnode-dev -y
- name: Checkout
uses: actions/checkout@v3

Expand All @@ -21,7 +28,5 @@ jobs:
run: |
npm ci
npm run build
# npm run test:coverage
npm run test:coverage
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
build
*~
.idea
coverage
.nyc_output
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# changelog

## 2023-11-15

### 0.3.2

- added new `Pin(n)` as a syntax sugar to get a new `Line(n)` from `Chip(0)`.
- put the workflow to run tests but mostly are ignored for the moment. i am
looking for a proper way to simulate a chip.

## 2023-11-13

### 0.3.1

- Merged PR #12 from @khill-fbmc fixing errors in index.d.ts
- Some dependency version bumps, it compiles again under node 18.
- Some dependency version bumps, it compiles again under node 18.
- Added GitHub Action to ease release process

I'll try to streamline more the changes we receive, let me know if anything needs
Expand All @@ -22,7 +30,7 @@ immediate attention.
- Added Line::getLineName which returns line's name, if set, otherwise undefined
- Added Line::getLineConsumer which returns line's consumer, if set, otherwise undefined
- Extended the Typescript .d.ts file with the new methods and added jsdoc comments
- Added a condition in the binding.gyp to prevent builds on non-Linux environments (aka development machines)
- Added a condition in the binding.gyp to prevent builds on non-Linux environments (aka development machines)

## 2022-04-15

Expand Down
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,40 @@
Native nodejs bindings for [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/)

[![npm](https://img.shields.io/npm/v/node-libgpiod?style=plastic)](https://www.npmjs.com/package/node-libgpiod)
![Build status](https://github.com/sombriks/node-libgpiod/actions/workflows/node-test.yml/badge.svg)
[![MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

## Requirements
## Requirements / Dependencies

- libgpiod (and devel headers)
- libgpiod **1.x** (and devel headers)
- nodejs (and devel headers)
- linux (tested on fedora 33 running on raspberry pi model 3 B+ and rasp pi os on zero w)
- c/c++ development tools

## Compiling
## How to use into your project

Just add it as a regular nodejs dependency:
First install libgpiod and node development packages, if not installed yet:

### RPM based

```bash
# fedora
sudo dnf install libgpiod libgpiod-devel libgpiod-utils nodejs-devel
```

```bash
# openSUSE
sudo zypper in libgpiod libgpiod-devel libgpiod-utils nodejs-devel
```

### DEB based

```bash
# debian and its variants
sudo apt install gpiod libgpiod2 libgpiod-dev libnode-dev
```

Then just add it as a regular nodejs dependency:

```bash
npm i node-libgpiod
Expand All @@ -27,8 +49,10 @@ npm i node-libgpiod
- raspberry pi model 3 B+ (64 bits, 1GB ram) running fedora
- raspberry pi zero w (32 bits, 512MB ram) running rasp pi os
- [LTPPxG2](https://tibbo.com/store/tps/ltpp3g2.html) with sp7021 SoC (32 bits, 512MB ram) running Yocto
- [ROCK 5A](https://docs.radxa.com/en/rock5/rock5a/hardware/rock5a-gpio)

technically speaking it should work with any modern vanilla kernel and libgpio.
Technically speaking it should work with any modern vanilla kernel and
libgpio 1.x, we're still working on libgpio 2.x

## Status

Expand Down Expand Up @@ -92,6 +116,10 @@ for more sample code

## known issues

- libgpio 2.x series is around the corner and it's API is incompatible with 1.x
the 2.x branch (under development) will handle 2.x while 0.x and 1.x will
support libgpiod 1.x series.

- gpio character device needs
[special udev rules](https://blog.oless.xyz/post/fedorarpigpio/#udev) in order
to belong to a special group so non-root users could access it freely
Expand All @@ -103,7 +131,7 @@ for more sample code

- libgpiod must be installed in the system correctly with development headers
otherwise npm install will fail.
- node will garbage collect Chip and line too early on certain cases. When
- node will garbage collect Chip and Line too early on certain cases. When
writing the samples, sometimes the following error kept being thrown:

```bash
Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ if (os.type() === 'Linux') {
return new libgpiod.Line(this, n);
};

libgpiod.available = function() {
libgpiod.available = function () {
return true;
}

libgpiod.Pin = function Pin(n) {
// defaults to chip 0
const chip = new libgpiod.Chip(0);
const line = chip.getLine(n);
return line;
}

module.exports = libgpiod;
} else {
const libgpiod = {
available: function() {
available: function () {
return false;
}
}
Expand Down
Loading

0 comments on commit d58efba

Please sign in to comment.