Skip to content

Test npm package

Test npm package #66

Workflow file for this run

name: Test npm package
on:
workflow_call:
inputs:
package:
type: string
default: magickwand.js@latest
description: package tarball or npm name to install
download:
type: boolean
default: false
description: whether the package artifact needs to be downloaded
workflow_dispatch:
inputs:
package:
type: string
default: magickwand.js@latest
description: package tarball or npm name to install
jobs:
test_npm_binaries:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- windows-2019
- windows-2022
- macos-12
- macos-latest
node-version: [18.x, 20.x, 22.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Create package.json
run: npm init --yes
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Install dependencies
run: |
npm i chai@4.3.7 chai-as-promised@7.1.2 mocha typescript ts-node tsconfig-paths \
@types/chai@4.3.16 @types/chai-as-promised@7.1.8 @types/mocha @types/node \
karma karma-chrome-launcher karma-mocha webpack webpack-cli ts-loader
shell: bash
- name: Download the package
uses: robinraju/release-downloader@v1.11
with:
tag: ${{ github.ref_name }}
fileName: ${{ inputs.package }}
if: inputs.download
- name: Install magickwand.js from ${{ inputs.package }}
run: npm install ${{ inputs.package }}
shell: bash
- name: Set up the unit tests
shell: bash
run: |
mv node_modules/magickwand.js/test .
mkdir -p deps/ImageMagick/config
cp node_modules/magickwand.js/deps/ImageMagick/config/policy-websafe.xml deps/ImageMagick/config
- name: Run the unit tests headless (macOS/Windows)
run: npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os != 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
- name: Run the unit tests headless (Linux)
run: xvfb-run npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os == 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
test_npm_rebuild:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- windows-2022
- macos-12
- macos-latest
node-version: [18.x, 20.x, 22.x]
steps:
- name: Enable long paths on Windows
run: git config --system core.longpaths true
if: runner.os == 'Windows'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.53
if: runner.os == 'Linux'
- name: Create package.json
run: npm init --yes
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Install dependencies
run: |
npm i chai@4.3.7 chai-as-promised@7.1.2 mocha typescript ts-node tsconfig-paths \
@types/chai@4.3.16 @types/chai-as-promised@7.1.8 @types/mocha @types/node \
karma karma-chrome-launcher karma-mocha webpack webpack-cli ts-loader
shell: bash
- name: Download the package
uses: robinraju/release-downloader@v1.11
with:
tag: ${{ github.ref_name }}
fileName: ${{ inputs.package }}
if: inputs.download
- name: Install magickwand.js from ${{ inputs.package }}
run: |
npm install --verbose --foreground-scripts \
${{ inputs.package }} --build-from-source \
${{ runner.os == 'Linux' && '--build-wasm-from-source' || '' }}
shell: bash
- name: Set up the unit tests
shell: bash
run: |
mv node_modules/magickwand.js/test .
mkdir -p deps/ImageMagick/config
cp node_modules/magickwand.js/deps/ImageMagick/config/policy-websafe.xml deps/ImageMagick/config
- name: Run the unit tests headless (macOS/Windows)
run: npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os != 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
MOCHA_LIGHT: 1
MOCHA_EXTRALIGHT: 1
- name: Run the unit tests headless (Linux)
run: xvfb-run npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os == 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
MOCHA_LIGHT: 1
MOCHA_EXTRALIGHT: 1
test_npm_rebuild_light:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-22.04
node-version: [18.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Create package.json
run: npm init --yes
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Download the package
uses: robinraju/release-downloader@v1.11
with:
tag: ${{ github.ref_name }}
fileName: ${{ inputs.package }}
if: inputs.download
- name: Install magickwand.js from ${{ inputs.package }}
run: |
npm install --verbose --foreground-scripts \
${{ inputs.package }} --build-from-source --disable-shared \
--disable-fonts --enable-jpeg --enable-png --disable-tiff \
--disable-webp --disable-jpeg2000 --disable-raw --disable-openmedia \
--disable-brotli --disable-h265 --disable-exr --disable-fftw --disable-heif \
--disable-color --disable-xml --enable-gzip --disable-zip \
--disable-bzip2 --disable-zstd --disable-xz --disable-lzma --disable-simd \
--disable-openmp --disable-display --disable-jbig --disable-cairo
shell: bash
- name: Test loading the package
run: node -p 'require("magickwand.js/native").MagickCore.GetMagickDelegates()'
test_npm_rebuild_shared:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-20.04]
node-version: [18.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
with:
repository: 'imagemagick/ImageMagick'
path: 'ImageMagick'
ref: ${{ github.event.inputs.im_version }}
- name: Build and install ImageMagick-7
run: |
cd ImageMagick
sh configure --prefix /usr
make -j4
sudo make install
- name: Create package.json
run: npm init --yes
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Install dependencies
run: |
npm i chai@4.3.7 chai-as-promised@7.1.2 mocha typescript ts-node tsconfig-paths \
@types/chai@4.3.16 @types/chai-as-promised@7.1.8 @types/mocha @types/node \
karma karma-chrome-launcher karma-mocha webpack webpack-cli ts-loader
shell: bash
- name: Download the package
uses: robinraju/release-downloader@v1.11
with:
tag: ${{ github.ref_name }}
fileName: ${{ inputs.package }}
if: inputs.download
- name: Install magickwand.js from ${{ inputs.package }}
run: |
npm install --verbose --foreground-scripts=true \
${{ inputs.package }} \
--build-from-source \
--enable-external --enable-shared \
--cpp-args="`pkg-config --cflags Magick++`" \
--cpp-link-args="`pkg-config --libs Magick++`"
env:
CFLAGS: -I/usr/include/ImageMagick-7
CXXFLAGS: -I/usr/include/ImageMagick-7
shell: bash
- name: Set up the unit tests
shell: bash
run: |
mv node_modules/magickwand.js/test .
mkdir -p deps/ImageMagick/config
cp node_modules/magickwand.js/deps/ImageMagick/config/policy-websafe.xml deps/ImageMagick/config
- name: Run the unit tests headless (macOS/Windows)
run: npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os != 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
MOCHA_LIGHT: 1
MOCHA_EXTRALIGHT: 1
- name: Run the unit tests headless (Linux)
run: xvfb-run npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
if: runner.os == 'Linux'
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force ${{ inputs.download && format('{0}/{1}', github.workspace, inputs.package) || inputs.package }}
MOCHA_LIGHT: 1
MOCHA_EXTRALIGHT: 1