Skip to content

Commit

Permalink
switch all normal build to the reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Sep 27, 2024
1 parent 204733b commit b6bf009
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 230 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ on:
install_cmd:
type: string
description: install command to use for the integration tests
extra_npm_opts:
type: string
default: ''
description: extra npm options

jobs:
build:
Expand All @@ -48,6 +52,11 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.53
if: inputs.wasm
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -82,26 +91,33 @@ jobs:
- name: Build magickwand.js
run: |
npm install --verbose --foreground-scripts \
${{ inputs.native && '--build-from-source' || '--skip-magickwand-native' }}
${{ inputs.wasm && '--build-wasm-from-source' || '--skip-magickwand-wasm' }}
${{ inputs.dependencies == 'conan' && '--enable-conan' || '--disable-conan' }}
${{ inputs.native && '--build-from-source' || '--skip-magickwand-native' }} \
${{ inputs.wasm && '--build-wasm-from-source' || '--skip-magickwand-wasm' }} \
${{ inputs.dependencies == 'conan' && '--enable-conan' || '--disable-conan' }} \
${{ inputs.extra_npm_opts }}
# Because of https://github.com/mmomtchev/hadron/issues/37
env:
C_INCLUDE_PATH: /usr/local/include
CPLUS_INCLUDE_PATH: /usr/local/include
- name: Check size
run: |
echo "::notice::WASM version is $(( `gzip -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes gzipped"
echo "::notice::WASM version is $(( `brotli -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes brotlied"
if: inputs.wasm
- name: Locate addon file
shell: bash
id: addon
run: node -p '"addon=" + path.resolve(__dirname, "lib", "binding", `${os.platform()}-${os.arch()}`, "magickwand.node")' >> $GITHUB_OUTPUT
if: inputs.native
- name: List linked libraries (Linux)
run: ldd ${{ steps.addon.outputs.addon }}
if: runner.os == 'Linux'
if: runner.os == 'Linux' && inputs.native
- name: List linked libraries (macOS)
run: otool -L ${{ steps.addon.outputs.addon }}
if: runner.os == 'macOS'
if: runner.os == 'macOS' && inputs.native
- run: npx mocha test/node.test.ts test/integration.test.ts
env:
MOCHA_INTEGRATION: ${{ inputs.integration }}
MOCHA_MAGICK_INSTALL: ${{ inputs.install }}
MOCHA_MAGICK_INSTALL: ${{ inputs.install_cmd }}
MOCHA_LIGHT: ${{ inputs.light }}
MOCHA_EXTRALIGHT: ${{ inputs.extralight }}
270 changes: 46 additions & 224 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,87 +72,39 @@ jobs:

uses:
mmomtchev/magickwand.js/.github/workflows/build.yml@xpack-install

with:
native: true
wasm: false
platform: ${{ matrix.platform }}
dependencies: ${{ matrix.dependencies }}
integration: 'node'
install_cmd: "node -e \"fs.symlinkSync(process.env.GITHUB_WORKSPACE, path.resolve('node_modules', 'magickwand.js'), os.platform() == 'win32' ? 'junction': 'dir')\""
install_cmd: "node -e \"fs.symlinkSync(process.env.GITHUB_WORKSPACE, path.resolve('node_modules', 'magickwand.js'), os.platform() == 'win32' ? 'junction': 'dir')\""
light: ${{ matrix.dependencies == 'conan' && '' || '1' }}
extralight: ${{ matrix.dependencies == 'system' && startsWith(matrix.platform, 'windows') }}


native-light:
runs-on: ${{ matrix.platform }}
needs: swig

strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Install the xpacks
run: |
npm install xpm
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
run: |
npx xpm run -q conan -- version
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ${{ steps.conan_home.outputs.path }}
key: linux-light-conan
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
shell: bash
- name: Build magickwand.js
run: |
npm install --build-from-source --verbose --foreground-scripts --enable-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 \
--skip-magickwand-wasm
- name: Locate addon file
shell: bash
id: addon
run: node -p '"addon=" + path.resolve(__dirname, "lib", "binding", `${os.platform()}-${os.arch()}`, "magickwand.node")' >> $GITHUB_OUTPUT
- name: List linked libraries (Linux)
run: ldd ${{ steps.addon.outputs.addon }}
if: runner.os == 'Linux'
- name: List linked libraries (macOS)
run: otool -L ${{ steps.addon.outputs.addon }}
if: runner.os == 'macOS'
- run: npx mocha test/node.test.ts
env:
MOCHA_LIGHT: 1
uses:
mmomtchev/magickwand.js/.github/workflows/build.yml@xpack-install
with:
native: true
wasm: false
platform: ${{ matrix.platform }}
dependencies: 'conan'
integration: ''
install_cmd: ''
light: true
extra_npm_opts: '--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'


