Skip to content

Commit 0a69186

Browse files
chore(NODE-6578): add misc tooling to ZSTD repo (#36)
1 parent ec32fbe commit 0a69186

9 files changed

+223
-160
lines changed

.github/docker/Dockerfile.glibc

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ RUN python3 --version
1717

1818
RUN npm run install-zstd
1919
RUN npm install
20+
RUN npm run prebuild
2021

2122
ARG RUN_TEST
2223
RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi
24+
25+
FROM scratch
26+
27+
COPY --from=build /zstd/prebuilds/ /

.github/docker/Dockerfile.musl

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
ARG PLATFORM=arm64
33
ARG NODE_VERSION=16.20.1
44

5-
FROM ${PLATFORM}/node:${NODE_VERSION}-alpine AS node
5+
FROM ${PLATFORM}/node:${NODE_VERSION}-alpine AS build
66

77
WORKDIR /zstd
88
COPY . .
99

1010
RUN apk --no-cache add make g++ libc-dev curl bash python3 py3-pip vim cmake
1111
RUN npm run install-zstd && npm i
12+
RUN npm run prebuild
1213

1314
ARG RUN_TEST
1415
RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi
16+
17+
18+
FROM scratch
19+
20+
COPY --from=build /zstd/prebuilds/ /

.github/workflows/build.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
on:
2+
pull_request:
3+
branches: [main]
4+
workflow_dispatch: {}
5+
workflow_call: {}
6+
7+
name: Build
8+
9+
jobs:
10+
host_tests:
11+
strategy:
12+
matrix:
13+
os: [macos-latest, windows-2019]
14+
fail-fast: false
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 16.20.1
22+
cache: "npm"
23+
registry-url: "https://registry.npmjs.org"
24+
25+
- name: Install zstd
26+
run: npm run install-zstd
27+
shell: bash
28+
29+
- name: install dependencies and compile
30+
run: npm install --loglevel verbose && npm run prebuild
31+
shell: bash
32+
33+
- id: upload
34+
name: Upload prebuild
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: build-${{ matrix.os }}
38+
path: prebuilds/
39+
if-no-files-found: "error"
40+
retention-days: 1
41+
compression-level: 0
42+
43+
container_tests_glibc:
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
linux_arch: [s390x, arm64, amd64]
48+
fail-fast: false
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: ${{ matrix.node }}
55+
56+
- name: Set up QEMU
57+
uses: docker/setup-qemu-action@v3
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Run Buildx
63+
run: |
64+
docker buildx create --name builder --bootstrap --use
65+
docker buildx build \
66+
--platform linux/${{ matrix.linux_arch }} \
67+
--build-arg="NODE_ARCH=${{ matrix.linux_arch == 'amd64' && 'x64' || matrix.linux_arch }}" \
68+
--build-arg="NODE_VERSION=16.20.1" \
69+
--output type=local,dest=./prebuilds,platform-split=false \
70+
-f ./.github/docker/Dockerfile.glibc \
71+
.
72+
73+
- id: upload
74+
name: Upload prebuild
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: build-linux-glibc-${{ matrix.linux_arch }}
78+
path: prebuilds/
79+
if-no-files-found: "error"
80+
retention-days: 1
81+
compression-level: 0
82+
83+
container_tests_musl:
84+
runs-on: ubuntu-latest
85+
strategy:
86+
matrix:
87+
linux_arch: [amd64, arm64]
88+
fail-fast: false
89+
steps:
90+
- uses: actions/checkout@v4
91+
92+
- uses: actions/setup-node@v4
93+
with:
94+
node-version: ${{ matrix.node }}
95+
96+
- name: Set up QEMU
97+
uses: docker/setup-qemu-action@v3
98+
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v3
101+
102+
- name: Run Buildx
103+
run: |
104+
docker buildx create --name builder --bootstrap --use
105+
docker --debug buildx build --progress=plain --no-cache \
106+
--platform linux/${{ matrix.linux_arch }} \
107+
--build-arg="PLATFORM=${{ matrix.linux_arch == 'arm64' && 'arm64v8' || matrix.linux_arch }}" \
108+
--build-arg="NODE_VERSION=16.20.1" \
109+
--output type=local,dest=./prebuilds,platform-split=false \
110+
-f ./.github/docker/Dockerfile.musl \
111+
.
112+
113+
- id: upload
114+
name: Upload prebuild
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: build-linux-musl-${{ matrix.linux_arch }}
118+
path: prebuilds/
119+
if-no-files-found: "error"
120+
retention-days: 1
121+
compression-level: 0

.github/workflows/codeql.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
analyze:
11+
name: Analyze (${{ matrix.language }})
12+
runs-on: "ubuntu-latest"
13+
timeout-minutes: 360
14+
permissions:
15+
# required for all workflows
16+
security-events: write
17+
18+
# required to fetch internal or private CodeQL packs
19+
packages: read
20+
21+
# only required for workflows in private repositories
22+
actions: read
23+
contents: read
24+
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- language: "c-cpp"
30+
build-mode: "manual"
31+
sourceDirectory: "./addon"
32+
- language: "javascript-typescript"
33+
build-mode: "none"
34+
sourceDirectory: "./lib"
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
# Initializes the CodeQL tools for scanning.
40+
- name: Initialize CodeQL
41+
uses: github/codeql-action/init@v3
42+
with:
43+
languages: ${{ matrix.language }}
44+
build-mode: ${{ matrix.build-mode }}
45+
source-root: ${{ matrix.sourceDirectory }}
46+
47+
- if: matrix.build-mode == 'manual'
48+
shell: bash
49+
run: npm i --ignore-scripts && npm run install-zstd && npm run compile
50+
51+
- name: Perform CodeQL Analysis
52+
uses: github/codeql-action/analyze@v3
53+
with:
54+
category: "/language:${{matrix.language}}"

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.0.0-beta.0"
3+
}

etc/install-zstd.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ clean_deps() {
88
download_zstd() {
99
rm -rf deps
1010
mkdir -p deps/zstd
11+
ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']")
1112

12-
curl -L "https://github.com/facebook/zstd/releases/download/v1.5.6/zstd-1.5.6.tar.gz" \
13+
curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \
1314
| tar -zxf - -C deps/zstd --strip-components 1
1415
}
1516

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"install-zstd": "bash etc/install-zstd.sh",
3939
"check:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint *ts lib/*.js test/*.js .*.json",
4040
"clang-format": "clang-format --style=file:.clang-format --Werror -i addon/*",
41-
"check:clang-format": "clang-format --style=file:.clang-format --dry-run --Werror addon/*"
41+
"check:clang-format": "clang-format --style=file:.clang-format --dry-run --Werror addon/*",
42+
"prebuild": "prebuild --runtime napi --strip --verbose --all"
4243
},
4344
"overrides": {
4445
"prebuild": {
@@ -49,5 +50,6 @@
4950
"napi_versions": [
5051
4
5152
]
52-
}
53-
}
53+
},
54+
"mongodb:zstd_version": "1.5.6"
55+
}

release-please-config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pull-request-header": "Please run the release_notes action before releasing to generate release highlights",
3+
"packages": {
4+
".": {
5+
"include-component-in-tag": false,
6+
"changelog-path": "HISTORY.md",
7+
"release-type": "node",
8+
"bump-minor-pre-major": false,
9+
"bump-patch-for-minor-pre-major": false,
10+
"draft": false
11+
}
12+
},
13+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
14+
}

0 commit comments

Comments
 (0)