From 5375cd6541770b98fefd2fc6a1c7158f2e7761b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bispo?= Date: Wed, 12 Aug 2026 15:44:30 +0100 Subject: [PATCH 1/3] Adds GitHub workflow --- .github/workflows/main.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e181223 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + JAVA_VERSION: 21 + +jobs: + test: + strategy: + fail-fast: false + matrix: + node-version: ['22.x'] + os: [ubuntu-latest, windows-2022, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + registry-url: 'https://registry.npmjs.org/' + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm ci + + - name: Build the project + run: npm run build + + - name: Run tests + run: npm run test From 5d41b8a59e7e159398abd73cf726df13724e3bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bispo?= Date: Wed, 12 Aug 2026 15:58:56 +0100 Subject: [PATCH 2/3] Adds two workflow tests (gpt-5.6-sol high) --- .github/workflows/main.yml | 2 +- package.json | 1 + test/ExtendedTaskGraph.test.ts | 55 ++++++++++++++++++++++++++++++++++ tsconfig.jest.json | 3 ++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/ExtendedTaskGraph.test.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e181223..ca0246c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies - run: npm ci + run: npm install - name: Build the project run: npm run build diff --git a/package.json b/package.json index 1baaafa..e2ea127 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "clean": "rm -rf node_modules package-lock.json dist/ woven_code/ output/", "lint": "eslint .", "docs": "typedoc", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --detectOpenHandles --forceExit", "bundle": "npm run build && pkg . --targets node18-linux-x64,node18-macos-x64,node18-win-x64 --out-path bin", "simple:appdump": "clava dist/test/simple-use-cases/AppDumping.js -- clang inputs/edgedetect-transformed/", "simple:transflow": "clava dist/test/simple-use-cases/CodeTransformationFlow.js -- clang inputs/edgedetect/", diff --git a/test/ExtendedTaskGraph.test.ts b/test/ExtendedTaskGraph.test.ts new file mode 100644 index 0000000..2790a93 --- /dev/null +++ b/test/ExtendedTaskGraph.test.ts @@ -0,0 +1,55 @@ +import { readFileSync } from "node:fs"; +import { registerSourceCode } from "@specs-feup/lara/jest/jestHelpers.js"; +import { ExtendedTaskGraphAPI } from "../src/api/ExtendedTaskGraphAPI.js"; +import { GenFlowConfig } from "../src/api/GenFlowConfig.js"; +import { TransFlowConfig } from "../src/api/TransFlowConfig.js"; + +const source = readFileSync( + "inputs/cluster-scenario/ClusterScenario.cpp", + "utf8", +); + +describe("ExtendedTaskGraphAPI workflows", () => { + registerSourceCode(source); + + test("runs the code transformation flow", () => { + const config = new TransFlowConfig(); + config.dumpAST = false; + config.dumpCallGraph = false; + config.doSubsetInterTransforms = false; + config.doSubsetTaskTransforms = false; + + const api = new ExtendedTaskGraphAPI( + "start", + "output/tests", + "transformation-flow", + ); + + expect(api.runCodeTransformationFlow(config)).toBe(true); + }); + + test("builds a task graph from transformed code", () => { + const api = new ExtendedTaskGraphAPI( + "start", + "output/tests", + "task-graph-flow", + ); + + const transConfig = new TransFlowConfig(); + transConfig.dumpAST = false; + transConfig.dumpCallGraph = false; + transConfig.transformRecipe = []; + + expect(api.runCodeTransformationFlow(transConfig)).toBe(true); + + const config = new GenFlowConfig(); + config.dumpGraph = false; + config.gatherMetrics = false; + + const taskGraph = api.runTaskGraphGenerationFlow(config); + + expect(taskGraph).not.toBeNull(); + expect(taskGraph!.getTasks().length).toBeGreaterThan(0); + expect(taskGraph!.getTaskByName("fizzbuzz")).toBeDefined(); + }); +}); diff --git a/tsconfig.jest.json b/tsconfig.jest.json index dd7eedd..7852d50 100644 --- a/tsconfig.jest.json +++ b/tsconfig.jest.json @@ -1,5 +1,8 @@ { "extends": "./tsconfig.json", + "compilerOptions": { + "isolatedModules": true + }, "include": ["**/*.spec.ts", "**/*.test.ts"], "exclude": ["node_modules"] } From aac599730f4f735c9ca3c86e7bb27cabced50bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bispo?= Date: Wed, 12 Aug 2026 16:07:05 +0100 Subject: [PATCH 3/3] Fixes the CI-specific Jest resolution issue (gpt-5.6-sol high) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: LARA’s jestHelpers.js import resolves to an uncompiled TypeScript file in the published npm package. Jest ignores TypeScript inside node_modules, causing Unexpected token ':'. Changes: - Configured ts-jest to explicitly use tsconfig.jest.json, eliminating the TS151002 warnings. - Replaced the problematic helper import with equivalent lifecycle hooks using LARA’s compiled public APIs in test/ExtendedTaskGraph.test.ts:1. - Updated jest.config.js:3 with an explicit ESM TypeScript transform. --- jest.config.js | 11 ++++++++++- test/ExtendedTaskGraph.test.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/jest.config.js b/jest.config.js index e142053..804bc2f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,16 @@ import { weaverConfig } from "@specs-feup/clava/code/WeaverConfiguration.js"; const config = { - preset: "ts-jest/presets/default-esm", + transform: { + "^.+\\.tsx?$": [ + "ts-jest", + { + useESM: true, + tsconfig: "tsconfig.jest.json", + }, + ], + }, + extensionsToTreatAsEsm: [".ts"], testEnvironment: "@specs-feup/lara/jest/jestEnvironment.js", testEnvironmentOptions: { weaverConfig, diff --git a/test/ExtendedTaskGraph.test.ts b/test/ExtendedTaskGraph.test.ts index 2790a93..2152594 100644 --- a/test/ExtendedTaskGraph.test.ts +++ b/test/ExtendedTaskGraph.test.ts @@ -1,5 +1,6 @@ import { readFileSync } from "node:fs"; -import { registerSourceCode } from "@specs-feup/lara/jest/jestHelpers.js"; +import JavaTypes from "@specs-feup/lara/api/lara/util/JavaTypes.js"; +import Weaver from "@specs-feup/lara/api/weaver/Weaver.js"; import { ExtendedTaskGraphAPI } from "../src/api/ExtendedTaskGraphAPI.js"; import { GenFlowConfig } from "../src/api/GenFlowConfig.js"; import { TransFlowConfig } from "../src/api/TransFlowConfig.js"; @@ -9,6 +10,30 @@ const source = readFileSync( "utf8", ); +function registerSourceCode(code: string): void { + beforeEach(() => { + const javaWeaver = Weaver.getWeaverEngine(); + const javaDatastore = javaWeaver.getData().get(); + + javaWeaver.run(["ClusterScenario.cpp"], [code], javaDatastore); + }); + + afterEach(() => { + Weaver.getWeaverEngine().end(); + }); + + afterAll(() => { + const javaWeaver = Weaver.getWeaverEngine(); + const javaDatastore = javaWeaver.getData().get(); + + javaDatastore.set( + JavaTypes.LaraiKeys.WORKSPACE_FOLDER, + JavaTypes.FileList.newInstance(), + ); + javaWeaver.run(javaDatastore); + }); +} + describe("ExtendedTaskGraphAPI workflows", () => { registerSourceCode(source);