Skip to content

Commit

Permalink
Merge pull request #24185 from mshima/skip_ci-shared-actions
Browse files Browse the repository at this point in the history
Use shared actions for caching
  • Loading branch information
DanielFran authored Nov 11, 2023
2 parents c1231c0 + b30b384 commit 9d6b406
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 277 deletions.
10 changes: 10 additions & 0 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { extname } from 'path';
import BaseGenerator from '../../generators/base/index.mjs';
import command from './command.mjs';
import { generateSample } from './support/generate-sample.js';
Expand Down Expand Up @@ -30,7 +31,16 @@ export default class extends BaseGenerator {

get [BaseGenerator.END]() {
return this.asEndTaskGroup({
async generateJdlSample() {
if (extname(this.sampleName) !== '.jdl') return;

await this.composeWithJHipster(GENERATOR_JDL, {
generatorArgs: [this.templatePath('samples', this.sampleName)],
});
},
async generateSample() {
if (extname(this.sampleName) === '.jdl') return;

const sample = await generateSample(this.sampleName, {
destSamplesFolder: this._globalConfig.get('samplesFolder'),
destProjectFolder: this.projectFolder ?? this.global ? undefined : process.cwd(),
Expand Down
47 changes: 47 additions & 0 deletions .github/actions/build-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright 2013-2023 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: Build cache
description: Build cache
runs:
using: composite
steps:
- uses: jhipster/actions/cache-npm-dependencies@v0
if: always()
with:
generator-path: generator-jhipster
generator-jhipster-path: generator-jhipster
- uses: ./generator-jhipster/.github/actions/cache-java-dependencies
if: always()
with:
jhipster-bom-path: jhipster-bom
generator-jhipster-path: generator-jhipster
- 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
if: always()
with:
npm: true
maven: true
gradle: true
94 changes: 94 additions & 0 deletions .github/actions/cache-java-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#
# Copyright 2013-2023 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: Cache java dependencies
description: Cache java dependencies
inputs:
generator-jhipster-path:
description: JHipster generator folder relative to workspace.
required: false
jhipster-bom-path:
description: JHipster bom folder relative to workspace.
required: false
runs:
using: composite
steps:
- name: 'mvn: install JHipster'
run: |
echo "::group::jhipster-bom"
./mvnw dependency:go-offline --ntp
echo "::endgroup::"
if: always() && inputs.jhipster-bom-path
shell: bash
working-directory: ${{ github.workspace }}/${{ inputs.jhipster-bom-path }}
- run: rm -rf tmp; mkdir tmp
shell: bash
working-directory: ${{ github.workspace }}
- name: 'mvn(imperative): cache dependencies'
run: |
echo "::group::maven(imperative)"
${{ github.workspace }}/${{ inputs.generator-jhipster-path }}/bin/jhipster.cjs generate-sample cache.jdl --skip-install --workspaces
npm run backend:build-cache -- --ntp || true
cd app1
./npmw -v
echo "::endgroup::"
shell: bash
if: always()
working-directory: ${{ github.workspace }}/tmp
- run: rm -rf tmp; mkdir tmp
shell: bash
working-directory: ${{ github.workspace }}
- name: 'mvn(reactive): cache dependencies'
run: |
echo "::group::maven(reactive)"
${{ github.workspace }}/${{ inputs.generator-jhipster-path }}/bin/jhipster.cjs generate-sample cache.jdl --skip-install --skip-install --workspaces --reactive
npm install --force
npm run backend:build-cache -- --ntp || true
echo "::endgroup::"
shell: bash
if: always()
working-directory: ${{ github.workspace }}/tmp
- run: rm -rf tmp; mkdir tmp
shell: bash
working-directory: ${{ github.workspace }}
- name: 'gradle(imperative): cache dependencies'
run: |
echo "::group::gradle(imperative)"
${{ github.workspace }}/${{ inputs.generator-jhipster-path }}/bin/jhipster.cjs generate-sample cache.jdl --skip-install --skip-install --workspaces --build gradle
npm install --force
npm run backend:build-cache || true
cd app1
./npmw -v
echo "::endgroup::"
shell: bash
if: always()
working-directory: ${{ github.workspace }}/tmp
- run: rm -rf tmp; mkdir tmp
shell: bash
working-directory: ${{ github.workspace }}
- name: 'gradle(reactive): cache dependencies'
run: |
echo "::group::gradle(reactive)"
${{ github.workspace }}/${{ inputs.generator-jhipster-path }}/bin/jhipster.cjs generate-sample cache.jdl --skip-install --skip-install --workspaces --build gradle --reactive
npm install --force
npm run backend:build-cache || true
echo "::endgroup::"
shell: bash
if: always()
working-directory: ${{ github.workspace }}/tmp
31 changes: 31 additions & 0 deletions .github/actions/setup-default-node-java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright 2013-2023 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: Setup default Node and Java
description: Setup default Node and Java
runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
39 changes: 39 additions & 0 deletions .github/actions/setup-generator-jhipster-jit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright 2013-2023 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: Setup generator-jhipster jit
description: Make generator-jhipster jit executable available globally as jh
inputs:
generator-path:
description: Generator folder relative to workspace, git checkout, npm remove, install, and link will be executed in the folder.
required: true
runs:
using: composite
steps:
- name: Link executable
shell: bash
run: |
set -x
npm install
mkdir -p "${HOME}/.bin"
echo "${HOME}/.bin" >> $GITHUB_PATH
ln -s "${{ github.workspace }}/${{ inputs.generator-path }}/bin/jhipster.cjs" "${HOME}/.bin/jh"
ls -la "${HOME}/.bin/jh"
"${{ github.workspace }}/${{ inputs.generator-path }}/bin/jhipster.cjs" --install-path
working-directory: ${{ github.workspace }}/${{ inputs.generator-path }}
24 changes: 4 additions & 20 deletions .github/workflows/angular.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,11 @@ jobs:
with:
distribution: 'temurin'
java-version: ${{ steps.setup.outputs.java-version }}
- name: 'SETUP: load npm cache'
uses: actions/cache/restore@v3
- uses: jhipster/actions/restore-cache@v0
with:
path: |
~/.npm
~/.cache/Cypress/
key: ${{ runner.os }}-node-

- name: 'SETUP: load maven cache'
uses: actions/cache/restore@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-
- name: 'SETUP: load gradle cache'
if: matrix.workspaces == 'true' || matrix.gradle == 1 || contains(matrix.name, 'gradle')
uses: actions/cache/restore@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-
npm: true
maven: true
gradle: ${{ matrix.workspaces == 'true' || matrix.gradle == 1 || contains(matrix.name, 'gradle') }}
- name: 'TOOLS: configure tools installed by the system'
run: $JHI_SCRIPTS/03-system.sh
- name: 'TOOLS: configure git'
Expand Down
Loading

0 comments on commit 9d6b406

Please sign in to comment.