Skip to content

Commit e0821aa

Browse files
authored
Merge pull request #42 from aminya/prebuild
feat: prebuild minidump
2 parents 813584e + 0f360d7 commit e0821aa

File tree

7 files changed

+117
-31
lines changed

7 files changed

+117
-31
lines changed

.github/workflows/CI.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
6+
jobs:
7+
Test:
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os:
14+
- ubuntu-latest
15+
- macos-latest
16+
# - windows-latest
17+
node_version:
18+
- 12
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
submodules: recursive
23+
24+
- name: Install Node
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node_version }}
28+
29+
- name: Install dependencies and build
30+
run: npm install
31+
32+
- name: Tests
33+
run: npm run test
34+
35+
- name: Upload artifacts
36+
uses: actions/upload-artifact@v2
37+
with:
38+
path: ./bin
39+
40+
Skip:
41+
if: contains(github.event.head_commit.message, '[skip ci]')
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Skip CI 🚫
45+
run: echo skip ci

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/build
33
*.swp
44
npm-debug.log
5+
bin

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# minidump - Process minidump files [![Build Status](https://travis-ci.org/electron/node-minidump.svg?branch=master)](https://travis-ci.org/electron/node-minidump)
1+
# minidump - Process minidump files
2+
3+
![CI](https://github.com/electron/node-minidump/workflows/CI/badge.svg)
24

35
## Installing
46

@@ -34,3 +36,28 @@ Parse and dump the raw contents of the minidump as text using `minidump_dump`.
3436

3537
Dump debug symbols in minidump format from `binaryPath`, the `callback` would
3638
be called with `callback(error, minidump)` upon completion.
39+
40+
41+
## Releasing a new npm version
42+
- Change the version in `package.json`, make a new git tag, and push it to GitHub.
43+
- Wait until the GitHub Actions on the master branch pass.
44+
- The artifacts of the latest GitHub Action run should be downloaded and placed under the `bin` folder
45+
(replacing the old folder if it exists).
46+
47+
The bin folder should look like the following.
48+
```
49+
bin
50+
|_linux-x64
51+
|_dump_syms
52+
|_minidump_dump
53+
|_minidump_stackwalk
54+
|_darwin-x64
55+
|_dump_syms
56+
|_minidump_dump
57+
|_minidump_stackwalk
58+
```
59+
60+
- Then:
61+
```
62+
npm publish
63+
```

build.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ const fs = require('fs')
22
const path = require('path')
33
const childProcess = require('child_process')
44

5+
const exe = process.platform === 'win32' ? '.exe' : ''
6+
const binDir = path.join(__dirname, 'bin', `${process.platform}-${process.arch}`)
7+
8+
const minidumpStackwalkDest = path.join(binDir, 'minidump_stackwalk') + exe
9+
const minidumpDumpDest = path.join(binDir, 'minidump_dump') + exe
10+
const dumpSymsDest = path.join(binDir, 'dump_syms') + exe
11+
12+
// do not build if executables already exist
13+
if (
14+
fs.existsSync(minidumpStackwalkDest) &&
15+
fs.existsSync(minidumpDumpDest) &&
16+
fs.existsSync(dumpSymsDest)
17+
) {
18+
process.exit(0)
19+
}
20+
521
function spawnSync (...args) {
622
const result = childProcess.spawnSync(...args)
723
if (result.status !== 0) {
@@ -36,3 +52,23 @@ if (process.platform === 'darwin') {
3652
stdio: 'inherit'
3753
})
3854
}
55+
56+
// copy to bin folder
57+
if (!fs.existsSync(binDir)) {
58+
fs.mkdirSync(binDir, { recursive: true })
59+
}
60+
61+
const minidumpStackwalk = path.resolve(__dirname, 'build', 'src', 'processor', 'minidump_stackwalk') + exe
62+
fs.copyFileSync(minidumpStackwalk, minidumpStackwalkDest)
63+
64+
const minidumpDump = path.resolve(__dirname, 'build', 'src', 'processor', 'minidump_dump') + exe
65+
fs.copyFileSync(minidumpDump, minidumpDumpDest)
66+
67+
const dumpSyms = (() => {
68+
if (process.platform === 'darwin') {
69+
return path.resolve(__dirname, 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms')
70+
} else if (process.platform === 'linux') {
71+
return path.resolve(__dirname, 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms')
72+
}
73+
})()
74+
fs.copyFileSync(dumpSyms, dumpSymsDest)

lib/minidump.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ const spawn = require('child_process').spawn
44
const format = require('./format')
55

66
const exe = process.platform === 'win32' ? '.exe' : ''
7+
const binDir = path.join(path.dirname(__dirname), 'bin', `${process.platform}-${process.arch}`)
8+
79
const commands = {
8-
minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe,
9-
minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe,
10-
dump_syms: (() => {
11-
if (process.platform === 'darwin') {
12-
return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms')
13-
} else if (process.platform === 'linux') {
14-
return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms')
15-
}
16-
})()
10+
minidump_stackwalk: path.join(binDir, 'minidump_stackwalk') + exe,
11+
minidump_dump: path.join(binDir, 'minidump_dump') + exe,
12+
dump_syms: path.join(binDir, 'dump_syms') + exe
1713
}
1814

1915
function execute (command, args, callback) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"/lib",
3535
"index.d.ts",
3636
"build.js",
37-
"deps"
37+
"deps",
38+
"bin"
3839
]
3940
}

0 commit comments

Comments
 (0)