Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add java:graalvm generator. #27660

Merged
merged 2 commits into from
Oct 23, 2024
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
2 changes: 1 addition & 1 deletion .blueprint/generate-generator/templates/command.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { JHipsterCommandDefinition } from '<%- generatorRelativePath %>base/api.js';
import type { JHipsterCommandDefinition } from '<%- generatorRelativePath %>../lib/command/types.js';

const command = {
configs: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,61 @@ exports[`generator - github-build-matrix with docker-compose-integration should
}"
`;

exports[`generator - github-build-matrix with graalvm should match matrix value 1`] = `
"{
"include": [
{
"job-name": "maven",
"sample": "maven",
"os": "ubuntu-latest",
"node-version": "NODE-VERSION",
"java-version": "21",
"npm-version": "NPM-VERSION",
"default-environment": "prod",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"jdl-base": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool maven\\n cacheProvider no\\n }\\n}",
"jdl": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool maven\\n graalvmSupport true\\n }\\n}"
},
{
"job-name": "maven-reactive(true)",
"sample": "maven-reactive(true)",
"os": "ubuntu-latest",
"node-version": "NODE-VERSION",
"java-version": "21",
"npm-version": "NPM-VERSION",
"default-environment": "prod",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"jdl-base": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool maven\\n reactive true\\n cacheProvider no\\n }\\n}",
"jdl": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool maven\\n reactive true\\n graalvmSupport true\\n }\\n}"
},
{
"job-name": "gradle",
"sample": "gradle",
"os": "ubuntu-latest",
"node-version": "NODE-VERSION",
"java-version": "21",
"npm-version": "NPM-VERSION",
"default-environment": "prod",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"jdl-base": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool gradle\\n cacheProvider no\\n }\\n}",
"jdl": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool gradle\\n graalvmSupport true\\n }\\n}"
},
{
"job-name": "gradle-reactive(true)",
"sample": "gradle-reactive(true)",
"os": "ubuntu-latest",
"node-version": "NODE-VERSION",
"java-version": "21",
"npm-version": "NPM-VERSION",
"default-environment": "prod",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"jdl-base": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool gradle\\n reactive true\\n cacheProvider no\\n }\\n}",
"jdl": "application {\\n config {\\n testFrameworks [cypress]\\n buildTool gradle\\n reactive true\\n graalvmSupport true\\n }\\n}"
}
]
}"
`;

exports[`generator - github-build-matrix with react should match matrix value 1`] = `
"{
"include": [
Expand Down
2 changes: 1 addition & 1 deletion .blueprint/github-build-matrix/command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { JHipsterCommandDefinition } from '../../generators/index.js';

export const workflowChoices = ['angular', 'devserver', 'react', 'docker-compose-integration', 'vue'] as const;
export const workflowChoices = ['angular', 'devserver', 'graalvm', 'react', 'docker-compose-integration', 'vue'] as const;
export const eventNameChoices = ['push', 'pull_request', 'daily'] as const;

export default {
Expand Down
2 changes: 1 addition & 1 deletion .blueprint/github-build-matrix/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const generator = basename(__dirname);
describe(`generator - ${generator}`, () => {
shouldSupportFeatures(Generator);

for (const workflow of ['angular', 'devserver', 'react', 'docker-compose-integration', 'vue']) {
for (const workflow of ['angular', 'devserver', 'graalvm', 'react', 'docker-compose-integration', 'vue']) {
describe(`with ${workflow}`, () => {
before(async () => {
await helpers.runJHipster(join(__dirname, 'index.ts'), { useEnvironmentBuilder: true }).withArguments(workflow);
Expand Down
5 changes: 5 additions & 0 deletions .blueprint/github-build-matrix/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { dockerComposeMatrix } from './samples/docker-compose-integration.js';
import { getGitChanges } from './support/git-changes.js';
import { devServerMatrix } from './samples/dev-server.js';
import type { eventNameChoices, workflowChoices } from './command.js';
import { graalvmMatrix } from './samples/graalvm.js';

type JHipsterGitHubMatrix = GitHubMatrix & {
name: string;
Expand Down Expand Up @@ -50,6 +51,10 @@ export default class extends BaseGenerator {
let randomEnvironment = false;
if (this.workflow === 'docker-compose-integration') {
matrix = dockerComposeMatrix;
} else if (this.workflow === 'graalvm') {
if (hasWorkflowChanges || java) {
matrix = graalvmMatrix;
}
} else if (this.workflow === 'devserver') {
if (devBlueprint || hasWorkflowChanges || client) {
matrix = { ...devServerMatrix.angular, ...devServerMatrix.react, ...devServerMatrix.vue };
Expand Down
23 changes: 23 additions & 0 deletions .blueprint/github-build-matrix/samples/graalvm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { extendMatrix, fromMatrix } from '../../../lib/testing/index.js';
import { convertOptionsToJDL } from '../support/jdl.js';

export const graalvmMatrix = Object.fromEntries(
[
...Object.entries(
extendMatrix(
fromMatrix({
buildTool: ['maven', 'gradle'],
reactive: [undefined, true],
}),
{},
),
),
].map(([key, value]) => [
key,
{
'java-version': '21',
'jdl-base': convertOptionsToJDL({ ...value, cacheProvider: 'no' }),
jdl: convertOptionsToJDL({ ...value, graalvmSupport: true }),
},
]),
);
1 change: 1 addition & 0 deletions .blueprint/github-build-matrix/support/github-ci-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type GitHubMatrix = {
sample: string;
args?: string;
'jwt-secret-key'?: string;
jdl?: string;
};

export type GitHubMatrixRecord = Record<string, Partial<Omit<GitHubMatrix, 'job-name'>> & { disabled?: boolean }>;
Expand Down
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,13 @@ updates:
- 'theme: github_actions'
- 'theme: CI builds'
- 'skip-changelog'

- package-ecosystem: 'gradle'
directory: '/generators/spring-boot/generators/graalvm/resources/'
schedule:
interval: 'daily'
time: '08:30'
open-pull-requests-limit: 5
labels:
- 'theme: dependencies'
- 'skip-changelog'
165 changes: 165 additions & 0 deletions .github/workflows/generator-graalvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#
# 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: Incremental Changelog
on: [workflow_call]
env:
FORCE_COLOR: 2
jobs:
build-matrix:
runs-on: ubuntu-latest
if: >-
!contains(github.event.head_commit.message, '[ci skip]') &&
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.pull_request.title, '[skip ci]') &&
!contains(github.event.pull_request.title, '[ci skip]') &&
github.event.action != 'closed' &&
(github.event.pull_request.draft == false || !contains(github.event.pull_request.labels.*.name, 'pr: skip-ci'))
outputs:
matrix: ${{ steps.build.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci --ignore-scripts
- id: build
run: bin/jhipster.cjs github-build-matrix graalvm --event-name ${{ github.event_name }}
applications:
name: ${{ matrix.job-name }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ${{ github.workspace }}/app
timeout-minutes: 40
needs: build-matrix
if: fromJson(needs.build-matrix.outputs.matrix).include[0] != null
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
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- run: npm ci --ignore-scripts
working-directory: ${{ github.workspace }}/generator-jhipster
- name: 'GENERATION: project'
run: jhipster.cjs jdl --skip-jhipster-dependencies --skip-install
env:
JHI_FOLDER_APP: ${{ github.workspace }}/app
JHIPSTER_DEPENDENCIES_VERSION: ${{ matrix.jhipster-bom-cicd-version }}
JHI_JWT_SECRET_KEY: ${{ matrix.jwt-secret-key }}
JHI_JDL: ${{ matrix.jdl }}
- run: jhipster.cjs info
#----------------------------------------------------------------------
# Detect changes against base commit
#----------------------------------------------------------------------
- uses: jhipster/actions/compare-sample@v0
id: compare
if: >-
github.event.pull_request &&
!contains(github.event.pull_request.labels.*.name, 'pr: disable-compare')
with:
generator-path: generator-jhipster
cmd: jhipster.cjs jdl --skip-jhipster-dependencies --skip-install
env:
# generate-sample uses JHI_FOLDER_APP to generate the application.
JHI_FOLDER_APP: ${{ github.workspace }}/base/app
JHIPSTER_DEPENDENCIES_VERSION: ${{ matrix.jhipster-bom-cicd-version }}
JHI_JWT_SECRET_KEY: ${{ matrix.jwt-secret-key }}
JHI_JDL: ${{ matrix.jdl-base || matrix.jdl }}
#----------------------------------------------------------------------
# Launch tests
#----------------------------------------------------------------------
- name: 'SETUP: setup graalvm'
uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- uses: jhipster/actions/build-jhipster-bom@v0
if: matrix.build-jhipster-bom && steps.compare.outputs.equals != 'true'
with:
jhipster-bom-ref: ${{ matrix.jhipster-bom-branch }}
- run: npm run native-package
if: steps.compare.outputs.equals != 'true'
id: packaging
timeout-minutes: 20
- run: npm run services:up
if: steps.compare.outputs.equals != 'true'
- run: npm run native-e2e --if-present
id: e2e
if: steps.compare.outputs.equals != 'true'
- name: Store the application
uses: actions/upload-artifact@v4
if: always() && (steps.e2e.outcome == 'failure' || steps.packaging.outcome == 'failure')
with:
name: app-${{ matrix.sample }}
include-hidden-files: true
path: |
${{ github.workspace }}/app/**/*
!**/app/build/**
!**/app/*/build/**
!**/app/.gradle/**
!**/app/*/.gradle/**
!**/app/target/**
!**/app/*/target/**
!**/node_modules/**
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v4
if: always() && steps.e2e.outcome == 'failure'
with:
name: screenshots-${{ matrix.sample }}
path: ${{ github.workspace }}/app/**/cypress/screenshots
- name: Dump docker logs
if: always() && contains(matrix.os, 'ubuntu')
uses: jwalton/gh-docker-logs@v2

check-graalvm:
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
7 changes: 6 additions & 1 deletion .github/workflows/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ jobs:
permissions:
contents: none
uses: ./.github/workflows/generator-database-changelog-liquibase.yml
graalvm:
permissions:
contents: none
uses: ./.github/workflows/generator-graalvm.yml
check-generators:
permissions:
contents: none
runs-on: ubuntu-latest
needs: [generate-blueprint, database-changelog-liquibase]
needs: [generate-blueprint, database-changelog-liquibase, graalvm]
if: always()
steps:
- run: |
echo '${{ toJSON(needs) }}'
if ([ 'skipped' == '${{ needs.generate-blueprint.result }}' ] || [ 'success' == '${{ needs.generate-blueprint.result }}' ]) && \
([ 'skipped' == '${{ needs.graalvm.result }}' ] || [ 'success' == '${{ needs.graalvm.result }}' ]) && \
([ 'skipped' == '${{ needs.database-changelog-liquibase.result }}' ] || [ 'success' == '${{ needs.database-changelog-liquibase.result }}' ]); then
exit 0
fi
Expand Down
7 changes: 7 additions & 0 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Options:
--sync-user-with-idp Allow relationships with User for oauth2 applications
--message-broker <value> message broker (choices: "kafka", "pulsar", "no")
--database-migration <value> Database migration (choices: "liquibase")
--graalvm-support Experimental GraalVM Native support
--with-generated-flag Add a GeneratedByJHipster annotation to all generated java classes and interfaces
--package-name <value> The package name for the generated application
--build <value> Provide build tool for the application when skipping server side generation (default: maven) (choices: "maven", "gradle")
Expand Down Expand Up @@ -485,6 +486,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"generateUserManagement": true,
"githubRepository": undefined,
"githubWorkflows": undefined,
"graalvmSupport": undefined,
"gradleEnterpriseHost": undefined,
"hipster": "jhipster_family_member_3",
"hipsterBugTrackerLink": "https://github.com/jhipster/generator-jhipster/issues?state=open",
Expand Down Expand Up @@ -744,6 +746,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
},
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
Expand Down Expand Up @@ -1136,6 +1139,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"generateUserManagement": true,
"githubRepository": undefined,
"githubWorkflows": undefined,
"graalvmSupport": undefined,
"gradleEnterpriseHost": undefined,
"hipster": "jhipster_family_member_3",
"hipsterBugTrackerLink": "https://github.com/jhipster/generator-jhipster/issues?state=open",
Expand Down Expand Up @@ -1389,6 +1393,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
},
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
Expand Down Expand Up @@ -1780,6 +1785,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"generateUserManagement": false,
"githubRepository": undefined,
"githubWorkflows": undefined,
"graalvmSupport": undefined,
"gradleEnterpriseHost": undefined,
"hipster": "jhipster_family_member_3",
"hipsterBugTrackerLink": "https://github.com/jhipster/generator-jhipster/issues?state=open",
Expand Down Expand Up @@ -1980,6 +1986,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
},
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
Expand Down
Loading
Loading