native-xpack:
runs-on: ${{ matrix.platform }}
needs: swig

strategy:
Expand All @@ -166,62 +118,16 @@ jobs:
- macos-latest
- windows-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Install the xpacks
run: |
npm install xpm
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
run: |
npx xpm run -q conan -- version
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ${{ steps.conan_home.outputs.path }}
key: conan-xpack-${{ matrix.platform }}
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Do not use GHA pkg-config on Windows
shell: bash
run: rm `which pkg-config`*
if: runner.os == 'Windows'
- name: Build with xPack
run: npm install --build-from-source --verbose --foreground-scripts --skip-magickwand-wasm --enable-conan --enable-standalone-build
env:
C_INCLUDE_PATH: /usr/local/include
CPLUS_INCLUDE_PATH: /usr/local/include
- name: Locate addon file
shell: bash
id: addon
run: node -p '"addon=" + path.resolve(__dirname, "lib", "binding", `${os.platform()}-${os.arch()}`, "magickwand.node")' >> $GITHUB_OUTPUT
- name: List linked libraries (Linux)
run: ldd ${{ steps.addon.outputs.addon }}
if: runner.os == 'Linux'
- name: List linked libraries (macOS)
run: otool -L ${{ steps.addon.outputs.addon }}
if: runner.os == 'macOS'
- run: npx mocha test/node.test.ts test/integration.test.ts
env:
MOCHA_INTEGRATION: node
MOCHA_MAGICK_INSTALL: "node -e \"fs.symlinkSync(process.env.GITHUB_WORKSPACE, path.resolve('node_modules', 'magickwand.js'), os.platform() == 'win32' ? 'junction': 'dir')\""
uses:
mmomtchev/magickwand.js/.github/workflows/build.yml@xpack-install
with:
native: true
wasm: false
platform: ${{ matrix.platform }}
dependencies: conan
integration: node
install_cmd: "node -e \"fs.symlinkSync(process.env.GITHUB_WORKSPACE, path.resolve('node_modules', 'magickwand.js'), os.platform() == 'win32' ? 'junction': 'dir')\""
extra_npm_opts: '--enable-standalone-build'


native-xpack-minimal-container:
Expand Down Expand Up @@ -286,123 +192,39 @@ jobs:


wasm:
runs-on: ubuntu-latest
needs: swig

strategy:
fail-fast: false
uses:
mmomtchev/magickwand.js/.github/workflows/build.yml@xpack-install
with:
native: false
wasm: true
platform: ubuntu-latest
dependencies: conan
integration: browser
install_cmd: 'ln -s ${{ github.workspace }} node_modules/magickwand.js'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.53
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Install the xpacks
run: |
npm install xpm
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
run: |
npx xpm run -q conan -- version
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ${{ steps.conan_home.outputs.path }}
key: wasm-conan
- name: Build magickwand.js
run: npm install --build-wasm-from-source --verbose --foreground-scripts --skip-magickwand-native --enable-conan
- name: Check size
run: |
echo "::notice::Default WASM version is $(( `gzip -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes gzipped"
echo "::notice::Default WASM version is $(( `brotli -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes brotlied"
- name: Run headless test
uses: coactions/setup-xvfb@v1
env:
MOCHA_INTEGRATION: browser
MOCHA_MAGICK_INSTALL: ln -s ${{ github.workspace }} node_modules/magickwand.js
with:
run: npx mocha test/browser.test.ts test/integration.test.ts

wasm-light:
runs-on: ubuntu-latest
needs: swig

strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]

uses:
mmomtchev/magickwand.js/.github/workflows/build.yml@xpack-install
with:
native: false
wasm: true
platform: ubuntu-latest
dependencies: conan
integration: browser
install_cmd: 'ln -s ${{ github.workspace }} node_modules/magickwand.js'
light: true
extra_npm_opts: '--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'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.53
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Install the xpacks
run: |
npm install xpm
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
run: |
npx xpm run -q conan -- version
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ${{ steps.conan_home.outputs.path }}
key: wasm-light-conan
- name: Build magickwand.js
run: |
npm install --build-wasm-from-source --verbose --foreground-scripts \
--enable-conan \
--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 \
--skip-magickwand-native
- name: Check size
run: |
echo "::notice::Light WASM version is $(( `gzip -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes gzipped"
echo "::notice::Light WASM version is $(( `brotli -9c lib/binding/emscripten-wasm32/magickwand.wasm | wc -c` / 1024 )) KBytes brotlied"
- name: Run headless test
uses: coactions/setup-xvfb@v1
env:
MOCHA_LIGHT: 1
MOCHA_INTEGRATION: browser
with:
run: npx mocha test/browser.test.ts

debug-asan:
runs-on: ${{ matrix.platform }}
Expand Down

0 comments on commit b6bf009

Please sign in to comment.