Skip to content

Commit d26ede2

Browse files
Merge pull request #2 from savetheclocktower/ci-publishing
Prepare for automatic publishing to `@pulsar-edit/git-utils` on NPM
2 parents 208a033 + a1eafd8 commit d26ede2

File tree

6 files changed

+96
-33
lines changed

6 files changed

+96
-33
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- uses: actions/setup-node@v2
1515
with:
16-
node-version: 14
16+
node-version: 16
1717
- name: Install
1818
run: |
1919
npm run prepare

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: NPM Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
8+
env:
9+
NODE_VERSION: 16
10+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
11+
CC: clang
12+
CXX: clang++
13+
npm_config_clang: 1
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ env.NODE_VERSION }}
23+
- run: npm run prepare
24+
- run: npm ci
25+
- run: npm test
26+
27+
publish:
28+
needs: build
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ env.NODE_VERSION }}
35+
registry-url: https://registry.npmjs.org/
36+
- run: npm run prepare
37+
- run: npm ci
38+
- run: npm publish --access public

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
*.log
66
*~
77
.node-version
8+
.cache
9+
.tool-versions
10+
compile_commands.json

binding.gyp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
'dependencies': [
66
'libgit2'
77
],
8-
'include_dirs': [ '<!(node -e "require(\'nan\')")' ],
8+
'include_dirs': ['<!(node -e "require(\'nan\')")'],
99
'sources': [
1010
'src/repository.cc'
1111
],
1212
'conditions': [
1313
['OS=="win"', {
1414
'msvs_disabled_warnings': [
15-
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of data
16-
4530, # C++ exception handler used, but unwind semantics are not enabled.
15+
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of
16+
# data
17+
4530, # C++ exception handler used, but unwind semantics are not
18+
# enabled.
1719
4506, # no definition for inline function
1820
4267, # conversion from 'size_t' to 'int', possible loss of data
1921
4344, # behavior change
@@ -23,7 +25,8 @@
2325
'-Wno-missing-field-initializers',
2426
],
2527
'cflags_cc!': [
26-
'-fno-delete-null-pointer-checks', # clang-3.4 doesn't understand this flag and fails.
28+
'-fno-delete-null-pointer-checks', # clang-3.4 doesn't understand
29+
# this flag and fails.
2730
],
2831
'xcode_settings': {
2932
'WARNING_CFLAGS': [
@@ -374,11 +377,14 @@
374377
},
375378
'msvs_disabled_warnings': [
376379
4005, # macro redefinition
377-
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of data
380+
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of
381+
# data
378382
4267, # conversion from 'size_t' to 'int', possible loss of data
379383
4090, # different 'volatile' qualifiers
380-
4047, # 'volatile void *' differs in levels of indirection from 'int'
381-
4013, # 'InterlockedDecrement' undefined; assuming extern returning int
384+
4047, # 'volatile void *' differs in levels of indirection from
385+
# 'int'
386+
4013, # 'InterlockedDecrement' undefined; assuming extern
387+
# returning int
382388
],
383389
'sources': [
384390
'deps/libgit2/src/net.c',
@@ -513,7 +519,8 @@
513519
'conditions': [
514520
['OS=="win"', {
515521
'msvs_disabled_warnings': [
516-
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of data
522+
4244, # conversion from 'ssize_t' to 'int32_t', possible loss of
523+
# data
517524
],
518525
}],
519526
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "git-utils",
2+
"name": "@pulsar-edit/git-utils",
33
"description": "A package for using Git repositories",
44
"version": "5.7.3",
55
"license": "MIT",

spec/git-spec.js

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,36 +1059,51 @@ describe('git', () => {
10591059
})
10601060
})
10611061

1062-
describe('.submoduleForPath(path)', () => {
1063-
beforeEach(() => {
1064-
const repoDirectory = temp.mkdirSync('node-git-repo-')
1065-
const submoduleDirectory = temp.mkdirSync('node-git-repo-')
1066-
wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(repoDirectory, '.git'))
1067-
wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(submoduleDirectory, '.git'))
1062+
if (process.env.CI) {
1063+
// NOTE: Testing a submodule requires that you be able to add one defined
1064+
// at a path on disk. This is disallowed by default these days as a
1065+
// security risk. There's a config setting to allow it, but we don't seem
1066+
// to be able to opt into it on a per-repo basis.
1067+
//
1068+
// So this test is disabled unless we're running in CI, where the
1069+
// environment is transient and will be thrown away anyway. If you want to
1070+
// test this locally, save your config value for `protocol.file.allow`
1071+
// beforehand and restore it when you're done testing.
1072+
describe('.submoduleForPath(path)', () => {
1073+
beforeEach(() => {
1074+
const repoDirectory = temp.mkdirSync('node-git-repo-')
1075+
const submoduleDirectory = temp.mkdirSync('node-git-repo-')
1076+
wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(repoDirectory, '.git'))
1077+
wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(submoduleDirectory, '.git'))
10681078

1069-
const gitCommandHandler = jasmine.createSpy('gitCommandHandler')
1070-
execCommands([`cd ${repoDirectory}`, `git submodule add ${submoduleDirectory} sub`], gitCommandHandler)
1079+
const gitCommandHandler = jasmine.createSpy('gitCommandHandler')
1080+
execCommands([
1081+
`git config --global protocol.file.allow always`,
1082+
`cd ${repoDirectory}`,
1083+
`git submodule add ${submoduleDirectory} sub`
1084+
], gitCommandHandler)
10711085

1072-
waitsFor(() => gitCommandHandler.callCount === 1)
1086+
waitsFor(() => gitCommandHandler.callCount === 1)
10731087

1074-
runs(() => repo = git.open(repoDirectory))
1075-
})
1088+
runs(() => repo = git.open(repoDirectory))
1089+
})
10761090

1077-
it('returns the repository for the path', () => {
1078-
expect(repo.submoduleForPath()).toBe(null)
1079-
expect(repo.submoduleForPath(null)).toBe(null)
1080-
expect(repo.submoduleForPath('')).toBe(null)
1081-
expect(repo.submoduleForPath('sub1')).toBe(null)
1091+
it('returns the repository for the path', () => {
1092+
expect(repo.submoduleForPath()).toBe(null)
1093+
expect(repo.submoduleForPath(null)).toBe(null)
1094+
expect(repo.submoduleForPath('')).toBe(null)
1095+
expect(repo.submoduleForPath('sub1')).toBe(null)
10821096

1083-
let submoduleRepoPath = path.join(repo.getPath(), 'modules', 'sub/')
1084-
if (process.platform === 'win32') { submoduleRepoPath = submoduleRepoPath.replace(/\\/g, '/') }
1097+
let submoduleRepoPath = path.join(repo.getPath(), 'modules', 'sub/')
1098+
if (process.platform === 'win32') { submoduleRepoPath = submoduleRepoPath.replace(/\\/g, '/') }
10851099

1086-
expect(repo.submoduleForPath('sub').getPath()).toBe(submoduleRepoPath)
1087-
expect(repo.submoduleForPath('sub/').getPath()).toBe(submoduleRepoPath)
1088-
expect(repo.submoduleForPath('sub/a').getPath()).toBe(submoduleRepoPath)
1089-
expect(repo.submoduleForPath('sub/a/b/c/d').getPath()).toBe(submoduleRepoPath)
1100+
expect(repo.submoduleForPath('sub').getPath()).toBe(submoduleRepoPath)
1101+
expect(repo.submoduleForPath('sub/').getPath()).toBe(submoduleRepoPath)
1102+
expect(repo.submoduleForPath('sub/a').getPath()).toBe(submoduleRepoPath)
1103+
expect(repo.submoduleForPath('sub/a/b/c/d').getPath()).toBe(submoduleRepoPath)
1104+
})
10901105
})
1091-
})
1106+
}
10921107

10931108
describe('.add(path)', () => {
10941109
beforeEach(() => {

0 commit comments

Comments
 (0)