diff --git a/.github/workflows/main-aarch64.yml b/.github/workflows/main-aarch64.yml index 45613908..aaa2230a 100644 --- a/.github/workflows/main-aarch64.yml +++ b/.github/workflows/main-aarch64.yml @@ -1,4 +1,4 @@ -# CI for native ARM64 Linux build and ARM WASM build. +# CI for native ARM64 Linux build. name: CI-aarch64 @@ -6,11 +6,6 @@ on: push: pull_request: workflow_dispatch: - inputs: - emsdk_version: - description: 'Emscripten SDK version (e.g. latest, 3.1.56)' - required: false - default: 'latest' jobs: simple_build_linux_arm: @@ -26,41 +21,3 @@ jobs: ./configure make database/database.h make -j$(nproc) - - simple_build_wasm_arm: - runs-on: ubuntu-24.04-arm - env: - EMSDK_VERSION: ${{ github.event.inputs.emsdk_version || 'latest' }} - steps: - - uses: actions/checkout@v4 - - name: Get Dependencies - run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install $EMSDK_VERSION - ./emsdk activate $EMSDK_VERSION - - name: Emscripten Diagnostic - run: | - source ./emsdk/emsdk_env.sh - echo "===== gcc -dM -E - =====" - echo | gcc -dM -E - | sort - echo "===== g++ -dM -E - =====" - echo | g++ -dM -E - | sort - echo "===== emcc -dM -E - =====" - echo | emcc -dM -E - | sort - echo "===== em++ -dM -E - =====" - echo | em++ -dM -E - | sort - - name: Build - run: | - source ./emsdk/emsdk_env.sh - CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 -g" emconfigure ./configure --without-cairo --without-opengl --without-x --without-tk --without-tcl --disable-readline --disable-compression --target=asmjs-unknown-emscripten - echo "===== defs.mak =====" - cat defs.mak - echo "===== defs.mak =====" - emmake make - - name: Archive WASM bundle - uses: actions/upload-artifact@v4 - with: - name: magic-wasm-bundle-arm - path: | - ${{ github.workspace }}/magic/magic.wasm diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/main-wasm.yml similarity index 61% rename from .github/workflows/npm-publish.yml rename to .github/workflows/main-wasm.yml index ef074941..177b94ed 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/main-wasm.yml @@ -1,27 +1,31 @@ -name: Publish npm package +name: CI-wasm -# Publishes magic-vlsi-wasm to GitHub Packages (npm.pkg.github.com). -# Triggered automatically on version tags (v*); can also be run manually. -# Requires the default GITHUB_TOKEN — no extra secret needed. +# Builds the Magic WebAssembly target on every push and pull request. +# On version tags (v*), additionally publishes magic-vlsi-wasm to GitHub +# Packages (npm.pkg.github.com). +# +# The primary goal of this workflow is to always build a WASM version and +# verify it against the example test suite. Publishing to a package repo is +# an optional, tag-gated extension of the same pipeline. # # Publishing to GitHub Packages first allows testing and evaluation before a -# wider release to the public npm registry. Consumers can install from here via -# npm with an appropriate .npmrc pointing at npm.pkg.github.com. +# wider release to the public npm registry. Consumers can install from there +# via npm with an appropriate .npmrc pointing at npm.pkg.github.com. # -# WASM is architecture-independent — built once on x86-64, usable everywhere. +# WASM is architecture-independent — built on x86-64 and ARM64 in parallel +# to verify the toolchain works on both, and to compare outputs. on: push: - tags: - - 'v*' + pull_request: workflow_dispatch: inputs: emsdk_version: - description: 'emsdk version to build with (default: pinned release; use "latest" to track HEAD)' + description: 'emsdk version to build with (default: latest; pin a version number to bisect)' type: string default: 'latest' dry_run: - description: 'Dry run: pack only, do not publish' + description: 'Dry run: pack only, do not publish even on tag pushes' type: boolean default: true @@ -32,7 +36,7 @@ env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true jobs: - build-and-publish: + build-wasm: runs-on: ubuntu-latest steps: @@ -46,10 +50,9 @@ jobs: - name: Install emsdk env: - # Pinned to match .github/workflows/main.yml (see post-build.sh for why the - # versions must stay in sync). The default here is the published-release pin; - # pass emsdk_version: 'latest' via workflow_dispatch to track emsdk HEAD and - # catch breakage before it affects a real release. + # Defaults to latest so CI tracks emsdk HEAD and catches breakage early. + # Override via workflow_dispatch to pin a specific version when needed + # (e.g. to bisect a regression or verify a post-build.sh patch still applies). EMSDK_VERSION: ${{ github.event.inputs.emsdk_version || 'latest' }} run: | git clone https://github.com/emscripten-core/emsdk.git @@ -57,6 +60,16 @@ jobs: ./emsdk install "$EMSDK_VERSION" ./emsdk activate "$EMSDK_VERSION" + # Dump native + emscripten preprocessor defines. Useful for diagnosing + # WASM-build differences after an emsdk bump. + - name: Emscripten Diagnostic + run: | + source ./emsdk/emsdk_env.sh + echo "===== gcc -dM -E - ====="; echo | gcc -dM -E - | sort + echo "===== g++ -dM -E - ====="; echo | g++ -dM -E - | sort + echo "===== emcc -dM -E - ====="; echo | emcc -dM -E - | sort + echo "===== em++ -dM -E - ====="; echo | em++ -dM -E - | sort + - name: Build WASM run: | source ./emsdk/emsdk_env.sh @@ -68,6 +81,8 @@ jobs: --target=asmjs-unknown-emscripten # Append WASM linker flags and activate the WASM link target cat toolchains/emscripten/defs.mak >> defs.mak + # Echo the merged defs.mak so CI logs show the exact build config + echo "===== defs.mak ====="; cat defs.mak; echo "===== defs.mak =====" # Build in order: techs must exist before mains (--embed-file embeds them) emmake make depend emmake make -j$(nproc) modules libs @@ -79,6 +94,24 @@ jobs: cp magic/magic.js npm/ cp magic/magic.wasm npm/ + - name: Run example tests + run: cd npm && npm run test + + # Dump generated text outputs (.ext, .spice, .cif, …) into the CI log + # so a regression in extraction / netlisting / cifoutput is visible + # without having to download artifacts. The .gds output is binary — + # skip it and just record its size. + - name: Display example outputs + run: | + shopt -s nullglob + for f in npm/examples/output/*; do + name=$(basename "$f") + case "$f" in + *.gds) echo "===== $name (binary, $(wc -c < "$f") bytes — skipped) =====" ;; + *) echo "===== $name ====="; cat "$f" ;; + esac + done + - name: Set package version run: | base=$(cat VERSION) # e.g. 8.3.637 @@ -96,7 +129,7 @@ jobs: - name: Upload tarball as artifact uses: actions/upload-artifact@v5 with: - name: magic-wasm-npm-package + name: magic-vlsi-wasm-npm path: npm/*.tgz - name: Publish to GitHub Packages @@ -120,10 +153,10 @@ jobs: ./emsdk install "$EMSDK_VERSION" ./emsdk activate "$EMSDK_VERSION" - - name: Emscripten diagnostics - # Captures compiler predefined macros for all four toolchains. - # Kept intentionally: emsdk changes over time and these logs are the - # fastest way to diagnose a broken build without reproducing it locally. + # Captures compiler predefined macros for all four toolchains. + # Kept intentionally: emsdk changes over time and these logs are the + # fastest way to diagnose a broken build without reproducing it locally. + - name: Emscripten Diagnostic run: | source ./emsdk/emsdk_env.sh echo "===== gcc -dM -E - ====="; echo | gcc -dM -E - | sort diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcb2ef6a..f367ab26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,17 +4,6 @@ on: push: pull_request: workflow_dispatch: - inputs: - emsdk_version: - description: 'emsdk version to build with (default: latest; use a version number to pin)' - type: string - default: 'latest' - -# actions/upload-artifact@v5 still runs on Node.js 20. Force Node 24 to -# silence the deprecation warning until upload-artifact ships a Node-24 -# release. Drop this once upgraded. -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true jobs: simple_build_linux: @@ -29,67 +18,3 @@ jobs: ./configure make database/database.h make -j$(nproc) - simple_build_wasm: - runs-on: ubuntu-latest - env: - # Defaults to latest so CI tracks emsdk HEAD and catches breakage early. - # Override via workflow_dispatch to pin a specific version when needed - # (e.g. to bisect a regression or verify a post-build.sh patch still applies). - EMSDK_VERSION: ${{ github.event.inputs.emsdk_version || 'latest' }} - steps: - - uses: actions/checkout@v5 - - name: Get Dependencies - run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install "$EMSDK_VERSION" - ./emsdk activate "$EMSDK_VERSION" - # Dump native + emscripten preprocessor defines. Useful for diagnosing - # WASM-build differences after an emsdk bump. - - name: Emscripten Diagnostic - run: | - source ./emsdk/emsdk_env.sh - echo "===== gcc -dM -E - =====" - echo | gcc -dM -E - | sort - echo "===== g++ -dM -E - =====" - echo | g++ -dM -E - | sort - echo "===== emcc -dM -E - =====" - echo | emcc -dM -E - | sort - echo "===== em++ -dM -E - =====" - echo | em++ -dM -E - | sort - - name: Build - run: | - source ./emsdk/emsdk_env.sh - # --without/--disable flags: no WASM library available for these features - CFLAGS="--std=c17 -D_DEFAULT_SOURCE=1 -DEMSCRIPTEN=1 -g" emconfigure ./configure \ - --without-cairo --without-opengl --without-x --without-tk --without-tcl \ - --disable-readline --disable-compression \ - --host=asmjs-unknown-emscripten \ - --target=asmjs-unknown-emscripten - # Append WASM linker flags and activate the WASM link target - cat toolchains/emscripten/defs.mak >> defs.mak - # Echo the merged defs.mak so CI logs show the exact build config - echo "===== defs.mak =====" - cat defs.mak - echo "===== defs.mak =====" - # Build in order: techs must exist before mains (--embed-file embeds them) - emmake make depend - emmake make -j$(nproc) modules libs - emmake make techs - emmake make mains - - name: Set up Node.js - uses: actions/setup-node@v5 - with: - node-version: '22' - - name: Run example tests - run: | - cp magic/magic.js npm/ - cp magic/magic.wasm npm/ - cd npm && npm run test - - name: Pack npm package - run: ./npm/pack.sh - - name: Upload npm package - uses: actions/upload-artifact@v5 - with: - name: magic-vlsi-wasm-npm - path: ${{ github.workspace }}/npm/*.tgz diff --git a/npm/pack.sh b/npm/pack.sh index 10553f48..1c05ffa8 100755 --- a/npm/pack.sh +++ b/npm/pack.sh @@ -12,8 +12,7 @@ # # Used by: # - npm/build.sh --pack (local build) -# - .github/workflows/main.yml (CI artifact upload) -# - .github/workflows/npm-publish.yml (tag-triggered publish) +# - .github/workflows/main-wasm.yml (CI build + tag-triggered publish) set -euo pipefail