From 32fa63e3e2ca8e93c165add1547daf577a0fd420 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Wed, 27 Aug 2025 15:44:15 +0200 Subject: [PATCH 1/7] ci: allow publishing alpha releases from tag --- .github/workflows/release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bddb0cb..a7ed1904 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,12 @@ jobs: run: pnpm moon run :build - name: Publish the libraries - run: pnpm publish -r --access=public --no-git-checks + run: | + if [[ "${{ github.ref }}" == *"-alpha"* ]]; then + pnpm publish -r --access=public --no-git-checks --tag=alpha + else + pnpm publish -r --access=public --no-git-checks + fi env: NPM_CONFIG_PROVENANCE: true NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 835fb0242a3945e5a7dc1b4e7fb1fc5f46e4b915 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Mon, 15 Sep 2025 16:52:12 +0200 Subject: [PATCH 2/7] chore(core): print error when failing to load native core --- packages/core/src/native_core/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/src/native_core/index.ts b/packages/core/src/native_core/index.ts index 9cbb4a90..64459a13 100644 --- a/packages/core/src/native_core/index.ts +++ b/packages/core/src/native_core/index.ts @@ -1,4 +1,5 @@ import path from "path"; +import { logDebug } from "../utils"; import { InstrumentHooks } from "./instruments/hooks"; import { LinuxPerf } from "./linux_perf/linux_perf"; interface NativeCore { @@ -21,6 +22,8 @@ try { isBound: true, }; } catch (e) { + logDebug("Failed to bind native core, instruments will not work."); + logDebug(e); native_core = { LinuxPerf: class LinuxPerf { start() { From 471a62f9f603196344dcb3b41f7dad19564fe64a Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 16 Sep 2025 12:18:23 +0200 Subject: [PATCH 3/7] ci(core): build artifacts for both x86 and arm64 during release --- .github/workflows/release.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7ed1904..37997c60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,31 @@ permissions: contents: write jobs: + build-native-arm: + runs-on: codspeedhq-arm64-ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v3 + with: + cache: pnpm + node-version-file: .nvmrc + - run: pnpm install --frozen-lockfile --prefer-offline + - name: Build native code on ARM + run: pnpm moon core:build-native-addon + - name: Upload ARM prebuilds + uses: actions/upload-artifact@v4 + with: + name: arm-prebuilds + path: packages/core/prebuilds + build: runs-on: ubuntu-latest + needs: build-native-arm steps: - uses: actions/checkout@v4 @@ -28,6 +51,12 @@ jobs: - name: Build the libraries run: pnpm moon run :build + - name: Download ARM prebuilds + uses: actions/download-artifact@v4 + with: + name: arm-prebuilds + path: packages/core/prebuilds + - name: Publish the libraries run: | if [[ "${{ github.ref }}" == *"-alpha"* ]]; then From bb7c9d9f81c515b5876bb102053207578023551d Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 16 Sep 2025 16:40:38 +0200 Subject: [PATCH 4/7] ci(core): run tests on arm as well --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 720726b7..21d941a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,10 @@ on: jobs: check: - runs-on: "ubuntu-latest" + strategy: + matrix: + os: ["ubuntu-latest", "codspeedhq-arm64-ubuntu-22.04"] + runs-on: ${{ matrix.os }} steps: - uses: "actions/checkout@v4" with: From 613c6a095beb9066200a350b234b462f6b2da305 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 16 Sep 2025 16:42:44 +0200 Subject: [PATCH 5/7] ci: fix deprecation warning about set-output --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21d941a0..e48aff26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: # list the directories in ./examples and output them to a github action workflow variables as a JSON array - run: | examples=$(find ./examples -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | jq -R -s -c 'split("\n") | map(select(length > 0))') - echo "::set-output name=examples::$examples" + echo "examples=$examples" >> $GITHUB_OUTPUT id: list-examples node-versions: From e8bd881c0a4ae5220151588567961da6d09359af Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Fri, 26 Sep 2025 12:00:50 +0200 Subject: [PATCH 6/7] feat(core): throw when trying to call setupCore with no native core --- packages/core/src/index.ts | 6 ++++++ packages/core/tests/index.integ.test.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ec89e15f..4e31f38d 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -33,6 +33,12 @@ export function getCodspeedRunnerMode(): CodSpeedRunnerMode { } export const setupCore = () => { + if (!native_core.isBound) { + throw new Error( + "Native core module is not bound, CodSpeed integration will not work properly" + ); + } + native_core.InstrumentHooks.setIntegration("codspeed-node", __VERSION__); linuxPerf.start(); checkV8Flags(); diff --git a/packages/core/tests/index.integ.test.ts b/packages/core/tests/index.integ.test.ts index 1b803844..d9b8dc83 100644 --- a/packages/core/tests/index.integ.test.ts +++ b/packages/core/tests/index.integ.test.ts @@ -24,4 +24,9 @@ describe("without bindings", () => { const isBound = require("..").isBound as boolean; expect(isBound).toBe(false); }); + + it("should throw when calling setupCore", () => { + const setupCore = require("..").setupCore as () => unknown; + expect(setupCore).toThrowError("Native core module is not bound"); + }); }); From 69c156b69b8bd7a7e3020d3457057f7a27341b46 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Fri, 26 Sep 2025 12:48:10 +0200 Subject: [PATCH 7/7] fix(core): fix tests failing after running `pnpm install` `node-gyp` was being too smart for its own good and was actually falling back to the local build, which should not be allowed for this test! --- packages/core/tests/index.integ.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/tests/index.integ.test.ts b/packages/core/tests/index.integ.test.ts index d9b8dc83..46f01baa 100644 --- a/packages/core/tests/index.integ.test.ts +++ b/packages/core/tests/index.integ.test.ts @@ -16,6 +16,8 @@ describe("without bindings", () => { const initialEnv = process.env; beforeAll(() => { process.env.npm_config_arch = "unknown"; + // Prevent node-gyp from falling back to a local version of the native core in packages/core/build + process.env.PREBUILDS_ONLY = "1"; }); afterAll(() => { process.env = initialEnv;