Skip to content

Commit

Permalink
add missing deasync binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
CircleCI committed Dec 1, 2024
1 parent 758cef0 commit e5d637d
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": false,
"types": "dist/src/distro.js",
"scripts": {
"postinstall": "./scripts/hooks/postinstall/index.js",
"build": "rm -rf dist *.tgz && tsc --build --force && tracer=\"$(npm pack)\" && mv \"$tracer\" distro.tgz && cp distro.tgz wrapper.tgz",
"prepublishOnly": "npm run prettier:fix && npm run lint && npm run test:unit",
"lint": "eslint \"src/**/*.{ts,tsx,js}\"",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions scripts/hooks/postinstall/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node

const path = require('path');
const fs = require('fs-extra');

try {
const deasyncPath = path.dirname(require.resolve('deasync'));
const deasyncBinPath = path.join(deasyncPath, 'bin');
const sourcePath = path.join(__dirname, 'deasync-binaries');

console.log('Copying deasync binaries:', 'from', sourcePath, 'to', deasyncBinPath);
fs.copySync(sourcePath, deasyncBinPath, { overwrite: false });
} catch (e) {
console.error('Failed to copy deasync binaries:', e);
console.warn('@lumigo/opentelemetry/sync endpoint might not work as expected');
}
23 changes: 23 additions & 0 deletions src/sync-init.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import path from "path"
import { range } from 'lodash'

Check failure on line 2 in src/sync-init.spec.ts

View workflow job for this annotation

GitHub Actions / Validation lint

'lodash' should be listed in the project's dependencies. Run 'npm i -S lodash' to add it
import fs from "fs"

const deasyncPath = path.dirname(require.resolve("deasync"))
const supportedSyncInitNodeVersions = range(14, 22)

describe("pre-built binaries for arm64 (applicable when loaded by the operator)", () => {
/*
This test effectively checks the correctness of our post-install script, responsible for adding pre-built binaries
for the `deasync` package to be used on arm64 hosts.
Those binaries are required since:
1. The `deasync` package is a native module, and as such, it needs to be compiled for the target architecture.
2. The operator pre-installs the distro (and therefore pre-compiles the `deasync` package), so it could be later added
from an init-container volume-mount
3. Since that pre-installed version is compiled when building the injector image, it does not product a binary for other target plafforms
4. `deasync` addresses that by providing pre-built binaries for the most common platforms, but not for arm64 :(
*/
test.each(supportedSyncInitNodeVersions)("binaries are added for arm64 running Node %i", nodeVersion => {
const expectedBinaryPath = path.join(deasyncPath, "bin", `linux-arm64-node-${nodeVersion}`)
expect(fs.existsSync(expectedBinaryPath)).toBe(true)
})
})

0 comments on commit e5d637d

Please sign in to comment.