Skip to content

Commit

Permalink
fix(cli): ci template
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Sep 2, 2021
1 parent c303f35 commit 45d3e68
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
17 changes: 10 additions & 7 deletions cli/src/new/cargo-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ export const createCargoConfig = (
) => {
let result = ''
if (enableLinuxArm8Gnu) {
result = `[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"`
result += `[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
`
}
if (enableLinuxArm8Musl) {
result = `[target.aarch64-unknown-linux-musl]
result += `[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]`
rustflags = ["-C", "target-feature=-crt-static"]
`
}
if (enableLinuxArm7) {
result = `${result}
[target.armv7-unknown-linux-gnueabihf]
result += `[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
`
}
return result
Expand Down
48 changes: 24 additions & 24 deletions cli/src/new/ci-template.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const YAML = `
export const YAML = (app: string) => `
name: CI
env:
DEBUG: 'napi:*'
APP_NAME: 'napi'
APP_NAME: '${app}'
MACOSX_DEPLOYMENT_TARGET: '10.13'
on:
Expand Down Expand Up @@ -45,14 +45,14 @@ jobs:
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
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
target: 'x86_64-unknown-linux-musl'
docker: |
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 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
target: 'aarch64-apple-darwin'
build: yarn build --target=aarch64-apple-darwin
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
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
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
target: 'aarch64-pc-windows-msvc'
build: yarn build --target aarch64-pc-windows-msvc
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
shell: bash
- 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:
name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }}
Expand Down Expand Up @@ -329,7 +329,7 @@ jobs:
shell: bash
- 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:
name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }}
Expand Down Expand Up @@ -361,13 +361,13 @@ jobs:
with:
args: >
sh -c "
apt-get update && \
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \
apt-get install -y nodejs && \
npm install -g yarn && \
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \
yarn test && \
apt-get update && \\
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \\
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \\
apt-get install -y nodejs && \\
npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
yarn test && \\
ls -la
"
test-linux-aarch64-musl-binding:
Expand Down Expand Up @@ -397,9 +397,9 @@ jobs:
with:
args: >
sh -c "
apk add nodejs npm && \
npm install -g yarn && \
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \
apk add nodejs npm && \\
npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
npm test
"
test-linux-arm-gnueabihf-binding:
Expand Down Expand Up @@ -432,13 +432,13 @@ jobs:
with:
args: >
sh -c "
apt-get update && \
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \
apt-get install -y nodejs && \
npm install -g yarn && \
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \
yarn test && \
apt-get update && \\
apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \\
curl -sL https://deb.nodesource.com/setup_\${{ matrix.node }}.x | bash - && \\
apt-get install -y nodejs && \\
npm install -g yarn && \\
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \\
yarn test && \\
ls -la
"
publish:
Expand Down
2 changes: 1 addition & 1 deletion cli/src/new/ci-yml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createGithubActionsCIYml = (
binaryName: string,
targets: string[],
) => {
const fullTemplate = load(YAML) as any
const fullTemplate = load(YAML(binaryName)) as any
const requiredSteps = []
const enableWindowsX86 = targets.includes('x86_64-pc-windows-msvc')
const enableMacOSX86 = targets.includes('x86_64-apple-darwin')
Expand Down
1 change: 1 addition & 0 deletions cli/src/new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const SupportedPlatforms: string[] = [
'aarch64-apple-darwin',
'aarch64-linux-android',
'aarch64-unknown-linux-gnu',
'aarch64-unknown-linux-musl',
'aarch64-pc-windows-msvc',
'armv7-unknown-linux-gnueabihf',
'x86_64-apple-darwin',
Expand Down

0 comments on commit 45d3e68

Please sign in to comment.