From 72013d3aeecfd16b2e3b74a5bc7a667af3c3fc6d Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Wed, 29 Jul 2026 06:38:46 -0700 Subject: [PATCH] test: run the unit:integrations vitest project and de-rot its version test vitest.config.ts declares six projects, but the `test`, `test:unit` and `test:coverage` scripts enumerate the unit projects by hand and omitted `unit:integrations`. CI runs `test:coverage`, so `integrations/test/**/*_test.ts` was never executed by .github/workflows/validation.yaml and the entire integrations test surface was dark. Add `unit:integrations` to those three scripts, ordered to match the project declaration order in vitest.config.ts. `test:integration`, `test:e2e` and `test:cross-language` are deliberate single-project entry points and are left alone; `cross-language` stays out of the default suite because it needs a Go toolchain and has its own workflow. Then repair the test that rotted while nobody was running it. It asserted a hardcoded '1.3.0' against an export release-please had already bumped to '1.4.0'. Derive the expectation from integrations/package.json at runtime instead: release-please rewrites the manifest and src/version.ts in the same release commit, so the manifest is a self-maintaining oracle and the literal cannot drift again. A second assertion checks semver shape, which catches the degenerate case where both files drift together into something that is not a version at all. Coverage thresholds are unaffected. No production code, public API or dependency changes. --- integrations/test/version_test.ts | 18 ++++++++++++++++-- package.json | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/integrations/test/version_test.ts b/integrations/test/version_test.ts index 9f5a6900a..52bcd8de1 100644 --- a/integrations/test/version_test.ts +++ b/integrations/test/version_test.ts @@ -5,10 +5,24 @@ */ import {version} from '@google/adk-integrations'; +import {readFileSync} from 'node:fs'; import {describe, expect, it} from 'vitest'; +const SEMVER_PATTERN = + /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/; + +// release-please rewrites src/version.ts and package.json in the same release +// commit, so package.json is a self-maintaining oracle; a literal here rots. +const packageJson = JSON.parse( + readFileSync(new URL('../package.json', import.meta.url), 'utf-8'), +) as {version: string}; + describe('version', () => { - it('should return the correct version', () => { - expect(version).toBe('1.3.0'); + it('should match the version declared in package.json', () => { + expect(version).toBe(packageJson.version); + }); + + it('should be a valid semver string', () => { + expect(version).toMatch(SEMVER_PATTERN); }); }); diff --git a/package.json b/package.json index 86cee8241..d5b10ea5d 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,12 @@ "docs:generate": "typedoc", "docs:serve": "http-server api-reference/typescript", "docs:check": "typedoc --emit none --treatWarningsAsErrors", - "test": "vitest --project unit:core --project unit:dev --project integration --project e2e", - "test:unit": "vitest --project unit:core --project unit:dev", + "test": "vitest --project unit:core --project unit:dev --project unit:integrations --project integration --project e2e", + "test:unit": "vitest --project unit:core --project unit:dev --project unit:integrations", "test:integration": "vitest --project integration", "test:e2e": "vitest --project e2e", "test:cross-language": "vitest --project cross-language", - "test:coverage": "vitest run --project unit:core --project unit:dev --project integration --project e2e --coverage", + "test:coverage": "vitest run --project unit:core --project unit:dev --project unit:integrations --project integration --project e2e --coverage", "prepare": "husky" }, "workspaces": [