Skip to content

Commit

Permalink
Merge branch 'jhipster:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Aug 26, 2023
2 parents bb80bdf + f71af30 commit 20fd611
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 12 deletions.
42 changes: 34 additions & 8 deletions .blueprint/from-issue/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Octokit } from 'octokit';
import { setOutput } from '@actions/core';
import BaseGenerator from '../../generators/base/index.mjs';
import command from './command.mjs';
import { promptSamplesFolder } from '../support.mjs';
Expand All @@ -8,6 +9,15 @@ import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.mjs';
import { CLI_NAME } from '../../cli/utils.mjs';
import EnvironmentBuilder from '../../cli/environment-builder.mjs';

const YO_RC_OUTPUT = 'yo-rc';
const ENTITIES_JDL_OUTPUT = 'entities-jdl';
const RESULT_OUTPUT = 'result';

const BLANK = 'blank';
const VALID = 'valid';
const ERROR = 'error';
const SUCCESS = 'successfully generated';

export default class extends BaseGenerator {
issue;
projectFolder;
Expand Down Expand Up @@ -53,9 +63,19 @@ export default class extends BaseGenerator {
let match;
while ((match = regexp.exec(issue.data.body)) !== null) {
if (match.groups.title.includes('.yo-rc.json file')) {
this.yoRcContent = JSON.parse(match.groups.body);
try {
if (match.groups.body) {
this.yoRcContent = JSON.parse(match.groups.body);
setOutput(YO_RC_OUTPUT, VALID);
} else {
setOutput(YO_RC_OUTPUT, BLANK);
}
} catch {
setOutput(YO_RC_OUTPUT, ERROR);
}
} else if (match.groups.title.includes('JDL entity definitions')) {
this.jdlEntities = match.groups.body?.trim();
setOutput(ENTITIES_JDL_OUTPUT, this.jdlEntities ? VALID : BLANK);
}
}

Expand All @@ -80,17 +100,23 @@ export default class extends BaseGenerator {
return this.asEndTaskGroup({
async generateSample() {
if (this.jdlEntities) {
await this.runNonInteractive({
cwd: this.projectFolder,
inline: this.jdlEntities,
generatorOptions: {
jsonOnly: true,
},
});
try {
await this.runNonInteractive({
cwd: this.projectFolder,
inline: this.jdlEntities,
generatorOptions: {
jsonOnly: true,
},
});
} catch (error) {
setOutput(ENTITIES_JDL_OUTPUT, ERROR);
throw error;
}
}
if (this.yoRcContent) {
await this.runNonInteractive({ cwd: this.projectFolder, generatorOptions: { withEntities: true } });
}
setOutput(RESULT_OUTPUT, SUCCESS);

if (this.codeWorkspace) {
await this.composeWithJHipster('@jhipster/jhipster-dev:code-workspace', {
Expand Down
47 changes: 44 additions & 3 deletions .github/workflows/issue-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
name: Issue Check
on:
issues:
types: [reopened]
types: [reopened, labeled]
workflow_dispatch:
inputs:
issue:
Expand All @@ -30,8 +30,20 @@ on:
permissions:
contents: read
jobs:
applications:
comment:
runs-on: ubuntu-latest
permissions:
issues: write
if: "${{ github.event.action != 'labeled' || github.event.label.name == 'area: check' }}"
steps:
- uses: mshick/[email protected]
with:
issue: ${{ inputs.issue || github.event.issue.id }}
message: |
JHipster is [checking sample](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
application:
name: Check issue ${{ inputs.issue || github.event.issue.id }}
needs: comment
runs-on: 'ubuntu-20.04'
defaults:
run:
Expand Down Expand Up @@ -87,6 +99,7 @@ jobs:
- name: 'GENERATION: install JHipster'
run: $JHI_SCRIPTS/10-install-jhipster.sh
- name: 'GENERATION: project'
id: project
run: jhipster from-issue ${{ inputs.issue || github.event.issue.id }} --no-code-workspace
- name: 'GENERATION: jhipster info'
run: $JHI_SCRIPTS/14-jhipster-info.sh
Expand All @@ -99,9 +112,12 @@ jobs:
- name: 'TESTS: backend'
id: backend
run: npm run ci:backend:test --if-present
continue-on-error: true
timeout-minutes: 15
- name: 'TESTS: frontend'
id: frontend
run: npm run ci:frontend:test --if-present
continue-on-error: true
timeout-minutes: 15
- name: 'TESTS: packaging'
run: npm run ci:e2e:package --if-present
Expand All @@ -126,5 +142,30 @@ jobs:
name: screenshots-${{ inputs.issue || github.event.issue.id }}
path: ${{ steps.setup.outputs.application-path }}/**/cypress/screenshots
- name: Dump docker logs
if: always()
if: success() || failure()
uses: jwalton/gh-docker-logs@v2
outputs:
yo-rc: ${{ steps.project.outputs.yo-rc }}
entities-jdl: ${{ steps.project.outputs.entities-jdl }}
application: ${{ steps.project.outputs.result }}
frontend-check: ${{ steps.frontend.outcome }}
backend-check: ${{ steps.backend.outcome }}
e2e-check: ${{ steps.e2e.outcome }}
result-comment:
runs-on: ubuntu-latest
needs: application
if: always()
permissions:
issues: write
steps:
- uses: mshick/[email protected]
with:
issue: ${{ inputs.issue || github.event.issue.id }}
message: |
JHipster has completed the [sample check](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`.yo-rc.json`: ${{ needs.application.outputs.yo-rc }}
Entities JDL: ${{ needs.application.outputs.entities-jdl }}
Application: ${{ needs.application.outputs.application }}
Frontend check: ${{ needs.application.outputs.frontend-check }}
Backend check: ${{ needs.application.outputs.backend-check }}
E2E check: ${{ needs.application.outputs.e2e-check }}
40 changes: 39 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"yeoman-generator": "6.0.0-rc.4"
},
"devDependencies": {
"@actions/core": "1.10.0",
"@node-loaders/esbuildx": "1.2.0",
"@types/chai": "4.3.5",
"@types/glob": "npm:[email protected]",
Expand Down

0 comments on commit 20fd611

Please sign in to comment.