Skip to content

Test npm package

Test npm package #54

Workflow file for this run

name: Test npm package
on:
workflow_dispatch:
inputs:
version:
description: "Package version to test"
required: true
im_version:
description: "ImageMagick commit-ish to checkout"
required: false
default: 'main'
jobs:
test_npm_rebuild:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- macos-12
node-version: [18.x, 20.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Create package.json
run: npm init --yes
- name: Install fonts on Ubuntu
run: |
[[ '${{ matrix.platform }}' =~ 'ubuntu' ]] && sudo apt-get install -y fonts-ubuntu || true
shell: bash
- name: Set up the unit tests
run: |
curl https://codeload.github.com/mmomtchev/magickwand.js/zip/refs/tags/v${{ github.event.inputs.version }} --output repo.zip
unzip repo.zip
mv magickwand.js-${{ github.event.inputs.version }}/test .
- name: Install dependencies
run: |
npm i chai chai-spies chai-as-promised mocha typescript ts-node tsconfig-paths \
@types/chai @types/chai-as-promised @types/mocha @types/node \
karma karma-chrome-launcher karma-mocha webpack webpack-cli ts-loader
shell: bash
- name: Install magickwand.js from npm
run: |
[[ '${{ matrix.platform }}' =~ 'windows' ]] && subst M: `pwd` && cd M:/
npm install --verbose magickwand.js@${{ github.event.inputs.version }}
mkdir -p deps/ImageMagick/config
cp node_modules/magickwand.js/deps/ImageMagick/config/policy-websafe.xml deps/ImageMagick/config
shell: bash
- run: ls -alR node_modules/magickwand.js
- run: |
cd node_modules/magickwand.js
node scripts/install.mjs
env:
npm_config_loglevel: verbose
npm_config_build_from_source: true
- name: Run the unit tests headless
uses: GabrielBB/xvfb-action@v1
with:
run: npx mocha --require ts-node/register --types mocha --reporter=tap --v8-expose-gc --timeout 5000 test/*.test.ts
env:
TS_NODE_PROJECT: ${{ github.workspace }}/test/tsconfig.standalone.json
MOCHA_INTEGRATION: node,browser
MOCHA_MAGICK_INSTALL: npm install --force magickwand.js@${{ github.event.inputs.version }}