Skip to content

Commit

Permalink
Merge pull request #15183 from mshima/setup_action
Browse files Browse the repository at this point in the history
Implement setup GitHub action
  • Loading branch information
pascalgrimaud authored Jun 6, 2021
2 parents 0e4a6e0 + 32adc0e commit 8c407f2
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 391 deletions.
154 changes: 154 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#
# 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: 'Install jhipster-bom and generator-jhipster'
description: 'Install JHipster using test-integration scripts'
inputs:
application-path:
description: 'Application path'
required: false
default: ${{ github.workspace }}/app
application-sample:
description: 'Application sample'
required: false
default: jdl
jdl-sample:
description: 'JDL application sample'
required: false
default: ''
entities-sample:
description: 'Entities sample'
required: false
default: none
jdl-entities-sample:
description: 'JDL entities sample'
required: false
default: ''
application-environment:
description: 'Application environment'
required: false
default: prod
application-packaging:
description: 'Application packaging'
required: false
default: jar
enable-testcontainers:
description: 'Enable test containers'
required: false
default: 'true'
generator-jhipster-directory:
description: 'JHipster Generator path'
required: false
default: ${{ github.workspace }}/generator-jhipster
generator-jhipster-repository:
description: 'JHipster Generator repository'
required: false
default: https://github.com/jhipster/generator-jhipster.git
generator-jhipster-branch:
description: 'JHipster Generator branch'
required: false
default: main
jhipster-bom-repository:
description: 'JHipster BOM repository'
required: false
default: https://github.com/jhipster/jhipster-bom.git
jhipster-bom-branch:
description: 'JHipster BOM branch'
required: false
default: main
jhipster-bom-directory:
description: 'JHipster BOM path'
required: false
default: ${{ github.workspace }}/jhipster-bom
outputs:
java-version:
description: 'Java version'
value: ${{ steps.variables.outputs.java-version }}
node-version:
description: 'Node version'
value: ${{ steps.variables.outputs.node-version }}
npm-version:
description: 'NPM version'
value: ${{ steps.variables.outputs.npm-version }}
application-path:
description: 'Application path'
value: ${{ steps.variables.outputs.application-path }}
date:
description: 'Current date'
value: ${{ steps.variables.outputs.date }}
runs:
using: 'composite'
steps:
- name: 'ENV: setup variables'
id: variables
run: |
JHI_HOME="${{ inputs.generator-jhipster-directory }}"
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_LIB_REPO=${{inputs.jhipster-bom-repository}}" >> $GITHUB_ENV
echo "JHI_LIB_BRANCH=${{inputs.jhipster-bom-branch}}" >> $GITHUB_ENV
echo "JHI_LIB_HOME=${{inputs.jhipster-bom-directory}}" >> $GITHUB_ENV
echo "JHI_GEN_REPO=${{inputs.generator-jhipster-repository}}" >> $GITHUB_ENV
echo "JHI_GEN_BRANCH=${{inputs.generator-jhipster-branch}}" >> $GITHUB_ENV
echo "JHI_FOLDER_APP=${{inputs.application-path}}" >> $GITHUB_ENV
echo "JHI_JDL_APP=${{ inputs.jdl-sample }}" >> $GITHUB_ENV
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_PROFILE=${{inputs.application-environment}}" >> $GITHUB_ENV
test ${{inputs.application-packaging}} != war || echo "JHI_WAR=1" >> $GITHUB_ENV
test ${{inputs.enable-testcontainers}} != true || echo "JHI_TESTCONTAINERS=true" >> $GITHUB_ENV
test ${{inputs.enable-testcontainers}} != true || echo "SPRING_PROFILES_ACTIVE=testcontainers" >> $GITHUB_ENV
echo "JHI_GENERATE_SKIP_CONFIG=1" >> $GITHUB_ENV
echo "JHI_DISABLE_WEBPACK_LOGS=true" >> $GITHUB_ENV
echo "JHI_GITHUB_CI=true" >> $GITHUB_ENV
echo "JHI_E2E_HEADLESS=true" >> $GITHUB_ENV
echo "JHI_RUN_APP=1" >> $GITHUB_ENV
echo "JHI_E2E=1" >> $GITHUB_ENV
echo "FORCE_COLOR=1" >> $GITHUB_ENV
echo "SPRING_OUTPUT_ANSI_ENABLED=ALWAYS" >> $GITHUB_ENV
echo "SPRING_JPA_SHOW_SQL=false" >> $GITHUB_ENV
echo "NG_CLI_ANALYTICS=ci" >> $GITHUB_ENV
# https://github.com/actions/virtual-environments/issues/1499#issuecomment-689467080
echo "MAVEN_OPTS=-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120" >> $GITHUB_ENV
echo "::set-output name=application-path::${{inputs.application-path}}"
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
echo "::set-output name=java-version::$JHI_JDK"
echo "::set-output name=node-version::$JHI_NODE_VERSION"
echo "::set-output name=npm-version::$JHI_NPM_VERSION"
echo "Variables added to environment"
cat $GITHUB_ENV
echo "=============================="
shell: bash
- name: 'ENV: display variables'
run: $JHI_SCRIPTS/01-display-configuration.sh
shell: bash
- name: 'SETUP: Create required structure'
run: mkdir -p $JHI_FOLDER_APP
shell: bash
86 changes: 29 additions & 57 deletions .github/workflows/angular.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,6 @@ on:
- 'package*.json'
- 'generators/*client/templates/react/**'
- 'generators/*client/templates/vue/**'
env:
JHI_RUN_APP: 1
JHI_JDK: 11
JHI_LIB_REPO: https://github.com/jhipster/jhipster-bom.git
JHI_LIB_BRANCH: main
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: main
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
JHI_E2E_HEADLESS: true
JHI_HOME: ${{ github.workspace }}/generator-jhipster
JHI_SCRIPTS: ${{ github.workspace }}/generator-jhipster/test-integration/scripts
JHI_FOLDER_APP: ${{ github.workspace }}/app
NG_CLI_ANALYTICS: 'false'
JHI_GITHUB_CI: true
FORCE_COLOR: 1
# https://github.com/actions/virtual-environments/issues/1499#issuecomment-689467080
MAVEN_OPTS: >-
-Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
jobs:
applications:
name: ${{ matrix.app-type }}
Expand All @@ -82,7 +60,6 @@ jobs:
strategy:
fail-fast: false
matrix:
node_version: [14.16.0]
os: [ubuntu-20.04]
cache: [angular]
app-type:
Expand Down Expand Up @@ -167,15 +144,6 @@ jobs:
war: 1
e2e: 1
testcontainers: 0
env:
JHI_GENERATE_SKIP_CONFIG: 1
JHI_ENTITY: ${{ matrix.entity }}
JHI_JDL_ENTITY: ${{ matrix.jdl-entity }}
JHI_APP: ${{ matrix.jhi-app-type || matrix.app-type }}
JHI_PROFILE: ${{ matrix.environment }}
JHI_WAR: ${{ matrix.war }}
JHI_E2E: ${{ matrix.e2e }}
SPRING_PROFILES_ACTIVE: ${{ fromJson('["", "testcontainers"]')[matrix.testcontainers] }}
steps:
#----------------------------------------------------------------------
# Install all tools and check configuration
Expand All @@ -185,53 +153,53 @@ jobs:
with:
path: generator-jhipster
fetch-depth: 2
- name: 'SETUP: Create required structure'
run: |
mkdir app
mkdir -p base/generator-jhipster
mkdir -p base/app
working-directory: ${{ github.workspace }}
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
with:
entities-sample: ${{ matrix.entity }}
jdl-entities-sample: ${{ matrix.jdl-entity }}
application-sample: ${{ matrix.jhi-app-type || matrix.app-type }}
application-environment: ${{ matrix.environment }}
application-packaging: ${{ (matrix.war == 1 && 'war') || 'jar' }}
enable-testcontainers: ${{ matrix.testcontainers == 1 }}
- uses: actions/setup-node@v2.1.5
with:
node-version: ${{ matrix.node_version }}
node-version: ${{ steps.setup.outputs.node-version }}
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11.x'
- name: 'SETUP: Get date'
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
java-version: ${{ steps.setup.outputs.java-version }}
- name: 'SETUP: load npm cache'
uses: actions/cache@v2.1.6
with:
path: |
~/.npm
~/.cache/Cypress/
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ matrix.cache }}-${{ hashFiles('generator-jhipster/package-lock.json', 'generator-jhipster/**/package.json') }}
key: ${{ runner.os }}-node-${{ steps.setup.outputs.date }}-${{ matrix.cache }}-${{ hashFiles('generator-jhipster/package-lock.json', 'generator-jhipster/**/package.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ matrix.cache }}-
${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-node-${{ steps.get-date.outputs.date }}
${{ runner.os }}-node-${{ steps.setup.outputs.date }}-${{ matrix.cache }}-
${{ runner.os }}-node-${{ steps.setup.outputs.date }}-
${{ runner.os }}-node-${{ steps.setup.outputs.date }}
- name: 'SETUP: load maven cache'
uses: actions/cache@v2.1.6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ steps.get-date.outputs.date }}-${{ hashFiles('generator-jhipster/**/pom.xml.ejs') }}
key: ${{ runner.os }}-maven-${{ steps.setup.outputs.date }}-${{ hashFiles('generator-jhipster/**/pom.xml.ejs') }}
restore-keys: |
${{ runner.os }}-maven-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-maven-${{ steps.get-date.outputs.date }}
${{ runner.os }}-maven-${{ steps.setup.outputs.date }}-
${{ runner.os }}-maven-${{ steps.setup.outputs.date }}
- name: 'SETUP: load gradle cache'
if: contains(matrix.app-type, 'gradle')
uses: actions/cache@v2.1.6
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }}-${{ hashFiles('generator-jhipster/**/build.gradle.ejs') }}
key: ${{ runner.os }}-gradle-${{ steps.setup.outputs.date }}-${{ hashFiles('generator-jhipster/**/build.gradle.ejs') }}
restore-keys: |
${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }}
${{ runner.os }}-gradle-${{ steps.setup.outputs.date }}-
${{ runner.os }}-gradle-${{ steps.setup.outputs.date }}
- name: 'ENV: display variables'
run: $JHI_SCRIPTS/01-display-configuration.sh
- name: 'TOOLS: configure tools installed by the system'
Expand All @@ -254,6 +222,11 @@ jobs:
#----------------------------------------------------------------------
# Detect changes against base commit
#----------------------------------------------------------------------
- name: 'GENERATION: Create required structure'
run: |
mkdir -p base/generator-jhipster
mkdir -p base/app
working-directory: ${{ github.workspace }}
- name: 'MERGE: Install base generator-jhipster'
continue-on-error: true
id: base-checkout
Expand All @@ -273,7 +246,6 @@ jobs:
working-directory: ${{ github.workspace }}/base/app
run: |
$JHI_SCRIPTS/11-generate-config.sh
# 11-generate-entities.sh removes current dir, we need to switch to the new one
cd ../app
$JHI_SCRIPTS/12-generate-project.sh --skip-install --skip-git
env:
Expand Down Expand Up @@ -330,13 +302,13 @@ jobs:
if: always() && steps.backend.outcome == 'failure'
with:
name: log-${{ matrix.app-type }}
path: ${{ github.workspace }}/app/build/test-results/**/*.xml
path: ${{ steps.setup.outputs.application-path }}/*/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v2
if: always() && steps.e2e.outcome == 'failure'
with:
name: screenshots-${{ matrix.app-type }}
path: ${{ github.workspace }}/app/*/cypress/screenshots
path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots
- name: 'ANALYSIS: Sonar analysis'
if: steps.tests-should-be-skipped.outputs.skip-tests != 'true' && matrix.sonar-analyse == 1
run: $JHI_SCRIPTS/25-sonar-analyze.sh
Expand Down
Loading

0 comments on commit 8c407f2

Please sign in to comment.