feat(resolve-check-config): defined required integration test services required (#269)

This commit is contained in:
Damien Retzinger
2026-05-17 19:01:11 -04:00
parent d07afbacd0
commit 35c1ace2bc
3 changed files with 52 additions and 14 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -1,14 +1,17 @@
import { EXTENSION_JOBS, KNOWN_JOBS_EXTENSION, resolveExtensionConfig } from './extension'; import { EXTENSION_JOBS, KNOWN_JOBS_EXTENSION, resolveExtensionConfig } from './extension';
import { Matrix } from '../types'; import { Matrix } from '../types';
const MATRIX: Matrix = { const FULL_SERVICES = {
include: [{
php: '8.3',
services: {
mysql: { image: 'mysql:8' }, mysql: { image: 'mysql:8' },
opensearch: { image: 'opensearchproject/opensearch:2' }, opensearch: { image: 'opensearchproject/opensearch:2' },
}, rabbitmq: { image: 'rabbitmq:3' },
}], valkey: { image: 'valkey:8' },
nginx: { image: 'nginx:1.27' },
'php-fpm': { image: 'php:8.3-fpm' },
};
const MATRIX: Matrix = {
include: [{ php: '8.3', services: { ...FULL_SERVICES } }],
}; };
describe('EXTENSION_JOBS', () => { describe('EXTENSION_JOBS', () => {
@@ -24,6 +27,23 @@ describe('EXTENSION_JOBS', () => {
it('keeps KNOWN_JOBS_EXTENSION in sync with the map keys', () => { it('keeps KNOWN_JOBS_EXTENSION in sync with the map keys', () => {
expect([...KNOWN_JOBS_EXTENSION].sort()).toEqual(Object.keys(EXTENSION_JOBS).sort()); expect([...KNOWN_JOBS_EXTENSION].sort()).toEqual(Object.keys(EXTENSION_JOBS).sort());
}); });
it('declares integration_test required tiers (no web)', () => {
expect(EXTENSION_JOBS['integration_test'].services).toEqual([]);
expect([...EXTENSION_JOBS['integration_test'].requiredServices!].sort()).toEqual([
'cache',
'db',
'queue',
'search',
]);
});
it('leaves the non-service jobs with empty defaults', () => {
for (const name of ['unit-test-extension', 'compile-extension', 'coding-standard']) {
expect(EXTENSION_JOBS[name].services).toEqual([]);
expect(EXTENSION_JOBS[name].requiredServices).toBeUndefined();
}
});
}); });
describe('resolveExtensionConfig', () => { describe('resolveExtensionConfig', () => {
@@ -37,19 +57,34 @@ describe('resolveExtensionConfig', () => {
]); ]);
}); });
it('emits services={} for every job under the current defaults', () => { it('emits services={} for the non-service jobs', () => {
const resolved = resolveExtensionConfig({}, MATRIX); const resolved = resolveExtensionConfig({}, MATRIX);
for (const name of Object.keys(resolved)) { for (const name of ['unit-test-extension', 'compile-extension', 'coding-standard']) {
expect(resolved[name].matrix.include[0].services).toEqual({}); expect(resolved[name].matrix.include[0].services).toEqual({});
} }
}); });
it('still accepts a caller-supplied services override', () => { it('integration_test includes mysql/search/queue/cache but NOT nginx/php-fpm', () => {
const resolved = resolveExtensionConfig({}, MATRIX);
expect(Object.keys(resolved['integration_test'].matrix.include[0].services!).sort()).toEqual([
'mysql',
'opensearch',
'rabbitmq',
'valkey',
]);
});
it('keeps integration_test required tiers even when caller overrides services to []', () => {
const resolved = resolveExtensionConfig( const resolved = resolveExtensionConfig(
{ jobs: { integration_test: { services: ['search'] } } }, { jobs: { integration_test: { services: [] } } },
MATRIX, MATRIX,
); );
expect(Object.keys(resolved['integration_test'].matrix.include[0].services!)).toEqual(['opensearch']); expect(Object.keys(resolved['integration_test'].matrix.include[0].services!).sort()).toEqual([
'mysql',
'opensearch',
'rabbitmq',
'valkey',
]);
}); });
it('throws on a typo in the job name', () => { it('throws on a typo in the job name', () => {
+4 -1
View File
@@ -12,7 +12,10 @@ export const EXTENSION_JOBS: Record<string, JobDefaults> = {
'unit-test-extension': { services: [] }, 'unit-test-extension': { services: [] },
'compile-extension': { services: [] }, 'compile-extension': { services: [] },
'coding-standard': { services: [] }, 'coding-standard': { services: [] },
'integration_test': { services: [] }, 'integration_test': {
services: [],
requiredServices: ['db', 'search', 'queue', 'cache'],
},
}; };
export const KNOWN_JOBS_EXTENSION: readonly string[] = Object.keys(EXTENSION_JOBS); export const KNOWN_JOBS_EXTENSION: readonly string[] = Object.keys(EXTENSION_JOBS);