Skip to content

Commit 1e86041

Browse files
rathbomaclaude
andcommitted
Add GitHub Actions CI workflows and lint fixes
Add comprehensive CI/CD workflows for automated testing: - Test workflow runs on Ubuntu, macOS, and Windows - Tests with Node.js 18.x and 20.x - Installs libssh on all platforms - Runs tests and attempts native module build - Separate lint workflow for code quality checks - Coverage reporting with Codecov integration Also add lint scripts to package.json and fix ESLint errors: - Fix lexical declaration in case block (config.ts) - Change unused let to const (tunnel.ts) - Add lint and lint:fix scripts - Add test:coverage script All tests passing (16/16) and linter clean. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 888adf8 commit 1e86041

File tree

5 files changed

+143
-2
lines changed

5 files changed

+143
-2
lines changed

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: ESLint & TypeScript Check
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.x'
22+
cache: 'yarn'
23+
24+
- name: Install dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Run ESLint
28+
run: yarn lint
29+
30+
- name: TypeScript type check
31+
run: yarn tsc --noEmit

.github/workflows/test.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
node-version: [18.x, 20.x]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'yarn'
29+
30+
- name: Install libssh (Ubuntu)
31+
if: runner.os == 'Linux'
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y libssh-dev
35+
36+
- name: Install libssh (macOS)
37+
if: runner.os == 'macOS'
38+
run: |
39+
brew install libssh
40+
41+
- name: Install libssh (Windows)
42+
if: runner.os == 'Windows'
43+
run: |
44+
choco install cmake -y
45+
vcpkg install libssh:x64-windows
46+
vcpkg integrate install
47+
shell: powershell
48+
49+
- name: Install dependencies
50+
run: yarn install --frozen-lockfile
51+
52+
- name: Build TypeScript
53+
run: yarn build:ts
54+
55+
- name: Run linter
56+
run: yarn lint --max-warnings 0
57+
continue-on-error: true
58+
59+
- name: Run tests
60+
run: yarn test
61+
62+
- name: Build native module (Ubuntu/macOS)
63+
if: runner.os != 'Windows'
64+
run: yarn build:native
65+
continue-on-error: true
66+
67+
- name: Build native module (Windows)
68+
if: runner.os == 'Windows'
69+
run: yarn build:native
70+
env:
71+
VCPKG_ROOT: C:\vcpkg
72+
continue-on-error: true
73+
74+
test-coverage:
75+
name: Test Coverage
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Setup Node.js
83+
uses: actions/setup-node@v4
84+
with:
85+
node-version: '20.x'
86+
cache: 'yarn'
87+
88+
- name: Install libssh
89+
run: |
90+
sudo apt-get update
91+
sudo apt-get install -y libssh-dev
92+
93+
- name: Install dependencies
94+
run: yarn install --frozen-lockfile
95+
96+
- name: Build TypeScript
97+
run: yarn build:ts
98+
99+
- name: Run tests with coverage
100+
run: yarn test --coverage
101+
102+
- name: Upload coverage to Codecov
103+
uses: codecov/codecov-action@v4
104+
with:
105+
file: ./coverage/coverage-final.json
106+
fail_ci_if_error: false

lib/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class SSHConfigParser {
116116
case 'user':
117117
host.user = value;
118118
break;
119-
case 'identityfile':
119+
case 'identityfile': {
120120
if (!host.identityFile) {
121121
host.identityFile = [];
122122
}
@@ -126,6 +126,7 @@ export class SSHConfigParser {
126126
: value;
127127
host.identityFile.push(expandedValue);
128128
break;
129+
}
129130
case 'proxyjump':
130131
host.proxyJump = value;
131132
break;

lib/tunnel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class SSHTunnel {
149149
* Set up bidirectional data forwarding between socket and channel
150150
*/
151151
private setupDataForwarding(channelId: number, channel: SSHChannel, socket: net.Socket): void {
152-
let isForwarding = true;
152+
const isForwarding = true;
153153

154154
// Socket -> Channel
155155
socket.on('data', async (data) => {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"clean": "node-gyp clean && rm -rf dist",
1313
"test": "jest",
1414
"test:watch": "jest --watch",
15+
"test:coverage": "jest --coverage",
16+
"lint": "eslint lib/**/*.ts test/**/*.ts examples/**/*.ts",
17+
"lint:fix": "eslint lib/**/*.ts test/**/*.ts examples/**/*.ts --fix",
1518
"rebuild": "yarn clean && yarn build:all"
1619
},
1720
"keywords": [

0 commit comments

Comments
 (0)