Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 94 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,73 @@
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]

env:
npm_config_audit: false
npm_config_fund: false
npm_config_save: false
npm_config_package_lock: false

permissions: {}

jobs:
push:
name: Push ${{ github.ref }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Use Node.js 24
uses: actions/setup-node@v5
with:
node-version: 24
cache: 'npm'
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: build
path: |
target
package.json
jsr.json
retention-days: 1

test:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 24
cache: 'npm'
- uses: actions/download-artifact@v5
with:
name: build
- name: Fetch deps
run: npm ci
- name: Run tests
run: npm run test
- uses: actions/upload-artifact@v4
with:
name: coverage
path: |
target/coverage
package.json
retention-days: 1

release:
name: Release ${{ github.ref }}
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# if: github.event_name == 'turned-off-temporary'
runs-on: ubuntu-latest
permissions:
checks: read
statuses: write
Expand All @@ -15,36 +77,19 @@ jobs:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: ${{ github.ref == 'refs/heads/main' && '0' || '1' }}

fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20
node-version: 24
cache: 'npm'

- name: Fetch deps
run: npm ci

- name: Build
run: npm run build

- name: Run tests
run: npm run test

# - name: Codeclimate
# if: github.ref == 'refs/heads/main'
# uses: paambaati/codeclimate-action@v4.0.0
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{github.workspace}}/target/coverage/lcov.info:lcov

- name: Semantic Release
if: github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v5
with:
merge-multiple: true
- name: Run release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_PROVENANCE: true
Expand All @@ -54,14 +99,23 @@ jobs:
GIT_AUTHOR_EMAIL: ${{ vars.GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL }}
run: npm_config_yes=true npx zx-semrel
run: npx zx-semrel

- name: Push docs and coverage
env:
GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL }}
run: |
npx ggcp target/docs https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git/gh-pages --message='chore: update docs'
npx ggcp target/coverage/lcov.info https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git/coverage/${{ github.sha }}.lcov.info --message='chore: add coverage for ${{ github.sha }}'

pr:
needs: build
if: github.event_name == 'pull_request'
name: PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
name: pr-os-${{ matrix.os }}-nodejs${{ matrix.node-version }}
strategy:
matrix:
os: [ ubuntu-22.04, windows-latest ]
os: [ ubuntu-24.04, windows-2022, windows-2025 ]
node-version: [ 20 ]

runs-on: ${{ matrix.os }}
Expand All @@ -75,20 +129,21 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- uses: actions/download-artifact@v5
with:
name: build

- name: Fetch deps
run: npm ci

- name: Build
run: npm run build

- name: Run all tests
if: matrix.os == 'ubuntu-22.04'
if: matrix.os == 'ubuntu-24.04'
run: npm run test

- name: Run win32 tests
if: matrix.os == 'windows-latest'
- name: Run legacy tests only
if: matrix.os != 'ubuntu-24.04'
timeout-minutes: 2
run: npm run test:legacy
run: npm run x:test:legacy
# run: |
# wmic process get ProcessId,ParentProcessId,CommandLine

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
* [x] `table-parser` replaced with `@webpod/ingrid` to handle some issues: [neekey/ps#76](https://github.com/neekey/ps/issues/76), [neekey/ps#62](https://github.com/neekey/ps/issues/62), [neekey/table-parser#11](https://github.com/neekey/table-parser/issues/11), [neekey/table-parser#18](https://github.com/neekey/table-parser/issues/18)
* [x] Provides promisified responses
* [x] Brings sync API
* [x] Builds a process tree
* [x] Builds a process subtree by parent

## Install
```bash
$ npm install @webpod/ps
```

## Internals
This module invokes different tools to get process list:
This module uses different approaches for getting process list:

* `ps` for unix/mac: `ps -lx`
* [`wmic` for win runtimes](https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic): `wmic process get ProcessId,CommandLine`.
| Platform | Method |
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| Unix/Mac | `ps -lx` |
| Windows (kernel >= 26000)| `pwsh -NoProfile -Command "Get-CimInstance Win32_Process \| Select-Object ProcessId,ParentProcessId,CommandLine \| ConvertTo-Json -Compress"` |
| Windows (kernel < 26000) | [`wmic`](https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic) `process get ProcessId,CommandLine` |

## Usage

Expand Down
Loading