|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Node.js Binding |
| 19 | + |
| 20 | +env: |
| 21 | + DEBUG: napi:* |
| 22 | + APP_NAME: adbc-driver-manager |
| 23 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 24 | + CARGO_INCREMENTAL: '1' |
| 25 | + |
| 26 | +on: |
| 27 | + push: |
| 28 | + branches: |
| 29 | + - main |
| 30 | + paths: |
| 31 | + - 'javascript/**' |
| 32 | + - 'rust/**' |
| 33 | + - '.github/workflows/node.yml' |
| 34 | + pull_request: |
| 35 | + paths: |
| 36 | + - 'javascript/**' |
| 37 | + - 'rust/**' |
| 38 | + - '.github/workflows/node.yml' |
| 39 | + |
| 40 | +concurrency: |
| 41 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 42 | + cancel-in-progress: true |
| 43 | + |
| 44 | +jobs: |
| 45 | + lint: |
| 46 | + name: Lint |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - name: Setup node |
| 51 | + uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: 22 |
| 54 | + cache: 'npm' |
| 55 | + cache-dependency-path: javascript/package-lock.json |
| 56 | + - name: Install Rust |
| 57 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable |
| 58 | + with: |
| 59 | + components: clippy, rustfmt |
| 60 | + - name: Install dependencies |
| 61 | + working-directory: javascript |
| 62 | + run: npm install |
| 63 | + - name: Cargo fmt |
| 64 | + working-directory: javascript |
| 65 | + run: cargo fmt -- --check |
| 66 | + - name: Clippy |
| 67 | + working-directory: javascript |
| 68 | + run: cargo clippy -- -D warnings |
| 69 | + |
| 70 | + build: |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + settings: |
| 75 | + - host: macos-15-intel |
| 76 | + target: x86_64-apple-darwin |
| 77 | + arch: amd64 |
| 78 | + os: macOS |
| 79 | + build: npm run build -- --target x86_64-apple-darwin |
| 80 | + - host: macos-latest |
| 81 | + target: aarch64-apple-darwin |
| 82 | + arch: arm64 |
| 83 | + os: macOS |
| 84 | + build: npm run build -- --target aarch64-apple-darwin |
| 85 | + - host: windows-latest |
| 86 | + target: x86_64-pc-windows-msvc |
| 87 | + arch: amd64 |
| 88 | + os: Windows |
| 89 | + build: npm run build -- --target x86_64-pc-windows-msvc |
| 90 | + - host: ubuntu-latest |
| 91 | + target: x86_64-unknown-linux-gnu |
| 92 | + arch: amd64 |
| 93 | + os: Linux |
| 94 | + build: npm run build -- --target x86_64-unknown-linux-gnu --use-napi-cross |
| 95 | + - host: ubuntu-latest |
| 96 | + target: aarch64-unknown-linux-gnu |
| 97 | + arch: arm64 |
| 98 | + os: Linux |
| 99 | + build: npm run build -- --target aarch64-unknown-linux-gnu --use-napi-cross |
| 100 | + name: Build Node.js ${{ matrix.settings.arch }} ${{ matrix.settings.os }} |
| 101 | + runs-on: ${{ matrix.settings.host }} |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + - name: Setup node |
| 105 | + uses: actions/setup-node@v4 |
| 106 | + with: |
| 107 | + node-version: 22 |
| 108 | + cache: 'npm' |
| 109 | + cache-dependency-path: javascript/package-lock.json |
| 110 | + - name: Install Rust |
| 111 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable |
| 112 | + with: |
| 113 | + toolchain: stable |
| 114 | + targets: ${{ matrix.settings.target }} |
| 115 | + - name: Install dependencies |
| 116 | + working-directory: javascript |
| 117 | + run: npm install |
| 118 | + - name: Build |
| 119 | + working-directory: javascript |
| 120 | + run: ${{ matrix.settings.build }} |
| 121 | + shell: bash |
| 122 | + - name: Ad-hoc sign binary (macOS) |
| 123 | + if: runner.os == 'macOS' |
| 124 | + working-directory: javascript |
| 125 | + run: codesign --sign - *.node |
| 126 | + - name: Upload artifact |
| 127 | + uses: actions/upload-artifact@v4 |
| 128 | + with: |
| 129 | + name: bindings-${{ matrix.settings.target }} |
| 130 | + path: javascript/*.node |
| 131 | + if-no-files-found: error |
| 132 | + |
| 133 | + test: |
| 134 | + name: Test ${{ matrix.settings.target }} |
| 135 | + needs: build |
| 136 | + runs-on: ${{ matrix.settings.host }} |
| 137 | + strategy: |
| 138 | + fail-fast: false |
| 139 | + matrix: |
| 140 | + settings: |
| 141 | + - host: ubuntu-latest |
| 142 | + target: x86_64-unknown-linux-gnu |
| 143 | + - host: macos-latest |
| 144 | + target: x86_64-apple-darwin |
| 145 | + # Windows testing is tricky without proper env setup for sqlite driver build |
| 146 | + steps: |
| 147 | + - uses: actions/checkout@v4 |
| 148 | + - name: Setup node |
| 149 | + uses: actions/setup-node@v4 |
| 150 | + with: |
| 151 | + node-version: 22 |
| 152 | + cache: 'npm' |
| 153 | + cache-dependency-path: javascript/package-lock.json |
| 154 | + - name: Install dependencies |
| 155 | + working-directory: javascript |
| 156 | + run: npm install --omit=optional |
| 157 | + - name: Download artifacts |
| 158 | + uses: actions/download-artifact@v4 |
| 159 | + with: |
| 160 | + name: bindings-${{ matrix.settings.target }} |
| 161 | + path: javascript |
| 162 | + - name: Build Driver |
| 163 | + # We need to build the SQLite driver for tests. |
| 164 | + # This assumes the host has CMake and C++ compiler. |
| 165 | + working-directory: javascript |
| 166 | + run: npm run build:driver |
| 167 | + env: |
| 168 | + # Point to vendored sqlite for reliable build in CI |
| 169 | + ADBC_CMAKE_ARGS: "-DSQLite3_INCLUDE_DIR=${{ github.workspace }}/c/vendor/sqlite3" |
| 170 | + - name: Run Tests |
| 171 | + working-directory: javascript |
| 172 | + run: npm test |
0 commit comments