Repository navigation
163 lines (146 loc) · 6.63 KB
/
Copy pathnapi-checks.yml
File metadata and controls
163 lines (146 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Copyright (c) 2026 Databricks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# napi-rs sub-crate CI. The napi/ directory is a *standalone* Cargo
# workspace (see napi/Cargo.toml — `[workspace] members = ["."]`)
# because it pins `tls-rustls` on the kernel while the root workspace
# picks `tls-native` via pyo3. Feature-unification under a single
# workspace would link both TLS stacks into the resulting cdylib.
#
# Consequence: every cargo invocation here runs from `napi/`, not the
# repo root. Lockfile drift detection uses `--locked` against
# `napi/Cargo.lock` rather than the kernel's root lock.
#
# Path-gated on `napi/**` so this workflow fires only when the
# directory or its inputs change.
name: napi Checks
on:
push:
branches: [main]
paths:
- "napi/**"
- "src/**"
# Root Cargo.toml change can affect napi via its `path = ".."`
# kernel dep, so this workflow re-runs to catch mismatches.
- "Cargo.toml"
- ".github/actions/setup-public-package-proxies/**"
- ".github/workflows/napi-checks.yml"
pull_request:
branches: [main]
paths:
- "napi/**"
- "src/**"
- "Cargo.toml"
- ".github/actions/setup-public-package-proxies/**"
- ".github/workflows/napi-checks.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
check-and-test:
name: "napi fmt + clippy + test"
permissions:
contents: read
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
defaults:
run:
# All cargo commands run from the napi/ standalone workspace.
working-directory: napi
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Route cargo through the unauthenticated filtered proxy so fork PRs
# never receive an OIDC mint permission while executing
# contributor-controlled code.
- uses: ./.github/actions/setup-public-package-proxies
with:
cargo: "true"
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
components: rustfmt, clippy
# napi is a standalone workspace; cache its actual target and
# lockfile instead of the unused repository-root target.
cache-workspaces: "napi -> target"
- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: cargo fmt --all -- --check
run: cargo fmt --all -- --check
# `--locked` makes the build fail if `napi/Cargo.lock` is out of
# sync with `napi/Cargo.toml` — catches contributors who bump a
# dep version in Cargo.toml without re-running `cargo update`.
# Mirrors the dual-Cargo.lock-drift concern from review.
- name: cargo clippy --all-targets --locked -- -D warnings
run: cargo clippy --all-targets --locked -- -D warnings
- name: cargo test --locked
# The napi crate's Rust-side unit tests (error envelope, panic
# guard, runtime handle, version) run here. No network, no
# secrets — purely cdylib + rlib in-tree tests.
#
# `--features dyn-symbols`: napi-rs 3 references N-API symbols
# from a `Drop` impl unconditionally, so the hostless `lib test`
# executable can't link/run without them. dyn-symbols resolves
# N-API via libloading with no-op stubs when absent, letting the
# pure-logic tests run with no Node host. The release cdylib
# (built below) intentionally omits it and keeps link-time symbols.
run: cargo test --locked --features dyn-symbols
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
- name: Test external authentication from Node
run: |
cargo build --locked
node --test tests/auth-external.test.cjs
# Drift guard for the committed loader (napi/index.js +
# napi/index.d.ts). PR #146 review feedback: nothing in CI
# detects when a contributor adds a top-level `#[napi]` symbol
# without recommitting the generated loader, and that already
# happened once (3 logger exports went missing in #146 before
# this check landed).
#
# This is a SURFACE audit, not a full regenerate-and-diff —
# parses napi/src/**.rs for top-level `#[napi]` items and
# compares against the destructured names in napi/index.js.
# Catches the "new export missing" bug class without needing
# an npm proxy on the protected runner (which doesn't yet
# exist; see .github/actions/setup-jfrog/action.yml — npm
# support is a "future" item). When npm-via-JFrog lands, this
# step should be replaced with the full reviewer-preferred
# form: `npx --yes @napi-rs/cli@2.18.4 build --platform ...`
# then `git diff --exit-code -- napi/index.js napi/index.d.ts`.
# Tracked in the PR #146 discussion.
- name: Check napi loader is in sync with #[napi] surface
working-directory: ${{ github.workspace }}
run: bash .github/scripts/check-napi-loader-drift.sh
# Release-profile build verifies the cdylib actually links with
# the production profile knobs (lto=true, codegen-units=1,
# strip="debuginfo"). The lto=true link is the slow part (~4 min
# here), and `cargo check --release` would NOT exercise it
# (check doesn't link the cdylib), so we keep the real build but
# run it only on push to main — a post-merge canary — rather
# than on every PR push. napi is not a required check, so this
# keeps PR feedback fast (fmt + clippy + test, ~2.5 min) while
# still catching release-only link regressions before they
# accumulate on main. The merge group does not run napi (no
# merge_group trigger), so main is the gate.
- name: cargo build --release --locked
if: github.event_name == 'push'
run: cargo build --release --locked