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 "PLATFORM_NAME=${NODE_PLATFORM_NAME}" >> $GITHUB_ENV shell: bash - name: Install llvm if: matrix.os == 'windows-latest' run: choco install -y llvm - name: Set llvm path if: matrix.os == 'windows-latest' run: | echo "LIBCLANG_PATH=C:\\Program Files\\LLVM\\bin" >> $GITHUB_ENV shell: bash - 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 "PLATFORM_NAME=${NODE_PLATFORM_NAME}" >> $GITHUB_ENV 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: Publish run: | if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc npm publish else echo "Not a release, skipping publish" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}