Skip to content

feat: prebuild minidump #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI
on:
pull_request:
push:

jobs:
Test:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
node_version:
- 12
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: Install dependencies and build
run: npm install

- name: Tests
run: npm run test

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: ./bin

Skip:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- name: Skip CI 🚫
run: echo skip ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/build
*.swp
npm-debug.log
bin
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# minidump - Process minidump files [![Build Status](https://travis-ci.org/electron/node-minidump.svg?branch=master)](https://travis-ci.org/electron/node-minidump)
# minidump - Process minidump files

![CI](https://github.com/electron/node-minidump/workflows/CI/badge.svg)

## Installing

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

Dump debug symbols in minidump format from `binaryPath`, the `callback` would
be called with `callback(error, minidump)` upon completion.


## Releasing a new npm version
- Change the version in `package.json`, make a new git tag, and push it to GitHub.
- Wait until the GitHub Actions on the master branch pass.
- The artifacts of the latest GitHub Action run should be downloaded and placed under the `bin` folder
(replacing the old folder if it exists).

The bin folder should look like the following.
```
bin
|_linux-x64
|_dump_syms
|_minidump_dump
|_minidump_stackwalk
|_darwin-x64
|_dump_syms
|_minidump_dump
|_minidump_stackwalk
```

- Then:
```
npm publish
```
36 changes: 36 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')

const exe = process.platform === 'win32' ? '.exe' : ''
const binDir = path.join(__dirname, 'bin', `${process.platform}-${process.arch}`)

const minidumpStackwalkDest = path.join(binDir, 'minidump_stackwalk') + exe
const minidumpDumpDest = path.join(binDir, 'minidump_dump') + exe
const dumpSymsDest = path.join(binDir, 'dump_syms') + exe

// do not build if executables already exist
if (
fs.existsSync(minidumpStackwalkDest) &&
fs.existsSync(minidumpDumpDest) &&
fs.existsSync(dumpSymsDest)
) {
process.exit(0)
}

function spawnSync (...args) {
const result = childProcess.spawnSync(...args)
if (result.status !== 0) {
Expand Down Expand Up @@ -36,3 +52,23 @@ if (process.platform === 'darwin') {
stdio: 'inherit'
})
}

// copy to bin folder
if (!fs.existsSync(binDir)) {
fs.mkdirSync(binDir, { recursive: true })
}

const minidumpStackwalk = path.resolve(__dirname, 'build', 'src', 'processor', 'minidump_stackwalk') + exe
fs.copyFileSync(minidumpStackwalk, minidumpStackwalkDest)

const minidumpDump = path.resolve(__dirname, 'build', 'src', 'processor', 'minidump_dump') + exe
fs.copyFileSync(minidumpDump, minidumpDumpDest)

const dumpSyms = (() => {
if (process.platform === 'darwin') {
return path.resolve(__dirname, 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms')
} else if (process.platform === 'linux') {
return path.resolve(__dirname, 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms')
}
})()
fs.copyFileSync(dumpSyms, dumpSymsDest)
14 changes: 5 additions & 9 deletions lib/minidump.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ const spawn = require('child_process').spawn
const format = require('./format')

const exe = process.platform === 'win32' ? '.exe' : ''
const binDir = path.join(path.dirname(__dirname), 'bin', `${process.platform}-${process.arch}`)

const commands = {
minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe,
minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe,
dump_syms: (() => {
if (process.platform === 'darwin') {
return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms')
} else if (process.platform === 'linux') {
return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms')
}
})()
minidump_stackwalk: path.join(binDir, 'minidump_stackwalk') + exe,
minidump_dump: path.join(binDir, 'minidump_dump') + exe,
dump_syms: path.join(binDir, 'dump_syms') + exe
}

function execute (command, args, callback) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"/lib",
"index.d.ts",
"build.js",
"deps"
"deps",
"bin"
]
}