Skip to content

Commit f199620

Browse files
authored
feat: support win2025 flow (#15)
BREAKING CHANGE: win-2025 uses `pwsh` to obtain process list tree instead of `wmic` * chore: up dev deps * ci: separate build and test, add win-2025 to test matrix * chore: up dev deps * refactor: recompose internal parsing flow * feat: support win2025 * test: update tests * chore: debug * docs: update internals description
1 parent 06e0dcd commit f199620

5 files changed

Lines changed: 365 additions & 270 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 94 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,73 @@
22
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
33
name: CI
44
on: [push, pull_request]
5+
6+
env:
7+
npm_config_audit: false
8+
npm_config_fund: false
9+
npm_config_save: false
10+
npm_config_package_lock: false
11+
12+
permissions: {}
13+
514
jobs:
6-
push:
7-
name: Push ${{ github.ref }}
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
with:
20+
persist-credentials: false
21+
- name: Use Node.js 24
22+
uses: actions/setup-node@v5
23+
with:
24+
node-version: 24
25+
cache: 'npm'
26+
- run: npm ci
27+
- run: npm run build
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: build
31+
path: |
32+
target
33+
package.json
34+
jsr.json
35+
retention-days: 1
36+
37+
test:
38+
needs: build
839
if: github.event_name == 'push'
9-
runs-on: ubuntu-22.04
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v5
44+
with:
45+
persist-credentials: false
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v5
48+
with:
49+
node-version: 24
50+
cache: 'npm'
51+
- uses: actions/download-artifact@v5
52+
with:
53+
name: build
54+
- name: Fetch deps
55+
run: npm ci
56+
- name: Run tests
57+
run: npm run test
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: coverage
61+
path: |
62+
target/coverage
63+
package.json
64+
retention-days: 1
65+
66+
release:
67+
name: Release ${{ github.ref }}
68+
needs: test
69+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
70+
# if: github.event_name == 'turned-off-temporary'
71+
runs-on: ubuntu-latest
1072
permissions:
1173
checks: read
1274
statuses: write
@@ -15,36 +77,19 @@ jobs:
1577
id-token: write
1678
steps:
1779
- name: Checkout
18-
uses: actions/checkout@v4
80+
uses: actions/checkout@v5
1981
with:
20-
fetch-depth: ${{ github.ref == 'refs/heads/main' && '0' || '1' }}
21-
82+
fetch-depth: 0
83+
persist-credentials: false
2284
- name: Setup Node.js
23-
uses: actions/setup-node@v4
85+
uses: actions/setup-node@v5
2486
with:
25-
node-version: 20
87+
node-version: 24
2688
cache: 'npm'
27-
28-
- name: Fetch deps
29-
run: npm ci
30-
31-
- name: Build
32-
run: npm run build
33-
34-
- name: Run tests
35-
run: npm run test
36-
37-
# - name: Codeclimate
38-
# if: github.ref == 'refs/heads/main'
39-
# uses: paambaati/codeclimate-action@v4.0.0
40-
# env:
41-
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
42-
# with:
43-
# coverageLocations: |
44-
# ${{github.workspace}}/target/coverage/lcov.info:lcov
45-
46-
- name: Semantic Release
47-
if: github.ref == 'refs/heads/main'
89+
- uses: actions/download-artifact@v5
90+
with:
91+
merge-multiple: true
92+
- name: Run release
4893
env:
4994
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5095
NPM_PROVENANCE: true
@@ -54,14 +99,23 @@ jobs:
5499
GIT_AUTHOR_EMAIL: ${{ vars.GIT_AUTHOR_EMAIL }}
55100
GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME }}
56101
GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL }}
57-
run: npm_config_yes=true npx zx-semrel
102+
run: npx zx-semrel
103+
104+
- name: Push docs and coverage
105+
env:
106+
GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME }}
107+
GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL }}
108+
run: |
109+
npx ggcp target/docs https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git/gh-pages --message='chore: update docs'
110+
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 }}'
58111
59112
pr:
113+
needs: build
60114
if: github.event_name == 'pull_request'
61-
name: PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
115+
name: pr-os-${{ matrix.os }}-nodejs${{ matrix.node-version }}
62116
strategy:
63117
matrix:
64-
os: [ ubuntu-22.04, windows-latest ]
118+
os: [ ubuntu-24.04, windows-2022, windows-2025 ]
65119
node-version: [ 20 ]
66120

67121
runs-on: ${{ matrix.os }}
@@ -75,20 +129,21 @@ jobs:
75129
node-version: ${{ matrix.node-version }}
76130
cache: 'npm'
77131

132+
- uses: actions/download-artifact@v5
133+
with:
134+
name: build
135+
78136
- name: Fetch deps
79137
run: npm ci
80138

81-
- name: Build
82-
run: npm run build
83-
84139
- name: Run all tests
85-
if: matrix.os == 'ubuntu-22.04'
140+
if: matrix.os == 'ubuntu-24.04'
86141
run: npm run test
87142

88-
- name: Run win32 tests
89-
if: matrix.os == 'windows-latest'
143+
- name: Run legacy tests only
144+
if: matrix.os != 'ubuntu-24.04'
90145
timeout-minutes: 2
91-
run: npm run test:legacy
146+
run: npm run x:test:legacy
92147
# run: |
93148
# wmic process get ProcessId,ParentProcessId,CommandLine
94149

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
* [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)
99
* [x] Provides promisified responses
1010
* [x] Brings sync API
11-
* [x] Builds a process tree
11+
* [x] Builds a process subtree by parent
1212

1313
## Install
1414
```bash
1515
$ npm install @webpod/ps
1616
```
1717

1818
## Internals
19-
This module invokes different tools to get process list:
19+
This module uses different approaches for getting process list:
2020

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

2427
## Usage
2528

0 commit comments

Comments
 (0)