Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
set -e

echo ""
echo "=========================================="
echo "Running pre-push contract guards..."
echo "=========================================="
echo ""

npm run test:contract-guards
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ RECON will:
# Run all tests
npm test

# Run focused contract guards before push
npm run test:contract-guards

# Run tests in watch mode
npm run test:watch

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"bootstrap": "node scripts/init.cjs",
"build": "tsc",
"test": "vitest run",
"test:contract-guards": "vitest run src/cli/evidence-command.test.ts src/cli/spec-schema-fixture-sync.test.ts",
"test:watch": "vitest",
"test:unit": "vitest run",
"test:integration": "node scripts/prove-architecture-compile.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/evidence-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
async function loadSpecSchema(schemaFile: string): Promise<object> {
const steRuntimeRoot = path.resolve(__dirname, '..', '..');
const candidates = [
path.resolve(steRuntimeRoot, '..', 'ste-spec', 'schemas', schemaFile),
path.resolve(steRuntimeRoot, '..', 'ste-spec', 'contracts', schemaFile),
path.resolve(steRuntimeRoot, 'test', 'fixtures', schemaFile),
];
for (const schemaPath of candidates) {
Expand Down
43 changes: 43 additions & 0 deletions src/cli/spec-schema-fixture-sync.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import path from 'node:path';
import { access, readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';

import { describe, expect, it } from 'vitest';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const steRuntimeRoot = path.resolve(__dirname, '..', '..');
const siblingSchemaPath = path.resolve(
steRuntimeRoot,
'..',
'ste-spec',
'contracts',
'architecture-evidence.schema.json',
);
const fixtureSchemaPath = path.resolve(
steRuntimeRoot,
'test',
'fixtures',
'architecture-evidence.schema.json',
);

describe('architecture evidence schema fixture sync', () => {
it('keeps the committed test fixture present', async () => {
await expect(access(fixtureSchemaPath)).resolves.toBeUndefined();
});

it('matches the sibling ste-spec contract when available', async () => {
try {
await access(siblingSchemaPath);
} catch {
return;
}

const [fixtureBytes, siblingBytes] = await Promise.all([
readFile(fixtureSchemaPath),
readFile(siblingSchemaPath),
]);
expect(JSON.parse(fixtureBytes.toString('utf8'))).toEqual(
JSON.parse(siblingBytes.toString('utf8')),
);
});
});
27 changes: 20 additions & 7 deletions test/fixtures/architecture-evidence.schema.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://ste.local/test/architecture-evidence.schema.json",
"title": "ArchitectureEvidence (test mirror of ste-spec contract v1)",
"$id": "https://github.com/egallmann/ste-spec/contracts/architecture-evidence.schema.json",
"title": "ArchitectureEvidence",
"type": "object",
"additionalProperties": false,
"required": ["version", "bundle", "freshness"],
"properties": {
"version": { "const": "1" },
"version": {
"const": "1"
},
"bundle": {
"type": "object",
"additionalProperties": false,
"required": ["status", "warnings", "errors"],
"properties": {
"status": { "type": "string", "enum": ["valid", "degraded", "invalid"] },
"warnings": { "type": "array", "items": { "type": "string" } },
"errors": { "type": "array", "items": { "type": "string" } },
"status": {
"type": "string",
"enum": ["valid", "degraded", "invalid"]
},
"warnings": {
"type": "array",
"items": { "type": "string" }
},
"errors": {
"type": "array",
"items": { "type": "string" }
},
"manifest": {
"type": "object",
"additionalProperties": false,
Expand All @@ -40,7 +51,9 @@
"type": "string",
"enum": ["current", "stale-unknown", "stale-confirmed"]
},
"lastReconciled": { "type": "string" }
"lastReconciled": {
"type": "string"
}
}
}
}
Expand Down
Loading