-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { JHipsterCommandDefinition } from '../../generators/index.js'; | ||
|
||
export default { | ||
configs: { | ||
workflow: { | ||
description: 'Workflow', | ||
argument: { | ||
type: String, | ||
}, | ||
scope: 'generator', | ||
choices: ['testcontainers'], | ||
}, | ||
}, | ||
} as const satisfies JHipsterCommandDefinition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import BaseGenerator from '../../generators/base/index.js'; | ||
import { setGithubTaskOutput } from '../../testing/index.js'; | ||
import { convertToGitHubMatrix } from './support/github-ci-matrix.js'; | ||
import { testcontainersMatrix } from './support/testcontainers.js'; | ||
|
||
export default class extends BaseGenerator { | ||
workflow; | ||
|
||
constructor(args, opts, features) { | ||
super(args, opts, { ...features, jhipsterBootstrap: true }); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asWritingTaskGroup({ | ||
async buildMatrix() { | ||
if (this.workflow === 'testcontainers') { | ||
setGithubTaskOutput('matrix', JSON.stringify(convertToGitHubMatrix(testcontainersMatrix), null, 2)); | ||
} | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './generator.js'; | ||
export { default as command } from './command.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { kebabCase } from 'lodash-es'; | ||
|
||
export const convertToCliArgs = (opts: Record<string, any>): string => { | ||
return Object.entries(opts) | ||
.map(([key, value]) => { | ||
key = kebabCase(key); | ||
if (typeof value === 'boolean') { | ||
return `--${value ? '' : 'no-'}${key}`; | ||
} | ||
return `--${key} ${value}`; | ||
}) | ||
.join(' '); | ||
}; |
38 changes: 38 additions & 0 deletions
38
.blueprint/github-build-matrix/support/github-ci-matrix.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { RECOMMENDED_JAVA_VERSION, RECOMMENDED_NODE_VERSION } from '../../../generators/index.js'; | ||
|
||
type GitHubMatrix = { | ||
os: string; | ||
'node-version': string; | ||
'java-version': string; | ||
'default-environment': string; | ||
'job-name': string; | ||
args: string; | ||
}; | ||
|
||
type GitHubMatrixOutput = { | ||
includes: GitHubMatrix[]; | ||
}; | ||
|
||
export const defaultEnvironment = { | ||
os: 'ubuntu-latest', | ||
'node-version': RECOMMENDED_NODE_VERSION, | ||
'java-version': RECOMMENDED_JAVA_VERSION, | ||
'default-environment': 'prod', | ||
}; | ||
|
||
export const defaultEnvironmentMatrix = { | ||
os: ['ubuntu-latest'], | ||
'node-version': [RECOMMENDED_NODE_VERSION], | ||
'java-version': [RECOMMENDED_JAVA_VERSION], | ||
'default-environment': ['prod'], | ||
}; | ||
|
||
export const convertToGitHubMatrix = (matrix: Record<string, any>): GitHubMatrixOutput => { | ||
return { | ||
includes: Object.entries(matrix).map(([key, value]) => ({ | ||
'job-name': key, | ||
...defaultEnvironment, | ||
...value, | ||
})), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { extendMatrix, fromMatrix } from '../../../testing/index.js'; | ||
import { convertToCliArgs } from './cli-args.js'; | ||
|
||
export const testcontainersMatrix = Object.fromEntries( | ||
Object.entries( | ||
extendMatrix( | ||
{ | ||
...fromMatrix({ reactive: [false, true], databaseType: ['cassandra', 'mongodb', 'neo4j'] }), | ||
...extendMatrix(fromMatrix({ reactive: [false, true], prodDatabaseType: ['postgresql', 'mysql', 'mariadb'] }), { | ||
cacheProvider: ['no', 'redis', 'memcached'], | ||
}), | ||
}, | ||
{ | ||
searchEngine: ['no', 'elasticsearch'], | ||
auth: ['jwt', 'oauth2'], | ||
serviceDiscovery: ['no', 'eureka', 'consul'], | ||
messageBroker: ['no', 'kafka', 'pulsar'], | ||
}, | ||
), | ||
).map(([key, value]) => [key, { args: convertToCliArgs(value) }]), | ||
); |