fix(cli): ci template

This commit is contained in:
LongYinan 2021-09-02 23:26:27 +08:00
parent c303f358ef
commit 45d3e68ff3
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
4 changed files with 36 additions and 32 deletions

View file

@ -5,19 +5,22 @@ export const createCargoConfig = (
) => { ) => {
let result = '' let result = ''
if (enableLinuxArm8Gnu) { if (enableLinuxArm8Gnu) {
result = `[target.aarch64-unknown-linux-gnu] result += `[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"` linker = "aarch64-linux-gnu-gcc"
`
} }
if (enableLinuxArm8Musl) { if (enableLinuxArm8Musl) {
result = `[target.aarch64-unknown-linux-musl] result += `[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc" linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]` rustflags = ["-C", "target-feature=-crt-static"]
`
} }
if (enableLinuxArm7) { if (enableLinuxArm7) {
result = `${result} result += `[target.armv7-unknown-linux-gnueabihf]
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc" linker = "arm-linux-gnueabihf-gcc"
` `
} }
return result return result

View file

@ -1,9 +1,9 @@
export const YAML = ` export const YAML = (app: string) => `
name: CI name: CI
env: env:
DEBUG: 'napi:*' DEBUG: 'napi:*'
APP_NAME: 'napi' APP_NAME: '${app}'
MACOSX_DEPLOYMENT_TARGET: '10.13' MACOSX_DEPLOYMENT_TARGET: '10.13'
on: on:
@ -45,14 +45,14 @@ jobs:
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder
build: | build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip \${{ env.APP_NAME }}.linux-x64-gnu.node docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip ${app}.linux-x64-gnu.node
- host: ubuntu-latest - host: ubuntu-latest
target: 'x86_64-unknown-linux-musl' target: 'x86_64-unknown-linux-musl'
docker: | docker: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine builder docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip \${{ env.APP_NAME }}.linux-x64-musl.node build: docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip ${app}.linux-x64-musl.node
- host: macos-latest - host: macos-latest
target: 'aarch64-apple-darwin' target: 'aarch64-apple-darwin'
build: yarn build --target=aarch64-apple-darwin build: yarn build --target=aarch64-apple-darwin
@ -83,7 +83,7 @@ jobs:
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: | build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/\${{ env.APP_NAME }} -w /\${{ env.APP_NAME }} builder sh -c "yarn build -- --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip \${{ env.APP_NAME }}.linux-arm64-musl.node" docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/${app} -w /${app} builder sh -c "yarn build -- --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip ${app}.linux-arm64-musl.node"
- host: windows-latest - host: windows-latest
target: 'aarch64-pc-windows-msvc' target: 'aarch64-pc-windows-msvc'
build: yarn build --target aarch64-pc-windows-msvc build: yarn build --target aarch64-pc-windows-msvc
@ -288,7 +288,7 @@ jobs:
shell: bash shell: bash
- name: Test bindings - name: Test bindings
run: docker run --rm -v $(pwd):/\${{ env.APP_NAME }} -w /\${{ env.APP_NAME }} node:\${{ matrix.node }}-slim yarn test run: docker run --rm -v $(pwd):/${app} -w /${app} node:\${{ matrix.node }}-slim yarn test
test-linux-x64-musl-binding: test-linux-x64-musl-binding:
name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }} name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }}
@ -329,7 +329,7 @@ jobs:
shell: bash shell: bash
- name: Test bindings - name: Test bindings
run: docker run --rm -v $(pwd):/\${{ env.APP_NAME }} -w /\${{ env.APP_NAME }} node:\${{ matrix.node }}-alpine yarn test run: docker run --rm -v $(pwd):/${app} -w /${app} node:\${{ matrix.node }}-alpine yarn test
test-linux-aarch64-gnu-binding: test-linux-aarch64-gnu-binding:
name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }} name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }}
@ -361,13 +361,13 @@ jobs:
with: with:
args: > args: >
sh -c " sh -c "
apt-get update && \ apt-get update && \\
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \\
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \ curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \\
apt-get install -y nodejs && \ apt-get install -y nodejs && \\
npm install -g yarn && \ npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
yarn test && \ yarn test && \\
ls -la ls -la
" "
test-linux-aarch64-musl-binding: test-linux-aarch64-musl-binding:
@ -397,9 +397,9 @@ jobs:
with: with:
args: > args: >
sh -c " sh -c "
apk add nodejs npm && \ apk add nodejs npm && \\
npm install -g yarn && \ npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
npm test npm test
" "
test-linux-arm-gnueabihf-binding: test-linux-arm-gnueabihf-binding:
@ -432,13 +432,13 @@ jobs:
with: with:
args: > args: >
sh -c " sh -c "
apt-get update && \ apt-get update && \\
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \\
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \ curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \\
apt-get install -y nodejs && \ apt-get install -y nodejs && \\
npm install -g yarn && \ npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
yarn test && \ yarn test && \\
ls -la ls -la
" "
publish: publish:

View file

@ -14,7 +14,7 @@ export const createGithubActionsCIYml = (
binaryName: string, binaryName: string,
targets: string[], targets: string[],
) => { ) => {
const fullTemplate = load(YAML) as any const fullTemplate = load(YAML(binaryName)) as any
const requiredSteps = [] const requiredSteps = []
const enableWindowsX86 = targets.includes('x86_64-pc-windows-msvc') const enableWindowsX86 = targets.includes('x86_64-pc-windows-msvc')
const enableMacOSX86 = targets.includes('x86_64-apple-darwin') const enableMacOSX86 = targets.includes('x86_64-apple-darwin')

View file

@ -34,6 +34,7 @@ const SupportedPlatforms: string[] = [
'aarch64-apple-darwin', 'aarch64-apple-darwin',
'aarch64-linux-android', 'aarch64-linux-android',
'aarch64-unknown-linux-gnu', 'aarch64-unknown-linux-gnu',
'aarch64-unknown-linux-musl',
'aarch64-pc-windows-msvc', 'aarch64-pc-windows-msvc',
'armv7-unknown-linux-gnueabihf', 'armv7-unknown-linux-gnueabihf',
'x86_64-apple-darwin', 'x86_64-apple-darwin',