Skip to content

test-cross-use

test-cross-use #50

name: test-cross-use
on:
workflow_dispatch:
inputs:
version:
description: '核心版本号'
required: true
default: '7.0.2'
dryRun:
description: '测试写这个为 true'
required: true
default: 'false'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
base:
name: Test - ${{ matrix.platform.os-name }}
strategy:
fail-fast: false
matrix:
platform:
- os-name: x86_64-unknown-linux-gnu
runs-on: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- os-name: Windows-x86_64-msvc
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- os-name: macOS-x86_64
runs-on: macos-13
target: x86_64-apple-darwin
- os-name: macOS-aarch64
runs-on: macOS-latest
target: aarch64-apple-darwin
- os-name: wasm32-wasip1
runs-on: macOS-latest
target: wasm32-wasip1
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file Linux
if: ${{ runner.os != 'Windows' }}
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Create index.mjs file Windows
if: ${{ runner.os == 'Windows' }}
run: |
$content = @'
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
'@
Set-Content -Path index.mjs -Value $content
- name: Install unzipper
run: |
npm init -y
npm i pnpm -g
npm i unzipper cn-font-split
pnpm cn-font-split ls
node index.mjs
- name: build
if: ${{ matrix.platform.target != 'wasm32-wasip1' }}
run: |
pnpm cn-font-split -i ./SmileySans-Oblique.otf -o ./dist/
- name: wasm build
if: ${{ matrix.platform.target == 'wasm32-wasip1' }}
run: |
pnpm cn-font-split i wasm32-wasip1
cat > test.mjs <<EOL
import { fontSplit, StaticWasm } from 'cn-font-split/dist/wasm/index.mjs';
import fs from 'fs';
const input = fs.readFileSync('./SmileySans-Oblique.otf');
const wasm = new StaticWasm(
fs.readFileSync(
'./node_modules/cn-font-split/dist/libffi-wasm32-wasip1.wasm',
),
);
const data = await fontSplit(
{
input: new Uint8Array(input.buffer),
outDir: './dist',
},
wasm.WasiHandle,
{
logger(str, type) {
console.log(str);
},
},
);
// console.log(data);
// { name: string, data: Uint8Array }[]
for (const file of data) {
fs.writeFileSync('./dist/' + file.name, file.data);
}
EOL
mkdir dist
node test.mjs
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.target }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error
nodejs:
name: Test - ${{ matrix.platform.name }}
strategy:
fail-fast: false
matrix:
platform:
- name: aarch64-unknown-linux-gnu-ubuntu_latest
arch: aarch64
distro: ubuntu_latest
env:
TZ: Asia/Shanghai
runs-on: ubuntu-24.04
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Install unzipper
run: |
npm init -y
npm install unzipper
node index.mjs
- name: Build artifact
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.platform.arch }}
distro: ${{ matrix.platform.distro }}
# Not required, but speeds up builds
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/:/app"
# The shell to run commands with in the container
shell: /bin/sh
install: |
case "${{ matrix.platform.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y nodejs npm
;;
fedora*)
dnf -y update
dnf -y install nodejs which
;;
alpine*)
apk update
apk add nodejs
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
apt install curl -q -y
npm i cn-font-split -g
cn-font-split ls
cn-font-split -i ./SmileySans-Oblique.otf -o ./dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.name }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error
python:
name: Test - ${{ matrix.platform.name }}
strategy:
fail-fast: false
matrix:
platform:
- name: aarch64-unknown-linux-gnu-bookworm
arch: aarch64
distro: bookworm
target: aarch64-unknown-linux-gnu
break_python: --break-system-packages
- name: aarch64-unknown-linux-gnu-ubuntu22.04
arch: aarch64
distro: ubuntu22.04
target: aarch64-unknown-linux-gnu
- name: aarch64-unknown-linux-gnu-ubuntu20.04
arch: aarch64
distro: ubuntu20.04
target: aarch64-unknown-linux-gnu
- name: riscv64gc-unknown-linux-gnu
arch: riscv64
distro: ubuntu_latest
target: riscv64gc-unknown-linux-gnu
break_python: --break-system-packages
- name: s390x-unknown-linux-gnu
arch: s390x
distro: ubuntu_latest
target: s390x-unknown-linux-gnu
break_python: --break-system-packages
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ubuntu-24.04
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Create index.mjs file
run: |
cat > index.mjs <<EOL
import unzipper from "unzipper";
fetch(
"https://github.com/atelier-anchor/smiley-sans/releases/download/v2.0.1/smiley-sans-v2.0.1.zip"
)
.then((res) => res.arrayBuffer())
.then(async (res) => {
const directory = await unzipper.Open.buffer(Buffer.from(res));
await directory.extract({ path: "./" });
});
EOL
- name: Install unzipper
run: |
npm init -y
npm install unzipper
node index.mjs
- name: Build artifact
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.platform.arch }}
distro: ${{ matrix.platform.distro }}
# Not required, but speeds up builds
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/:/app"
# The shell to run commands with in the container
shell: /bin/sh
install: |
case "${{ matrix.platform.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y nodejs npm
;;
fedora*)
dnf -y update
dnf -y install nodejs which
;;
alpine*)
apk update
apk add nodejs
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
apt update -y -q
apt install curl python3 python3-pip -y -q
pip3 install cn-font-split ${{ matrix.platform.break_python }}
cn-font-split-py i ${{ matrix.platform.target }}@${{inputs.version}}
cn-font-split-py -i ./SmileySans-Oblique.otf -o ./dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: test-${{ matrix.platform.name }}-${{hashFiles('dist/**/*.woff2')}}
path: ./dist/**/*
if-no-files-found: error