-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
57 changed files
with
638 additions
and
95 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 '../../lib/testing/index.js'; | ||
import { convertToGitHubMatrix } from './support/github-ci-matrix.js'; | ||
import { dockerComposeMatrix } from './samples/docker-compose-integration.js'; | ||
|
||
export default class extends BaseGenerator { | ||
workflow; | ||
|
||
constructor(args, opts, features) { | ||
super(args, opts, { queueCommandTasks: true, ...features, jhipsterBootstrap: false }); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asWritingTaskGroup({ | ||
async buildMatrix() { | ||
if (this.workflow === 'docker-compose-integration') { | ||
setGithubTaskOutput('matrix', JSON.stringify(convertToGitHubMatrix(dockerComposeMatrix), 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'; |
44 changes: 44 additions & 0 deletions
44
.blueprint/github-build-matrix/samples/docker-compose-integration.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,44 @@ | ||
import { extendMatrix, fromMatrix } from '../../../lib/testing/index.js'; | ||
import { convertOptionsToJDL } from '../support/jdl.js'; | ||
|
||
// Supported containers: https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection | ||
export const dockerComposeMatrix = Object.fromEntries( | ||
[ | ||
...Object.entries( | ||
extendMatrix( | ||
{ | ||
...fromMatrix({ | ||
databaseType: ['cassandra', 'mongodb', 'neo4j'], | ||
reactive: [undefined, true], | ||
}), | ||
...extendMatrix( | ||
fromMatrix({ | ||
prodDatabaseType: ['postgresql', 'mysql', 'mariadb'], | ||
reactive: [undefined], | ||
}), | ||
{ cacheProvider: ['no', 'redis', 'memcached'] }, | ||
), | ||
...fromMatrix({ | ||
prodDatabaseType: ['postgresql', 'mysql', 'mariadb'], | ||
reactive: [true], | ||
}), | ||
}, | ||
{ | ||
buildTool: ['maven', 'gradle'], | ||
searchEngine: [undefined, 'elasticsearch'], | ||
authenticationType: ['jwt', 'oauth2'], | ||
serviceDiscoveryType: [undefined, 'eureka', 'consul'], | ||
messageBroker: [undefined, 'kafka'], | ||
}, | ||
), | ||
), | ||
['h2', { devDatabaseType: 'h2Disk' }], | ||
].map(([key, value]) => [ | ||
key, | ||
{ | ||
'cmd-e2e': 'npm run ci:e2e:dev', | ||
args: 'jdl', | ||
jdl: convertOptionsToJDL(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,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 = { | ||
include: 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 { | ||
include: 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,11 @@ | ||
export const convertOptionsToJDL = (opts: Record<string, any>): string => { | ||
return `application { | ||
config { | ||
testFrameworks [cypress] | ||
${Object.entries(opts) | ||
.filter(([_key, value]) => value !== undefined) | ||
.map(([key, value]) => ` ${key} ${value}`) | ||
.join('\n')} | ||
} | ||
}`; | ||
}; |
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,109 @@ | ||
# | ||
# Copyright the original author or authors from the JHipster project. | ||
# | ||
# This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
# for more information. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
name: Testcontainers Integration | ||
concurrency: | ||
# Group PRs by head_ref, push to main branch by commit id, and others branch by ref. | ||
group: ${{ github.workflow }}-${{ github.head_ref || (github.ref == 'refs/heads/main' && github.sha) || github.ref }} | ||
cancel-in-progress: true | ||
on: | ||
pull_request: | ||
types: [closed, opened, synchronize, reopened] | ||
branches: | ||
- '*' | ||
jobs: | ||
build-matrix: | ||
runs-on: ubuntu-20.04 | ||
if: >- | ||
contains(github.event.pull_request.labels.*.name, 'pr: docker-compose integration') | ||
outputs: | ||
matrix: ${{ steps.build.outputs.matrix }} | ||
empty-matrix: ${{ steps.build.outputs.empty-matrix }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- run: npm ci --ignore-scripts | ||
- id: build | ||
run: bin/jhipster.cjs github-build-matrix docker-compose-integration | ||
applications: | ||
name: ${{ matrix.job-name }} | ||
needs: build-matrix | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
working-directory: ${{ github.workspace }}/app | ||
timeout-minutes: 40 | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{fromJson(needs.build-matrix.outputs.matrix)}} | ||
steps: | ||
#---------------------------------------------------------------------- | ||
# Install all tools and check configuration | ||
#---------------------------------------------------------------------- | ||
- name: 'SETUP: Checkout generator-jhipster' | ||
uses: actions/checkout@v4 | ||
with: | ||
path: generator-jhipster | ||
fetch-depth: 2 | ||
- uses: jhipster/actions/setup-runner@v0 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
java-version: ${{ matrix.java-version }} | ||
npm-version: ${{ matrix.npm-version }} | ||
maven-cache: true | ||
gradle-cache: ${{ matrix.gradle-cache }} | ||
binary-dir: ${{ github.workspace }}/generator-jhipster/bin | ||
- run: npm ci --ignore-scripts | ||
working-directory: ${{ github.workspace }}/generator-jhipster | ||
- uses: jhipster/actions/build-jhipster-bom@v0 | ||
with: | ||
jhipster-bom-ref: main | ||
- name: Generate project | ||
run: jhipster.cjs ${{ matrix.args }} --defaults | ||
env: | ||
JHIPSTER_DEPENDENCIES_VERSION: 0.0.0-CICD | ||
JHI_SKIP_JHIPSTER_DEPENDENCIES: true | ||
JHI_PROFILE: ${{ matrix.default-environment }} | ||
JHI_JDL: ${{ matrix.jdl }} | ||
- run: jhipster.cjs info | ||
- run: ${{ matrix.cmd-e2e }} | ||
id: e2e | ||
- name: Upload cypress screenshots | ||
uses: actions/upload-artifact@v4 | ||
if: always() && steps.e2e.outcome == 'failure' | ||
with: | ||
name: screenshots-${{ matrix.name }} | ||
path: ${{ github.workspace }}app//*/cypress/screenshots | ||
check-workflow: | ||
permissions: | ||
contents: none | ||
runs-on: ubuntu-latest | ||
needs: [applications] | ||
if: always() | ||
steps: | ||
- run: | | ||
echo '${{ toJSON(needs) }}' | ||
if [ 'skipped' == '${{ needs.applications.result }}' ] || [ 'success' == '${{ needs.applications.result }}' ] || [ 'closed' == '${{ github.event.action }}' ]; then | ||
exit 0 | ||
fi | ||
exit 1 |
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 |
---|---|---|
|
@@ -28,6 +28,8 @@ on: | |
tags: | ||
- 'v*.*.*' | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
|
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
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
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
Oops, something went wrong.