Skip to content

Commit 208d600

Browse files
authored
Merge pull request #11 from gristlabs/build-binaries
prepare for adding prebuild binaries to releases
2 parents 2f5f8c4 + 9e71bd8 commit 208d600

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1619
-2186
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
"extends": "eslint:recommended",
33
"env": {
4+
"es2017": true,
45
"node": true
56
},
67
"rules": {
@@ -9,4 +10,4 @@ module.exports = {
910
"semi": ["error", "always"],
1011
"no-cond-assign": ["error", "always"]
1112
}
12-
}
13+
};

.github/CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Contributing
2+
3+
General guidelines for contributing to node-sqlite3
4+
5+
## Install Help
6+
7+
If you've landed here due to a failed install of `node-sqlite3` then feel free to create a [new issue](https://github.com/tryghost/node-sqlite3/issues/new) to ask for help. The most likely problem is that we do not yet provide pre-built binaries for your particular platform and so the `node-sqlite3` install attempted a source compile but failed because you are missing the [dependencies for node-gyp](https://github.com/nodejs/node-gyp#installation). Provide as much detail on your problem as possible and we'll try to help. Include:
8+
9+
- Logs of failed install (preferably from running `npm install sqlite3 --loglevel=info`)
10+
- Version of `node-sqlite3` you tried to install
11+
- Node version you are running
12+
- Operating system and architecture you are running, e.g. `Windows 7 64 bit`.
13+
14+
The release process is documented in the wiki: https://github.com/TryGhost/node-sqlite3/wiki/Release-process

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 🐛 Bug report
2+
description: Report a reproducible issue
3+
labels: ["bug"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## Welcome 👋
9+
Thank you for taking the time to fill out a bug report 🙂
10+
11+
The more information you provide, the easier & quicker it is for us to diagnose the problem.
12+
13+
Please search the existing issues and recent releases to make sure your problem hasn't already been solved.
14+
- type: textarea
15+
id: summary
16+
attributes:
17+
label: Issue Summary
18+
description: Explain what's wrong
19+
validations:
20+
required: true
21+
- type: textarea
22+
id: reproduction
23+
attributes:
24+
label: Steps to Reproduce
25+
description: Also tell us, what did you expect to happen?
26+
placeholder: |
27+
1. This is the first step...
28+
2. This is the second step, etc.
29+
validations:
30+
required: true
31+
- type: input
32+
id: version
33+
attributes:
34+
label: Version
35+
description: What version of `node-sqlite3` are you using?
36+
validations:
37+
required: true
38+
- type: input
39+
id: node
40+
attributes:
41+
label: Node.js Version
42+
validations:
43+
required: true
44+
- type: input
45+
id: os
46+
attributes:
47+
label: How did you install the library?
48+
description: Provide details of your operating system and architecture
49+
validations:
50+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 📖 API documentation
4+
url: https://github.com/TryGhost/node-sqlite3/wiki/API
5+
about: Documentation for the `node-sqlite3` API
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: ✨ Feature request
2+
description: Request a desired feature
3+
labels: ["feature request"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## Welcome 👋
9+
Thank you for taking the time to fill out a feature request
10+
11+
The more information you provide, the easier it is for us to understand your use case.
12+
- type: textarea
13+
id: summary
14+
attributes:
15+
label: Summary
16+
description: Explain your use case. How would this improve your life?
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: reproduction
21+
attributes:
22+
label: Proposed implementation
23+
description: Give an API proposal. How would the feature work?
24+
placeholder: |
25+
The Database class has a new function called...
26+
validations:
27+
required: true
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: ⚙️ Installation problem
2+
description: Report an issue installing the library
3+
labels: ["install problem"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## Welcome 👋
9+
Thank you for taking the time to fill out a report with installing 🙂
10+
11+
The more information you provide, the easier & quicker it is for us to diagnose the problem.
12+
13+
Please search the existing issues and recent releases to make sure your problem hasn't already been solved.
14+
- type: textarea
15+
id: summary
16+
attributes:
17+
label: Issue Summary
18+
description: Explain what's wrong
19+
validations:
20+
required: true
21+
- type: textarea
22+
id: logs
23+
attributes:
24+
label: Relevant logs or output
25+
placeholder: |
26+
Error when installing `sqlite3` due to...
27+
validations:
28+
required: true
29+
- type: input
30+
id: version
31+
attributes:
32+
label: Version
33+
description: What version of `node-sqlite3` are you using?
34+
validations:
35+
required: true
36+
- type: input
37+
id: node
38+
attributes:
39+
label: Node.js Version
40+
validations:
41+
required: true
42+
- type: input
43+
id: os
44+
attributes:
45+
label: How did you install the library?
46+
description: Provide details of your operating system and architecture
47+
validations:
48+
required: true

.github/workflows/ci.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: CI
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- grist-main
9+
- grist-main-dev
10+
tags:
11+
- '*'
12+
env:
13+
FORCE_COLOR: 1
14+
concurrency:
15+
group: ${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
jobs:
18+
build:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os:
24+
- macos-latest
25+
- ubuntu-20.04
26+
- windows-latest
27+
host:
28+
- x64
29+
target:
30+
- x64
31+
node:
32+
- 14
33+
- 16
34+
- 18
35+
include:
36+
- os: windows-latest
37+
node: 16
38+
host: x86
39+
target: x86
40+
# This is a self-hosted runner, github doesn't have this architecture yet.
41+
- os: macos-m1
42+
node: 16
43+
host: arm64
44+
target: arm64
45+
name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }})
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: actions/setup-node@v3
49+
with:
50+
node-version: ${{ matrix.node }}
51+
architecture: ${{ matrix.host }}
52+
53+
- name: Add yarn (self-hosted)
54+
if: matrix.os == 'macos-m1'
55+
run: npm install -g yarn
56+
57+
- name: Add msbuild to PATH
58+
uses: microsoft/setup-msbuild@v1.1
59+
if: contains(matrix.os, 'windows')
60+
with:
61+
msbuild-architecture: ${{ matrix.target }}
62+
63+
- name: Install dependencies
64+
run: yarn install --ignore-scripts
65+
66+
- name: Add env vars
67+
shell: bash
68+
run: |
69+
echo "V=1" >> $GITHUB_ENV
70+
71+
if [ "${{ matrix.target }}" = "x86" ]; then
72+
echo "TARGET=ia32" >> $GITHUB_ENV
73+
else
74+
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
75+
fi
76+
77+
- name: Add Linux env vars
78+
if: contains(matrix.os, 'ubuntu')
79+
run: |
80+
echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
81+
echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
82+
83+
- name: Configure build
84+
run: yarn node-pre-gyp configure --target_arch=${{ env.TARGET }}
85+
86+
- name: Build binaries
87+
run: yarn node-pre-gyp build --target_arch=${{ env.TARGET }}
88+
89+
- name: Print binary info
90+
if: contains(matrix.os, 'ubuntu')
91+
run: |
92+
ldd lib/binding/*/node_sqlite3.node
93+
echo "---"
94+
nm lib/binding/*/node_sqlite3.node | grep "GLIBC_" | c++filt || true
95+
echo "---"
96+
file lib/binding/napi-v*/*
97+
98+
- name: Run tests
99+
run: yarn test
100+
101+
- name: Package prebuilt binaries
102+
run: yarn node-pre-gyp package --target_arch=${{ env.TARGET }}
103+
104+
- name: Upload binaries to commit artifacts
105+
uses: actions/upload-artifact@v3
106+
if: matrix.node == 16
107+
with:
108+
name: prebuilt-binaries
109+
path: build/stage/*/*
110+
retention-days: 7
111+
112+
- name: Upload binaries to GitHub Release
113+
run: yarn node-pre-gyp-github publish
114+
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
115+
env:
116+
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
117+
build-qemu:
118+
runs-on: ubuntu-latest
119+
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
node:
124+
- 16
125+
target:
126+
- linux/arm64
127+
variant:
128+
- bullseye
129+
- alpine3.15
130+
include:
131+
# musl x64 builds
132+
- target: linux/amd64
133+
variant: alpine3.15
134+
node: 16
135+
name: ${{ matrix.variant }} (node=${{ matrix.node }}, target=${{ matrix.target }})
136+
steps:
137+
- uses: actions/checkout@v3
138+
139+
- name: Set up QEMU
140+
uses: docker/setup-qemu-action@v2
141+
142+
- name: Setup Docker Buildx
143+
uses: docker/setup-buildx-action@v2
144+
145+
- name: Build binaries and test
146+
run: |
147+
docker buildx build \
148+
--file ./tools/BinaryBuilder.Dockerfile \
149+
--load \
150+
--tag sqlite-builder \
151+
--platform ${{ matrix.target }} \
152+
--no-cache \
153+
--build-arg VARIANT=${{ matrix.variant }} \
154+
--build-arg NODE_VERSION=${{ matrix.node }} \
155+
.
156+
CONTAINER_ID=$(docker create -it sqlite-builder)
157+
docker cp $CONTAINER_ID:/usr/src/build/build/ ./build
158+
159+
- name: Upload binaries to commit artifacts
160+
uses: actions/upload-artifact@v3
161+
if: matrix.node == 16
162+
with:
163+
name: prebuilt-binaries
164+
path: build/stage/*/*
165+
retention-days: 7
166+
167+
- name: Upload binaries to GitHub Release
168+
run: yarn install --ignore-scripts && yarn node-pre-gyp-github publish
169+
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
170+
env:
171+
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ test/nw/app.nw
2323
.dtps
2424
local.env
2525
.mason
26-
.eslintrc.js
2726
setup.sh
2827
/build-tmp-napi-v3
28+
/build-tmp-napi-v6
29+
*.tgz
30+
package-lock.json
31+
yarn.lock

.npmignore

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

0 commit comments

Comments
 (0)