Skip to content

Commit

Permalink
Merge pull request #26367 from mshima/blueprints
Browse files Browse the repository at this point in the history
improvements to blueprints
  • Loading branch information
DanielFran authored Jun 5, 2024
2 parents 0bf5218 + 08baa8e commit b86cba7
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 9 deletions.
4 changes: 1 addition & 3 deletions .blueprint/from-issue/generator.mts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { join } from 'node:path';

import BaseGenerator from '../../generators/base/index.js';
import { getGithubIssue, setGithubTaskOutput, prepareSample, parseIssue } from '../../testing/index.js';
import { getGithubIssue, setGithubTaskOutput, prepareSample } from '../../testing/index.js';
import { promptSamplesFolder } from '../support.mjs';
import { GENERATOR_APP, GENERATOR_JDL, GENERATOR_WORKSPACES } from '../../generators/generator-list.js';
import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.js';
import { extractDataFromInfo, type InfoData } from '../../generators/info/support/index.js';
import EnvironmentBuilder from '../../cli/environment-builder.mjs';
import { mutateData } from '../../generators/base/support/config.js';

const YO_RC_OUTPUT = 'yo-rc';
const ENTITIES_JDL_OUTPUT = 'entities-jdl';
Expand Down
2 changes: 2 additions & 0 deletions generators/generate-blueprint/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const files = {
'.blueprint/github-build-matrix/build-matrix.mjs',
'.blueprint/github-build-matrix/generator.mjs',
'.blueprint/github-build-matrix/index.mjs',
'.github/workflows/build-cache.yml',
'.github/workflows/samples.yml',
],
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { existsSync, appendFileSync } from 'node:fs';
import os from 'node:os';
import BaseGenerator from 'generator-jhipster/generators/base';
import { setGithubTaskOutput } from 'generator-jhipster/testing';
import { buildMatrix } from './build-matrix.mjs';

export default class extends BaseGenerator {
Expand All @@ -12,12 +13,7 @@ export default class extends BaseGenerator {
return this.asWritingTaskGroup({
async buildMatrix() {
const matrix = await buildMatrix(this.templatePath('../../generate-sample/templates/samples'));
const matrixoutput = `matrix<<EOF${os.EOL}${JSON.stringify(matrix)}${os.EOL}EOF${os.EOL}`;
const filePath = process.env['GITHUB_OUTPUT'];
console.log(matrixoutput);
if (filePath && existsSync(filePath)) {
appendFileSync(filePath, matrixoutput, { encoding: 'utf8' });
}
setGithubTaskOutput('matrix', matrix);
},
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build-cache
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
jobs:
build-cache:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}/app
steps:
- uses: actions/checkout@v4
with:
path: generator-jhipster-<%= baseName %>
- uses: jhipster/actions/setup-runner@v0
with:
node-version: 20
binary-dir: ${{ github.workspace }}/generator-jhipster-<%= baseName %>/cli/
- uses: jhipster/actions/cache-npm-dependencies@v0
with:
generator-path: generator-jhipster-<%= baseName %>
if: always()
- run: cli.cjs generate-sample --all
continue-on-error: true
- run: npm run backend:build-cache --workspaces
continue-on-error: true
- uses: jhipster/actions/save-cache@v0
if: always()
with:
key: ${{ github.run_id }}
npm: true
maven: true
gradle: true
- uses: jhipster/actions/restore-cache@v0
with:
npm: true
maven: true
gradle: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Verify Sample Projects
on:
push:
branches:
- 'main'
- '**maintenance'
paths-ignore:
- 'package*.json'
pull_request:
branches:
- '*'
permissions:
contents: read
jobs:
build-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: <%- nodeVersion.split('.', 2)[0] %>
- id: build
run: |
npm install
./cli/cli.cjs github-build-matrix
samples:
name: ${{ matrix.sample-name }}
runs-on: ubuntu-latest
needs: build-matrix
defaults:
run:
working-directory: ${{ github.workspace }}/app
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
with:
path: generator-jhipster-<%= baseName %>
fetch-depth: 2
- uses: jhipster/actions/setup-runner@v0
with:
java-version: ${{ matrix.java-version }}
node-version: ${{ matrix.node-version }}
maven-cache: true
gradle-cache: true
binary-dir: ${{ github.workspace }}/generator-jhipster-<%= baseName %>/cli/
- name: 'Install blueprint'
run: npm install
working-directory: ${{ github.workspace }}/generator-jhipster-<%= baseName %>
- name: 'Generate Project'
run: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies --force
- 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-<%= baseName %>
cmd: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies --force --skip-install
- run: npm run ci:backend:test
if: steps.compare.outputs.equals != 'true'
id: backend
- run: npm run ci:frontend:test --if-present
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:package
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:prepare
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:run --if-present
if: steps.compare.outputs.equals != 'true'
id: e2e
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v4
if: always() && steps.backend.outcome == 'failure'
with:
name: log-${{ matrix.sample-name }}
path: |
${{ github.workspace }}/app/build/test-results/**/*.xml
${{ github.workspace }}/app/target/surefire-reports
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v4
if: always() && steps.e2e.outcome == 'failure'
with:
name: screenshots-${{ matrix.sample-name }}
path: ${{ github.workspace }}/app/**/cypress/screenshots
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
check-samples:
permissions:
contents: none
runs-on: ubuntu-latest
needs: [samples]
if: always()
steps:
- run: |
echo '${{ toJSON(needs) }}'
if [ 'skipped' == '${{ needs.samples.result }}' ] || [ 'success' == '${{ needs.samples.result }}' ] || [ 'closed' == '${{ github.event.action }}' ]; then
exit 0
fi
exit 1

0 comments on commit b86cba7

Please sign in to comment.