Skip to content

Commit

Permalink
fix: async load of distro init
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Mancioppi committed Apr 28, 2023
1 parent d26c6fe commit a59cb3b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/push-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,45 @@ name: Tracer Testing
on: [push]
jobs:

build-package:
name: Build Lumigo OpenTelemetry for JS distro
supported-node-versions-testing:
name: Node ${{ matrix.node_cimg_tag }}
runs-on: ubuntu-latest
strategy:
matrix:
node_cimg_tag: [ 14, 16, 18, 20 ]
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ matrix.node_cimg_tag }}
architecture: x64
- run: sudo apt-get update && sudo apt-get install build-essential libsdl-pango-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev || true # Node.js 18 does not carry pango
- run: npm ci
- run: npm run build
- name: Upload distro as artifact
uses: actions/upload-artifact@v3
with:
name: distro-package
path: distro.tgz
retention-days: 5
- run: npm run test:unit
- run: npm run test:component
- run: npm run test:integration:version

supported-node-versions-testing:
name: Node ${{ matrix.node_cimg_tag }}
build-package:
name: Build Lumigo OpenTelemetry for JS distro
runs-on: ubuntu-latest
needs: [build-package]
strategy:
matrix:
node_cimg_tag: [ 14, 16, 18, 20 ]
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_cimg_tag }}
node-version: 16
architecture: x64
- name: Download distro
uses: actions/download-artifact@v3
- run: sudo apt-get update && sudo apt-get install build-essential libsdl-pango-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev || true # Node.js 18 does not carry pango
- run: npm ci
- run: npm run build
- name: Upload distro as artifact
uses: actions/upload-artifact@v3
with:
name: distro-package
- run: npm i ./distro.tgz
- run: npm run test:unit
- run: npm run test:component
- run: npm run test:integration:version
path: distro.tgz
retention-days: 5

unsupported-node-versions-testing:
name: Node ${{ matrix.node_cimg_tag }}
Expand All @@ -65,7 +63,13 @@ jobs:
- run: |
output=$(node -e "require('@lumigo/opentelemetry')" 2>&1)
if [ "${output}" != "@lumigo/opentelemetry: Node.js version '$(node --version)' is not supported"* ]; then
if [[ "${output}" != "@lumigo/opentelemetry: Node.js version '$(node --version)' is not supported"* ]]; then
echo "Unexpected output: ${output}"
exit 1
fi
all-tests:
runs-on: ubuntu-latest
needs:
- supported-node-versions-testing
- unsupported-node-versions-testing
7 changes: 4 additions & 3 deletions src/distro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
import { minMajor, maxMajor } from './supportedVersions.json';

const trace = (): Promise<any> => {
const trace = async (): Promise<any> => {
const version = process.version;
try {
const nodeJsMajorVersion = parseInt(version.match(/v(\d+)\..*/)[1]);
Expand All @@ -36,8 +36,9 @@ const trace = (): Promise<any> => {
return Promise.resolve();
}

const { init } = require('./distro-init');
return init();
const distro = await import('./distro-init');
const { init } = distro;
return await init;
};

export const init = trace();

0 comments on commit a59cb3b

Please sign in to comment.