| 1 | name: NodeJS (NAPI) |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - main |
| 7 | pull_request: |
| 8 | paths: |
| 9 | - nodejs/** |
| 10 | - .github/workflows/nodejs.yml |
| 11 | - docker-compose.yml |
| 12 | |
| 13 | concurrency: |
| 14 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 15 | cancel-in-progress: true |
| 16 | |
| 17 | env: |
| 18 | # Disable full debug symbol generation to speed up CI build and keep memory down |
| 19 | # "1" means line tables only, which is useful for panic tracebacks. |
| 20 | RUSTFLAGS: "-C debuginfo=1" |
| 21 | RUST_BACKTRACE: "1" |
| 22 | |
| 23 | jobs: |
| 24 | lint: |
| 25 | name: Lint |
| 26 | runs-on: ubuntu-22.04 |
| 27 | defaults: |
| 28 | run: |
| 29 | shell: bash |
| 30 | working-directory: nodejs |
| 31 | env: |
| 32 | # Need up-to-date compilers for kernels |
| 33 | CC: gcc-12 |
| 34 | CXX: g++-12 |
| 35 | steps: |
| 36 | - uses: actions/checkout@v4 |
| 37 | with: |
| 38 | fetch-depth: 0 |
| 39 | lfs: true |
| 40 | - uses: actions/setup-node@v3 |
| 41 | with: |
| 42 | node-version: 20 |
| 43 | cache: 'npm' |
| 44 | cache-dependency-path: nodejs/package-lock.json |
| 45 | - uses: Swatinem/rust-cache@v2 |
| 46 | - name: Install dependencies |
| 47 | run: | |
| 48 | sudo apt update |
| 49 | sudo apt install -y protobuf-compiler libssl-dev |
| 50 | - name: Lint |
| 51 | run: | |
| 52 | cargo fmt --all -- --check |
| 53 | cargo clippy --all --all-features -- -D warnings |
| 54 | npm ci |
| 55 | npm run lint-ci |
| 56 | linux: |
| 57 | name: Linux (NodeJS ${{ matrix.node-version }}) |
| 58 | timeout-minutes: 30 |
| 59 | strategy: |
| 60 | matrix: |
| 61 | node-version: [ "18", "20" ] |
| 62 | runs-on: "ubuntu-22.04" |
| 63 | defaults: |
| 64 | run: |
| 65 | shell: bash |
| 66 | working-directory: nodejs |
| 67 | steps: |
| 68 | - uses: actions/checkout@v4 |
| 69 | with: |
| 70 | fetch-depth: 0 |
| 71 | lfs: true |
| 72 | - uses: actions/setup-node@v3 |
| 73 | with: |
| 74 | node-version: ${{ matrix.node-version }} |
| 75 | cache: 'npm' |
| 76 | cache-dependency-path: node/package-lock.json |
| 77 | - uses: Swatinem/rust-cache@v2 |
| 78 | - name: Install dependencies |
| 79 | run: | |
| 80 | sudo apt update |
| 81 | sudo apt install -y protobuf-compiler libssl-dev |
| 82 | npm install -g @napi-rs/cli |
| 83 | - name: Build |
| 84 | run: | |
| 85 | npm ci |
| 86 | npm run build |
| 87 | - name: Setup localstack |
| 88 | working-directory: . |
| 89 | run: docker compose up --detach --wait |
| 90 | - name: Test |
| 91 | env: |
| 92 | S3_TEST: "1" |
| 93 | run: npm run test |
| 94 | macos: |
| 95 | timeout-minutes: 30 |
| 96 | runs-on: "macos-14" |
| 97 | defaults: |
| 98 | run: |
| 99 | shell: bash |
| 100 | working-directory: nodejs |
| 101 | steps: |
| 102 | - uses: actions/checkout@v4 |
| 103 | with: |
| 104 | fetch-depth: 0 |
| 105 | lfs: true |
| 106 | - uses: actions/setup-node@v3 |
| 107 | with: |
| 108 | node-version: 20 |
| 109 | cache: 'npm' |
| 110 | cache-dependency-path: node/package-lock.json |
| 111 | - uses: Swatinem/rust-cache@v2 |
| 112 | - name: Install dependencies |
| 113 | run: | |
| 114 | brew install protobuf |
| 115 | npm install -g @napi-rs/cli |
| 116 | - name: Build |
| 117 | run: | |
| 118 | npm ci |
| 119 | npm run build |
| 120 | - name: Test |
| 121 | run: | |
| 122 | npm run test |