Skip to content

Commit 464ce13

Browse files
authored
feat: support node 22 (#14)
- update the test action with a node version matrix - get the tests running on macos newer than 13 - there's a single test that fails, consistently, on macos > 13 - update the publish job to include node 22 prebuilds - we're gonna have super fat binaries until we can get an optionalDependencies-style setup going - run linux-arm tests on PRs - update version number The patch in this commit resolves the build issue noted in nodegit#2023 by applying a patch to zlib, which is a little gross but gets us building at least
1 parent 45a1fa8 commit 464ce13

File tree

13 files changed

+361
-34
lines changed

13 files changed

+361
-34
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules
2-
test

.github/workflows/publish.yml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: build
1212
strategy:
1313
matrix:
14-
node: [20]
14+
node: [20, 22]
1515
os:
1616
# macos-14 is arm64 (m1)
1717
- name: darwin
@@ -41,7 +41,7 @@ jobs:
4141
submodules: true
4242
- uses: actions/setup-node@v6
4343
with:
44-
node-version: 20
44+
node-version: ${{ matrix.node }}
4545
check-latest: true
4646
- name: Prebuildify
4747
run: |
@@ -50,48 +50,55 @@ jobs:
5050
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev
5151
5252
npm ci
53-
npx prebuildify --napi --strip --tag-libc -t "$(node --version | tr -d 'v')"
53+
# does the JOBS=2 speed things up? not sure
54+
JOBS=2 npx prebuildify --strip --napi=false --tag-libc -t "$(node --version | tr -d 'v')"
5455
- uses: actions/upload-artifact@v4
5556
with:
56-
name: prebuild-${{ runner.os }}-${{ runner.arch }}
57+
name: prebuild-${{ runner.os }}-${{ runner.arch }}-node${{ matrix.node }}
5758
path: ./prebuilds
5859
retention-days: 14
5960

6061
# musl build still needs QEMU since there are no native Alpine/musl runners
6162
cross-compile-musl-amd64:
6263
name: "cross compile linux/amd64-musl"
6364
runs-on: ubuntu-22.04
65+
strategy:
66+
matrix:
67+
node: [20, 22]
6468
steps:
6569
- uses: actions/checkout@v5
6670
- uses: docker/setup-qemu-action@v3
6771
- name: build linux musl amd64
6872
run: |
69-
docker build --platform=linux/amd64 --tag nodegit-linux-musl-amd64 -f scripts/Dockerfile.alpine .
70-
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64 nodegit-linux-musl-amd64
71-
docker cp "nodegit-linux-musl-amd64:/app/prebuilds" .
73+
docker build --platform=linux/amd64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-amd64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
74+
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64-node${{ matrix.node }} nodegit-linux-musl-amd64-node${{ matrix.node }}
75+
docker cp "nodegit-linux-musl-amd64-node${{ matrix.node }}:/app/prebuilds" .
7276
- name: "list the generated files"
7377
run: find prebuilds
7478
- uses: actions/upload-artifact@v4
7579
with:
76-
name: prebuild-linux-musl-amd64
80+
name: prebuild-linux-musl-amd64-node${{ matrix.node }}
7781
path: ./prebuilds
7882
retention-days: 14
7983

8084
cross-compile-musl-arm64:
8185
name: "build linux/arm64-musl"
8286
runs-on: ubuntu-22.04-arm
87+
strategy:
88+
matrix:
89+
node: [20, 22]
8390
steps:
8491
- uses: actions/checkout@v5
8592
- name: build linux musl arm64
8693
run: |
87-
docker build --platform=linux/arm64 --tag nodegit-linux-musl-arm64 -f scripts/Dockerfile.alpine .
88-
docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64 nodegit-linux-musl-arm64
89-
docker cp "nodegit-linux-musl-arm64:/app/prebuilds" .
94+
docker build --platform=linux/arm64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-arm64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
95+
docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64-node${{ matrix.node }} nodegit-linux-musl-arm64-node${{ matrix.node }}
96+
docker cp "nodegit-linux-musl-arm64-node${{ matrix.node }}:/app/prebuilds" .
9097
- name: "list the generated files"
9198
run: find prebuilds
9299
- uses: actions/upload-artifact@v4
93100
with:
94-
name: prebuild-linux-musl-arm64
101+
name: prebuild-linux-musl-arm64-node${{ matrix.node }}
95102
path: ./prebuilds
96103
retention-days: 14
97104

@@ -108,7 +115,7 @@ jobs:
108115
submodules: true
109116
- uses: actions/setup-node@v6
110117
with:
111-
node-version: 20
118+
node-version: 22
112119
check-latest: true
113120
registry-url: "https://registry.npmjs.org"
114121
# for the publish step, we need a version of npm that supports OIDC (>=
@@ -128,12 +135,19 @@ jobs:
128135
mkdir -p prebuilds/darwin-arm64
129136
mkdir -p prebuilds/darwin-x64
130137
find ${{ steps.download.outputs.download-path }}
131-
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-X64/linux-x64/* ./prebuilds/linux-x64/
132-
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-ARM64/linux-arm64/* ./prebuilds/linux-arm64/
133-
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-amd64/linux-x64/* ./prebuilds/linux-x64/
134-
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-arm64/linux-arm64/* ./prebuilds/linux-arm64/
135-
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-ARM64/darwin-arm64/* ./prebuilds/darwin-arm64/
136-
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-X64/darwin-x64/* ./prebuilds/darwin-x64/
138+
# Copy Node 20 and 22 prebuilds for each platform
139+
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-X64-node20/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true
140+
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-X64-node22/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true
141+
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-ARM64-node20/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true
142+
mv ${{ steps.download.outputs.download-path }}/prebuild-Linux-ARM64-node22/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true
143+
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-amd64-node20/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true
144+
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-amd64-node22/linux-x64/* ./prebuilds/linux-x64/ 2>/dev/null || true
145+
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-arm64-node20/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true
146+
mv ${{ steps.download.outputs.download-path }}/prebuild-linux-musl-arm64-node22/linux-arm64/* ./prebuilds/linux-arm64/ 2>/dev/null || true
147+
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-ARM64-node20/darwin-arm64/* ./prebuilds/darwin-arm64/ 2>/dev/null || true
148+
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-ARM64-node22/darwin-arm64/* ./prebuilds/darwin-arm64/ 2>/dev/null || true
149+
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-X64-node20/darwin-x64/* ./prebuilds/darwin-x64/ 2>/dev/null || true
150+
mv ${{ steps.download.outputs.download-path }}/prebuild-macOS-X64-node22/darwin-x64/* ./prebuilds/darwin-x64/ 2>/dev/null || true
137151
find ./prebuilds
138152
- name: npm install
139153
run: npm ci

.github/workflows/tests.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
linux-test:
12-
name: "test on linux"
12+
name: "test node ${{ matrix.node-version }} on linux"
1313
env:
1414
CC: clang
1515
CXX: clang++
@@ -18,6 +18,9 @@ jobs:
1818
DEBIAN_FRONTEND: "noninteractive"
1919
runs-on: ubuntu-22.04
2020
container: ubuntu:22.04
21+
strategy:
22+
matrix:
23+
node-version: [20, 22]
2124
steps:
2225
- name: prerequisites
2326
run: |
@@ -28,7 +31,7 @@ jobs:
2831
submodules: true
2932
- uses: actions/setup-node@v6
3033
with:
31-
node-version: 20
34+
node-version: ${{ matrix.node-version }}
3235
check-latest: true
3336
- name: Test
3437
run: |
@@ -50,20 +53,23 @@ jobs:
5053
npm test
5154
5255
mac-test:
53-
name: "macOS tests"
56+
name: "test node ${{ matrix.node-version }} on macOS"
5457
env:
5558
CC: clang
5659
CXX: clang++
5760
npm_config_clang: 1
5861
GYP_DEFINES: use_obsolete_asm=true
59-
runs-on: macos-13
62+
runs-on: macos-26
63+
strategy:
64+
matrix:
65+
node-version: [20, 22]
6066
steps:
6167
- uses: actions/checkout@v5
6268
with:
6369
submodules: true
6470
- uses: actions/setup-node@v6
6571
with:
66-
node-version: 20
72+
node-version: ${{ matrix.node-version }}
6773
check-latest: true
6874
- name: Test
6975
run: |
@@ -82,3 +88,45 @@ jobs:
8288
8389
npm install
8490
npm test
91+
92+
linux-arm-test:
93+
name: "test node ${{ matrix.node-version }} on linux-arm"
94+
env:
95+
CC: clang
96+
CXX: clang++
97+
npm_config_clang: 1
98+
GYP_DEFINES: use_obsolete_asm=true
99+
CXXFLAGS: -std=c++17
100+
runs-on: ubuntu-22.04-arm
101+
strategy:
102+
matrix:
103+
node-version: [20, 22]
104+
steps:
105+
- uses: actions/checkout@v5
106+
with:
107+
submodules: true
108+
- uses: actions/setup-node@v6
109+
with:
110+
node-version: ${{ matrix.node-version }}
111+
check-latest: true
112+
- name: Install dependencies
113+
run: |
114+
sudo apt-get update
115+
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev
116+
- name: Test
117+
run: |
118+
set -xe
119+
mkdir ~/.ssh_tests
120+
chmod 700 ~/.ssh_tests
121+
printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config
122+
cat test/id_rsa.pub > ~/.ssh_tests/id_rsa.pub
123+
cat test/id_rsa.enc | base64 -d > ~/.ssh_tests/id_rsa
124+
chmod 600 ~/.ssh_tests/id_rsa*
125+
git config --global user.name "John Doe"
126+
git config --global user.email [email protected]
127+
128+
eval "$(ssh-agent -s)"
129+
ssh-add ~/.ssh_tests/id_rsa
130+
131+
npm install
132+
npm test

CLAUDE.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# NodeGit Development Guide
2+
3+
## Overview
4+
5+
This is [@readme/nodegit](https://www.npmjs.com/package/@readme/nodegit), a fork of the original NodeGit library that provides Node.js bindings to libgit2. This fork is maintained by Readme and includes compatibility updates for Node.js 20 and 22.
6+
7+
## Quick Start
8+
9+
### Prerequisites
10+
- Node.js >= 20 (supports Node 20 and 22)
11+
- Git installed on your system
12+
- Build tools (automatically handled during install)
13+
14+
### Installation
15+
```bash
16+
npm install
17+
```
18+
19+
The install process automatically:
20+
1. Runs preinstall scripts
21+
2. Builds native bindings using node-gyp
22+
3. Runs postinstall scripts
23+
24+
## Running Tests
25+
26+
### Full Test Suite
27+
```bash
28+
npm test
29+
```
30+
This runs linting followed by the complete test suite.
31+
32+
### Tests Only (Skip Linting)
33+
```bash
34+
npm run mocha
35+
```
36+
37+
### Debug Tests
38+
```bash
39+
npm run mochaDebug
40+
```
41+
Runs tests with inspector for debugging.
42+
43+
### Run Specific Tests
44+
```bash
45+
# Run tests matching a pattern
46+
npm run mocha -- --grep "pattern"
47+
48+
# Example: Run only commit tests
49+
npm run mocha -- --grep "commit"
50+
51+
# Example: Run a specific test
52+
npm run mocha -- --grep "can amend commit"
53+
```
54+
55+
### Linting Only
56+
```bash
57+
npm run lint
58+
```
59+
60+
## Development Commands
61+
62+
### Building
63+
```bash
64+
# Full rebuild (includes code generation)
65+
npm run rebuild
66+
67+
# Debug build
68+
npm run rebuildDebug
69+
70+
# Recompile only (skip code generation)
71+
npm run recompile
72+
```
73+
74+
### Code Generation
75+
```bash
76+
# Generate missing tests
77+
npm run generateMissingTests
78+
79+
# Generate native code bindings
80+
npm run generateNativeCode
81+
82+
# Generate JSON API definitions
83+
npm run generateJson
84+
```
85+
86+
## Test Structure
87+
88+
Tests are located in:
89+
- `test/tests/` - Main test files
90+
- `test/utils/` - Test utilities
91+
- `test/repos/` - Test repositories
92+
93+
### Common Test Issues
94+
95+
**macOS Version Compatibility**: Tests may fail when upgrading macOS versions due to differences in Git behavior, file system precision, or system libraries. Hardcoded expected commit IDs are particularly sensitive to environment changes.
96+
97+
**Memory Management**: Tests use `--expose-gc` flag to test garbage collection behavior with native bindings.
98+
99+
**SSH Tests**: Some tests require SSH keys located in `test/id_rsa*` files.
100+
101+
## CI/CD
102+
103+
GitHub Actions workflows:
104+
- **tests.yml**: Runs tests on Ubuntu 22.04 and macOS-26
105+
- **publish.yml**: Handles package publishing
106+
107+
## Architecture
108+
109+
This library provides JavaScript bindings to the libgit2 C library:
110+
- `src/` - C++ binding code
111+
- `lib/` - Generated JavaScript APIs
112+
- `generate/` - Code generation scripts
113+
- `include/` - C++ headers
114+
- `vendor/` - Vendored dependencies (libgit2)
115+
116+
## Troubleshooting
117+
118+
### Build Issues
119+
```bash
120+
# Clean rebuild
121+
rm -rf build node_modules
122+
npm install
123+
```
124+
125+
### Test Failures
126+
- Check that Git is properly configured:
127+
```bash
128+
git config --global user.name "Test User"
129+
git config --global user.email "[email protected]"
130+
```
131+
- Ensure SSH agent is running for SSH tests
132+
133+
### Platform-Specific Issues
134+
- **Linux**: May require libssl-dev, libkrb5-dev, and pcre development packages
135+
- **macOS**: Uses clang compiler, may require Xcode command line tools
136+
- **Windows**: Requires Visual Studio build tools
137+
138+
## Contributing
139+
140+
1. Run tests locally: `npm test`
141+
2. Ensure linting passes: `npm run lint`
142+
3. Test on target Node versions (20, 22)
143+
4. Update tests if adding new functionality
144+
145+
For more detailed API documentation, visit [nodegit.org](http://www.nodegit.org/).

0 commit comments

Comments
 (0)