Skip to content
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

final test - hopefully #37

Closed
wants to merge 14 commits into from
Closed
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
22 changes: 22 additions & 0 deletions .github/docker/Dockerfile.glibc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG UBUNTU_VERSION=bionic
FROM ubuntu:${UBUNTU_VERSION} AS build

ARG NODE_VERSION=16.20.1
# Possible values: s390x, arm64, x64
ARG NODE_ARCH
ADD https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.gz /
RUN mkdir -p /nodejs && tar -xzf /node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.gz --strip-components=1 -C /nodejs
ENV PATH=$PATH:/nodejs/bin

WORKDIR /zstd
COPY . .

RUN apt-get -qq update
RUN apt-get -qq install -y python3 build-essential curl cmake
RUN python3 --version

RUN npm run install-zstd
RUN npm install

ARG RUN_TEST
RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi
14 changes: 14 additions & 0 deletions .github/docker/Dockerfile.musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

ARG PLATFORM=arm64
ARG NODE_VERSION=16.20.1

FROM ${PLATFORM}/node:${NODE_VERSION}-alpine AS node

WORKDIR /zstd
COPY . .

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

ARG RUN_TEST
RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi
89 changes: 64 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,41 @@ on:
name: Test

jobs:
host_tests:
strategy:
matrix:
# os: [macos-latest, windows-2019]
os: ['ubuntu-latest']
node: [16.20.1, 18.x, 20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# host_tests:
# strategy:
# matrix:
# os: [macos-latest, windows-2019]
# node: [16.20.1, 18.x, 20.x, 22.x]
# fail-fast: false
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node }}
# cache: "npm"
# registry-url: "https://registry.npmjs.org"

- name: Install zstd
run: npm run install-zstd
shell: bash
# - name: Install zstd
# run: npm run install-zstd
# shell: bash

- name: install dependencies and compmile
run: npm install --loglevel verbose
shell: bash
# - name: install dependencies and compmile
# run: npm install --loglevel verbose
# shell: bash

- name: Test ${{ matrix.os }}
shell: bash
run: npm test
# - name: Test ${{ matrix.os }}
# shell: bash
# run: npm test

# container_tests:
# container_tests_glibc:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# linux_arch: [s390x, arm64, amd64]
# node: [16.x, 18.x, 20.x, 22.x]
# fail-fast: false
# steps:
# - uses: actions/checkout@v4

Expand Down Expand Up @@ -73,4 +74,42 @@ jobs:
# --build-arg="RUN_TEST=true" \
# --output type=local,dest=./prebuilds,platform-split=false \
# -f ./.github/docker/Dockerfile.glibc \
# .
# .

container_tests_musl_amd64:
runs-on: ubuntu-latest
strategy:
matrix:
linux_arch: [amd64, arm64]
node: [16.20.1, 18.x, 20.x, 22.x]
fail-fast: false
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Get Full Node.js Version
id: get_nodejs_version
shell: bash
run: |
echo "version=$(node --print 'process.version.slice(1)')" >> "$GITHUB_OUTPUT"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run Buildx
run: |
docker buildx create --name builder --bootstrap --use
docker --debug buildx build --progress=plain --no-cache \
--platform linux/${{ matrix.linux_arch }} \
--build-arg="PLATFORM=${{ matrix.linux_arch == 'arm64' && 'arm64v8' || matrix.linux_arch }}" \
--build-arg="NODE_VERSION=${{ steps.get_nodejs_version.outputs.version }}" \
--build-arg="RUN_TEST=true" \
--output type=local,dest=./prebuilds,platform-split=false \
-f ./.github/docker/Dockerfile.musl \
.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ build

npm-debug.log
deps

prebuilds
3 changes: 2 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"extension": ["ts"],
"recursive": true,
"failZero": true,
"color": true
"color": true,
"timeout": 0
}
2 changes: 1 addition & 1 deletion addon/compression.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MONGODB_ZSTD_COMPRESSION
#define MONGODB_ZSTD_COMPRESSION

#include <exception>
#include <stdexcept>
#include <vector>

#include "compression_worker.h"
Expand Down
41 changes: 32 additions & 9 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,45 @@
'addon/compression.h',
'addon/compression.cpp'
],
'conditions': [
[
'OS=="win"',
{
'link_settings': {
'libraries': [
'<(module_root_dir)/deps/zstd/build/cmake/lib/Debug/zstd_static.lib'
]
},
},
{ # macos and linux
'link_settings': {
'libraries': [
'<(module_root_dir)/deps/zstd/build/cmake/lib/libzstd.a',
]
},
}
]
],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'cflags_cc': ['-std=c++17'],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '11',
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'OTHER_CFLAGS': [
'-std=c++17',
'-stdlib=libc++'
],
},
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'cflags_cc': ['-std=c++17'],
'msvs_settings': {
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
},
'link_settings': {
'libraries': [
'<(module_root_dir)/deps/zstd/build/cmake/lib/libzstd.a',
]
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'AdditionalOptions': [
'-std:c++17'
]
}
},
}]
}
47 changes: 47 additions & 0 deletions etc/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash

# script to aid in local testing of linux platforms
# requires a running docker instance

# s390x, arm64, amd64 for ubuntu
# amd64 or arm64v8 for alpine
LINUX_ARCH=arm64

# 16.20.1+, default 16.20.1
NODE_VERSION=18.0.0

SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
PROJECT_DIR=$SCRIPT_DIR/..

build_and_test_musl() {
docker buildx create --name builder --bootstrap --use

docker image pull arm64v8/node:18.0.0-alpine
docker --debug buildx build --load --progress=plain --no-cache \
--platform linux/$LINUX_ARCH --output=type=docker \
--build-arg="PLATFORM=arm64v8" \
--build-arg="NODE_VERSION=$NODE_VERSION" \
--build-arg="RUN_TEST=true" \
-f ./.github/docker/Dockerfile.musl \
.
}

build_and_test_glibc() {
docker buildx create --name builder --bootstrap --use

UBUNTU_VERSION=ubuntu_version=$(node --print '(process.argv[1].slice(1).split(`.`).at(0)) > 16 ? `noble` : `bionic`' $NODE_VERSION)
NODE_ARCH=$(node -p 'process.argv[1] === `amd64` && `x64` || process.argv[1]' $LINUX_ARCH)
echo $UBUNTU_VERSION
docker buildx build --progress=plain --no-cache \
--platform linux/$LINUX_ARCH \
--build-arg="NODE_ARCH=$NODE_ARCH" \
--build-arg="NODE_VERSION=$NODE_VERSION" \
--build-arg="UBUNTU_VERSION$UBUNTU_VERSION" \
--build-arg="RUN_TEST=true" \
--output type=local,dest=./prebuilds,platform-split=false \
-f ./.github/docker/Dockerfile.glibc \
$PROJECT_DIR
}


build_and_test_musl
6 changes: 4 additions & 2 deletions etc/install-zstd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ build_zstd() {
export MACOSX_DEPLOYMENT_TARGET=11
cd deps/zstd/build/cmake

cmake .
make
# CMAKE_RC_FLAGS is a workaround for a bug in 1.5.6 that breaks compilation on windows.
# The fix is merged but not yet released. see https://github.com/facebook/zstd/issues/3999
cmake -DCMAKE_RC_FLAGS="$(pwd)/lib" -DZSTD_MULTITHREAD_SUPPORT=OFF -DZSTD_BUILD_SHARED=OFF .
cmake --build .
}

clean_deps
Expand Down
Loading