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 custom cli to actions for blueprints. #16295

Merged
merged 3 commits into from
Sep 26, 2021
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
13 changes: 8 additions & 5 deletions .github/actions/compare-base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ runs:
steps:
- name: 'MERGE: Install base generator-jhipster'
run: |
mkdir -p ${{ github.workspace }}/base/generator-jhipster
cd ${{ github.workspace }}/base/generator-jhipster
git clone "$JHI_HOME" .
if [[ "$JHI_CLI_PACKAGE" == "" ]]; then
JHI_CLI_PACKAGE=generator-jhipster
fi
mkdir -p "${{ github.workspace }}/base/$JHI_CLI_PACKAGE"
cd "${{ github.workspace }}/base/$JHI_CLI_PACKAGE"
git clone "${{ github.workspace }}/$JHI_CLI_PACKAGE" .
git checkout @~1
git log
npm uninstall -g generator-jhipster
npm uninstall -g $JHI_CLI_PACKAGE
npm install
npm install -g .
shell: bash
Expand All @@ -64,7 +67,7 @@ runs:
- name: 'MERGE: merge base project'
id: base
run: |
$JHI_SCRIPTS/12-generate-project.sh --skip-install --skip-git ${{ inputs.extra-args }}
$JHI_SCRIPTS/12-generate-project.sh --skip-jhipster-dependencies --skip-install --skip-git ${{ inputs.extra-args }}
echo "::set-output name=application-path::${{inputs.application-path}}"
env:
JHI_FOLDER_APP: ${{ inputs.application-path }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/compare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
application-path:
description: 'Application path'
required: false
default: ${{ github.workspace }}/app
default: ${{ github.workspace }}/base/app
outputs:
equals:
description: "Generated source didn't changed"
Expand Down
38 changes: 38 additions & 0 deletions .github/actions/generate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright 2013-2021 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: 'Generate'
description: 'Generate application for test-integration scripts'
inputs:
extra-args:
description: 'Extra arguments'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: 'GENERATION: install executable'
run: $JHI_SCRIPTS/10-install-jhipster.sh
shell: bash
- name: 'GENERATION: generate config'
run: $JHI_SCRIPTS/11-generate-config.sh
shell: bash
- name: 'GENERATION: project'
run: $JHI_SCRIPTS/12-generate-project.sh --skip-jhipster-dependencies ${{ inputs.extra-args }}
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ inputs:
description: 'JHipster BOM path'
required: false
default: ${{ github.workspace }}/jhipster-bom
package-with-executable:
description: 'Package which contains the executable'
required: false
default: ''
executable:
description: 'Executable'
required: false
default: jhipster
outputs:
java-version:
description: 'Java version'
Expand All @@ -99,10 +107,14 @@ runs:
id: variables
run: |
JHI_HOME="${{ inputs.generator-jhipster-directory }}"
JHI_WORKSPACE="${{ github.workspace }}"
JHI_CLI_PACKAGE="${{inputs.package-with-executable}}"
source "$JHI_HOME/test-integration/scripts/00-init-env.sh"

echo "JHI_HOME=$JHI_HOME" >> $GITHUB_ENV
echo "JHI_SCRIPTS=$JHI_SCRIPTS" >> $GITHUB_ENV
echo "JHI_CLI_PACKAGE_PATH=$JHI_CLI_PACKAGE_PATH" >> $GITHUB_ENV
echo "JHI_CLI_PACKAGE=$JHI_CLI_PACKAGE" >> $GITHUB_ENV

echo "JHI_LIB_REPO=${{inputs.jhipster-bom-repository}}" >> $GITHUB_ENV
echo "JHI_LIB_BRANCH=${{inputs.jhipster-bom-branch}}" >> $GITHUB_ENV
Expand All @@ -115,6 +127,7 @@ runs:
echo "JHI_APP=${{inputs.application-sample}}" >> $GITHUB_ENV
echo "JHI_ENTITY=${{inputs.entities-sample}}" >> $GITHUB_ENV
echo "JHI_JDL_ENTITY=${{inputs.jdl-entities-sample}}" >> $GITHUB_ENV
echo "JHI_CLI=${{inputs.executable}}" >> $GITHUB_ENV

echo "JHI_PROFILE=${{inputs.application-environment}}" >> $GITHUB_ENV
test ${{inputs.application-packaging}} != war || echo "JHI_WAR=1" >> $GITHUB_ENV
Expand Down Expand Up @@ -152,3 +165,6 @@ runs:
- name: 'SETUP: Create required structure'
run: mkdir -p $JHI_FOLDER_APP
shell: bash
- name: 'SETUP: configure git'
run: $JHI_SCRIPTS/04-git-config.sh
shell: bash
13 changes: 13 additions & 0 deletions test-integration/scripts/00-init-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ if [[ "$JHI_HOME" == "" ]]; then
JHI_HOME="$JHI_DETECTED_DIR"
fi

# folder for executable package (blueprints or generator-jhipster)
if [[ "$JHI_CLI_PACKAGE_PATH" == "" ]]; then
if [[ "$JHI_CLI_PACKAGE" != "" && "$JHI_WORKSPACE" != "" ]]; then
JHI_CLI_PACKAGE_PATH="$JHI_WORKSPACE/$JHI_CLI_PACKAGE"
else
JHI_CLI_PACKAGE_PATH="$JHI_HOME"
fi
fi

# folder where the repo is cloned
if [[ "$JHI_REPO_PATH" == "" ]]; then
JHI_REPO_PATH=$(init_var "$BUILD_REPOSITORY_LOCALPATH" "$GITHUB_WORKSPACE")
Expand Down Expand Up @@ -78,6 +87,10 @@ if [[ "$JHI_JDK" == "11" && "$JHI_GITHUB_CI" != "true" ]]; then
JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
fi

if [[ "$JHI_CLI" == "" ]]; then
JHI_CLI=jhipster
fi

# node version
JHI_NODE_VERSION=$(grep -o "NODE_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.js | cut -f2 -d "'")

Expand Down
6 changes: 3 additions & 3 deletions test-integration/scripts/10-install-jhipster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ fi
#-------------------------------------------------------------------------------
cd "$HOME"
if [[ "$JHI_REPO" == *"/generator-jhipster" || "$JHI_GEN_BRANCH" == "local" ]]; then
echo "*** generator-jhipster: use local version at JHI_HOME=$JHI_HOME"
echo "*** generator-jhipster or executable: use local version at JHI_CLI_PACKAGE_PATH=$JHI_CLI_PACKAGE_PATH"

cd "$JHI_HOME"
cd "$JHI_CLI_PACKAGE_PATH"
git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
npm ci
npm install -g "$JHI_HOME"
npm install -g "$JHI_CLI_PACKAGE_PATH"

elif [[ "$JHI_GEN_BRANCH" == "release" ]]; then
echo "*** generator-jhipster: use release version"
Expand Down
6 changes: 3 additions & 3 deletions test-integration/scripts/12-generate-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [[ "$JHI_ENTITY" == "jdl" ]]; then
cp -f "$JHI_SAMPLES"/"$JHI_APP"/*.jdl "$JHI_FOLDER_APP"/
cd "$JHI_FOLDER_APP"
ls -la "$JHI_FOLDER_APP"/
jhipster import-jdl *.jdl --no-insight $@
eval "$JHI_CLI import-jdl *.jdl --no-insight $@"

elif [[ "$JHI_APP" == "jdl" ]]; then
#-------------------------------------------------------------------------------
Expand All @@ -40,7 +40,7 @@ elif [[ "$JHI_APP" == "jdl" ]]; then
ls -la "$JHI_FOLDER_APP"/

cd "$JHI_FOLDER_APP"
jhipster import-jdl *.jdl --no-insight $@
eval "$JHI_CLI import-jdl *.jdl --no-insight $@"

else
#-------------------------------------------------------------------------------
Expand All @@ -55,7 +55,7 @@ else
fi

cd "$JHI_FOLDER_APP"
jhipster --force --no-insight --skip-checks --with-entities $@
eval "$JHI_CLI --force --no-insight --skip-checks --with-entities $@"

fi

Expand Down