Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): avoid more native modules on production dependencies #190183

Merged
merged 46 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
61828ea
chore(NA): first iteration on package to check for prod native modules
mistic Aug 7, 2024
70c8913
chore(NA): adds new package into package.json
mistic Aug 7, 2024
f5e802c
fix(NA): boilerplate files for new package
mistic Aug 7, 2024
533a28c
fix(NA): correctly sets error state on the cli file
mistic Aug 7, 2024
a9579d4
chore(NA): add native modules check on CI
mistic Aug 7, 2024
3a6dd5d
fix(NA): recursively check directories for native modules
mistic Aug 8, 2024
dadc38d
fix(NA): change and correct the implementation
mistic Aug 8, 2024
4b04c1b
chore(NA): adds kbn-cbor
mistic Aug 8, 2024
0813aa2
chore(NA): replace cbor-x with @kbn/cbor abstracting cborg
mistic Aug 8, 2024
e203adb
chore(NA): update ts projects
mistic Aug 8, 2024
de07648
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Aug 8, 2024
198a8d7
fix(NA): permissions on check_native modules sh checks file
mistic Aug 8, 2024
468c478
fix(NA): check prod ntive modules logic
mistic Aug 8, 2024
9164366
fix(NA): logging path for node modules
mistic Aug 8, 2024
181f8a2
fix(NA): replace cborg with borc
mistic Aug 9, 2024
74cf489
docs(NA): update readme
mistic Aug 9, 2024
4b41f46
fix(NA): types for kbn-cbor
mistic Aug 9, 2024
1fa558a
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 9, 2024
d2636b8
Merge branch 'main' into avoid-more-native-modules-on-prod
elasticmachine Aug 9, 2024
b9bd546
test(NA): @kbn/cbor tests
mistic Aug 9, 2024
80376f7
refact(NA): previous codebase for searching for prod deps
mistic Aug 9, 2024
6b8570d
test(NA): unit tests
mistic Aug 9, 2024
5cf37ca
fix(NA): do not export function from another file
mistic Aug 9, 2024
80242e2
test(NA): include integration tests
mistic Aug 9, 2024
0708eec
chore(NA): include node_modules on fixtures
mistic Aug 9, 2024
fcd1d70
Merge branch 'avoid-more-native-modules-on-prod' of github.com:mistic…
mistic Aug 9, 2024
6d26a8e
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 12, 2024
0aec7ff
chore(NA): rename folders to use snake case
mistic Aug 12, 2024
1af3f1d
Merge branch 'avoid-more-native-modules-on-prod' of github.com:mistic…
mistic Aug 12, 2024
9ff0235
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 12, 2024
4110351
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 13, 2024
9097d8e
chore(NA): update error message
mistic Aug 13, 2024
61d11b0
test(NA): include 2 extra new integration test cases
mistic Aug 13, 2024
c99af1b
Merge remote-tracking branch 'upstream/main' into avoid-more-native-m…
mistic Aug 13, 2024
92a3756
fix(NA): eslint
mistic Aug 13, 2024
d7bb158
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 14, 2024
15f0c61
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 15, 2024
cf0970d
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 18, 2024
7e26295
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 19, 2024
425dfcc
chore(NA): merge and solve conflicts with main
mistic Aug 22, 2024
6053de0
chore(NA): test node-cbor
mistic Aug 22, 2024
ed996b5
Revert "chore(NA): test node-cbor"
mistic Aug 22, 2024
3d78488
docs(NA): small comment on class
mistic Aug 22, 2024
30d0d26
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 22, 2024
da2b879
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 23, 2024
c419608
Merge branch 'main' into avoid-more-native-modules-on-prod
mistic Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .buildkite/scripts/steps/checks/native_modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

