generated from napi-rs/package-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuuangzhang
committed
Oct 19, 2020
0 parents
commit 300c4df
Showing
10 changed files
with
1,828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
extends: [ | ||
'standard-vue-ts' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
name: CI | ||
|
||
env: | ||
DEBUG: 'napi:*' | ||
|
||
on: | ||
push: | ||
branches: [master, develop] | ||
tags-ignore: | ||
- '**' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
name: stable - ${{ matrix.os }} - node@12 | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
|
||
- name: Set platform name | ||
run: | | ||
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())") | ||
echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME" | ||
shell: bash | ||
|
||
- name: Install llvm | ||
if: matrix.os == 'windows-latest' | ||
run: choco install -y llvm | ||
|
||
- name: Set llvm path | ||
if: matrix.os == 'windows-latest' | ||
uses: allenevans/set-env@v1.0.0 | ||
with: | ||
LIBCLANG_PATH: 'C:\\Program Files\\LLVM\\bin' | ||
|
||
- name: Install | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
|
||
- name: Generate Cargo.lock | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: generate-lockfile | ||
|
||
- name: Cache cargo registry | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cargo/registry | ||
key: stable-${{ matrix.os }}-node@12-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Cache cargo index | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cargo/git | ||
key: stable-${{ matrix.os }}gnu-node@12-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Cache NPM dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: node_modules | ||
key: npm-cache-${{ matrix.os }}-node@12-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
npm-cache- | ||
- name: 'Install dependencies' | ||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org | ||
|
||
- name: 'Build' | ||
if: matrix.os != 'macos-latest' | ||
run: yarn build | ||
|
||
- name: 'Build' | ||
if: matrix.os == 'macos-latest' | ||
run: yarn build | ||
env: | ||
MACOSX_DEPLOYMENT_TARGET: '10.13' | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: bindings-${{ env.PLATFORM_NAME }} | ||
path: package-template.${{ env.PLATFORM_NAME }}.node | ||
|
||
- name: Clear the cargo caches | ||
run: | | ||
cargo install cargo-cache --no-default-features --features ci-autoclean | ||
cargo-cache | ||
build_musl: | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
name: stable - linux-musl - node@12 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Login to registry | ||
run: | | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL | ||
env: | ||
DOCKER_REGISTRY_URL: docker.pkg.github.com | ||
DOCKER_USERNAME: ${{ github.actor }} | ||
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Pull docker image | ||
run: | | ||
docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts | ||
docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder | ||
- name: 'Install dependencies' | ||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org | ||
|
||
- name: 'Build' | ||
run: | | ||
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/fast-escape -w /fast-escape builder sh -c "yarn build --musl" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: bindings-linux-musl | ||
path: package-template.linux-musl.node | ||
|
||
test_binding: | ||
name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }} | ||
needs: | ||
- build | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
node: ['10', '12', '14'] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Set platform name | ||
run: | | ||
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())") | ||
echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME" | ||
shell: bash | ||
|
||
# Do not cache node_modules, or yarn workspace links broken | ||
- name: 'Install dependencies' | ||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: bindings-${{ env.PLATFORM_NAME }} | ||
path: . | ||
|
||
- name: List packages | ||
run: ls -R . | ||
shell: bash | ||
|
||
- name: Test bindings | ||
run: yarn test | ||
|
||
test_musl_binding: | ||
name: Test bindings on alpine - node@${{ matrix.node }} | ||
needs: | ||
- build_musl | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: ['12', '14'] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: 'Install dependencies' | ||
run: yarn install --frozen-lockfile --ignore-scripts --registry https://registry.npmjs.org | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: bindings-linux-musl | ||
path: . | ||
|
||
- name: List files | ||
run: ls -R . | ||
shell: bash | ||
|
||
- name: Run simple tests | ||
run: docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/fast-escape -w /fast-escape node:${{ matrix.node }}-alpine sh -c "node ./simple-test.js" | ||
|
||
dependabot: | ||
needs: | ||
- test_binding | ||
- test_musl_binding | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: auto-merge | ||
uses: ridedott/dependabot-auto-merge-action@master | ||
with: | ||
GITHUB_LOGIN: dependabot[bot] | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test_binding | ||
- test_musl_binding | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
|
||
- name: Cache NPM dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: node_modules | ||
key: npm-cache-ubuntu-latest-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
npm-cache- | ||
- name: 'Install dependencies' | ||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: artifacts | ||
|
||
- name: Move artifacts | ||
run: yarn artifacts | ||
|
||
- name: List packages | ||
run: ls -R . | ||
shell: bash | ||
|
||
- name: lerna Publish | ||
run: | | ||
find ./packages/ -type d -maxdepth 1 -exec cp LICENSE {} \; | ||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | ||
npx lerna publish from-package --no-verify-access --yes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target | ||
yarn.lock | ||
.DS_Store | ||
node_modules | ||
*.node |
Oops, something went wrong.