echo --- Check Production Native Node Modules
node scripts/check_prod_native_modules
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/quick_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export DISABLE_BOOTSTRAP_VALIDATION=false
.buildkite/scripts/steps/checks/yarn_deduplicate.sh
.buildkite/scripts/steps/checks/prettier_topology.sh
.buildkite/scripts/steps/checks/renovate.sh
.buildkite/scripts/steps/checks/native_modules.sh
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ packages/kbn-capture-oas-snapshot-cli @elastic/kibana-core
x-pack/test/cases_api_integration/common/plugins/cases @elastic/response-ops
packages/kbn-cases-components @elastic/response-ops
x-pack/plugins/cases @elastic/response-ops
packages/kbn-cbor @elastic/kibana-operations
packages/kbn-cell-actions @elastic/security-threat-hunting-explore
src/plugins/chart_expressions/common @elastic/kibana-visualizations
packages/kbn-chart-icons @elastic/kibana-visualizations
src/plugins/charts @elastic/kibana-visualizations
packages/kbn-check-mappings-update-cli @elastic/kibana-core
packages/kbn-check-prod-native-modules-cli @elastic/kibana-operations
packages/kbn-ci-stats-core @elastic/kibana-operations
packages/kbn-ci-stats-performance-metrics @elastic/kibana-operations
packages/kbn-ci-stats-reporter @elastic/kibana-operations
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"@kbn/cases-api-integration-test-plugin": "link:x-pack/test/cases_api_integration/common/plugins/cases",
"@kbn/cases-components": "link:packages/kbn-cases-components",
"@kbn/cases-plugin": "link:x-pack/plugins/cases",
"@kbn/cbor": "link:packages/kbn-cbor",
"@kbn/cell-actions": "link:packages/kbn-cell-actions",
"@kbn/chart-expressions-common": "link:src/plugins/chart_expressions/common",
"@kbn/chart-icons": "link:packages/kbn-chart-icons",
Expand Down Expand Up @@ -1013,13 +1014,13 @@
"base64-js": "^1.3.1",
"bitmap-sdf": "^1.0.3",
"blurhash": "^2.0.1",
"borc": "3.0.0",
mistic marked this conversation as resolved.
Show resolved Hide resolved
"brace": "0.11.1",
"brok": "^5.0.2",
"byte-size": "^8.1.0",
"cacheable-lookup": "6",
"camelcase-keys": "7.0.2",
"canvg": "^3.0.9",
"cbor-x": "^1.3.3",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.12",
"chroma-js": "^2.1.0",
Expand Down Expand Up @@ -1298,6 +1299,7 @@
"@kbn/bazel-runner": "link:packages/kbn-bazel-runner",
"@kbn/capture-oas-snapshot-cli": "link:packages/kbn-capture-oas-snapshot-cli",
"@kbn/check-mappings-update-cli": "link:packages/kbn-check-mappings-update-cli",
"@kbn/check-prod-native-modules-cli": "link:packages/kbn-check-prod-native-modules-cli",
"@kbn/ci-stats-core": "link:packages/kbn-ci-stats-core",
"@kbn/ci-stats-performance-metrics": "link:packages/kbn-ci-stats-performance-metrics",
"@kbn/ci-stats-reporter": "link:packages/kbn-ci-stats-reporter",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-cbor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/cbor

Simple wrapper around borc to expose CBOR encode and decode methods with reasonable performance and no native modules
40 changes: 40 additions & 0 deletions packages/kbn-cbor/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { encode, decode } from '.';

describe('KbnCbor', () => {
it('should correctly encode and decode data', () => {
const data = { hello: 'world', count: 123, isValid: true };

// encoding
const encoded = encode(data);
expect(encoded).toBeInstanceOf(Buffer);
expect(encoded.length).toBeGreaterThan(0);

// decoding
const decoded = decode(encoded);
expect(decoded).toEqual(data);
});

it('should encode data to Buffer', () => {
const data = { foo: 'bar' };

const encoded = encode(data);
expect(Buffer.isBuffer(encoded)).toBe(true);
});

it('should decode Buffer to original data', () => {
const data = { foo: 'bar', num: 42, arr: [1, 2, 3] };

const encoded = encode(data);
const decoded = decode(encoded);

expect(decoded).toEqual(data);
});
});
22 changes: 22 additions & 0 deletions packages/kbn-cbor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { encode as encodeJS, decode as decodeJS } from 'borc';

export class KbnCbor {
static encode(data: unknown) {
return encodeJS(data);
}

static decode(uint8: any) {
return decodeJS(uint8);
}
}

export const encode = KbnCbor.encode;
export const decode = KbnCbor.decode;
13 changes: 13 additions & 0 deletions packages/kbn-cbor/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-cbor'],
};
5 changes: 5 additions & 0 deletions packages/kbn-cbor/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/cbor",
"owner": "@elastic/kibana-operations"
}
7 changes: 7 additions & 0 deletions packages/kbn-cbor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/cbor",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./index.ts"
}
18 changes: 18 additions & 0 deletions packages/kbn-cbor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
"../../typings/borc.d.ts"
],
"exclude": [
"target/**/*"
],
"kbn_references": []
}
3 changes: 3 additions & 0 deletions packages/kbn-check-prod-native-modules-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/check-prod-native-modules-cli

Simple and straightforward CLI for searching for native modules installed as prod dependencies or as a result of any prod dependency.
Loading