diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000000..733ddac4b33 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -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 diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index 02df1477de5..99a2d8966d0 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -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 }} @@ -82,7 +60,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] app-type: @@ -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 @@ -185,42 +153,42 @@ 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 @@ -228,10 +196,10 @@ jobs: 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' @@ -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 @@ -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: @@ -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 diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 06516ebb9de..aa33eaed351 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -51,23 +51,22 @@ jobs: steps: - name: 'SETUP: Checkout generator-jhipster' uses: actions/checkout@v2 + - name: 'SETUP: environment' + id: setup + uses: ./.github/actions/setup - uses: actions/setup-node@v2.1.5 with: - node-version: 14 - - name: 'SETUP: Get date for cache key' - id: get-date - run: | - echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" + node-version: ${{ steps.setup.outputs.node-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 }} + key: ${{ runner.os }}-node-${{ steps.setup.outputs.date }} - name: 'Install generator-jhipster npm version' - run: npm install -g npm@$(node -e "console.log(require('./generators/generator-constants').NPM_VERSION);") + run: npm install -g npm@${{ steps.setup.outputs.npm-version }} - name: Cache generator-jhipster node_modules run: npm ci continue-on-error: true @@ -84,7 +83,7 @@ jobs: working-directory: generators/client/templates/angular - name: Cache client common node_modules run: | - npm install + npm install --legacy-peer-deps npx cypress install continue-on-error: true working-directory: generators/client/templates/common @@ -110,36 +109,31 @@ jobs: uses: actions/checkout@v2 with: path: generator-jhipster - - name: 'SETUP: Create required structure' - run: | - mkdir app - working-directory: ${{ github.workspace }} + - name: 'SETUP: environment' + id: setup + uses: ./generator-jhipster/.github/actions/setup - uses: actions/setup-node@v2.1.5 with: - node-version: 14 + node-version: ${{ steps.setup.outputs.node-version }} - uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: '11.x' - - name: 'SETUP: Get date for cache key' - 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 }}-cache - restore-keys: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }} + key: ${{ runner.os }}-node-${{ steps.setup.outputs.date }}-cache + restore-keys: ${{ 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 }} + key: ${{ runner.os }}-maven-${{ steps.setup.outputs.date }} - name: 'Install generator-jhipster npm version' - run: npm install -g npm@$(node -e "console.log(require('./generators/generator-constants').NPM_VERSION);") + run: npm install -g npm@${{ steps.setup.outputs.npm-version }} - name: 'GENERATION: install JHipster' run: $JHI_SCRIPTS/10-install-jhipster.sh @@ -171,43 +165,38 @@ jobs: uses: actions/checkout@v2 with: path: generator-jhipster - - name: 'SETUP: Create required structure' - run: | - mkdir app - working-directory: ${{ github.workspace }} + - name: 'SETUP: environment' + id: setup + uses: ./generator-jhipster/.github/actions/setup - uses: actions/setup-node@v2.1.5 with: - node-version: 14 + node-version: ${{ steps.setup.outputs.node-version }} - uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: '11.x' - - name: 'SETUP: Get date for cache key' - 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 }}-cache - restore-keys: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }} + key: ${{ runner.os }}-node-${{ steps.setup.outputs.date }}-cache + restore-keys: ${{ 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 }} + key: ${{ runner.os }}-maven-${{ steps.setup.outputs.date }} - name: 'SETUP: load gradle cache' uses: actions/cache@v2.1.6 with: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }} + key: ${{ runner.os }}-gradle-${{ steps.setup.outputs.date }} - name: 'Install generator-jhipster npm version' - run: npm install -g npm@$(node -e "console.log(require('./generators/generator-constants').NPM_VERSION);") + run: npm install -g npm@${{ steps.setup.outputs.npm-version }} - name: 'GENERATION: install JHipster' run: $JHI_SCRIPTS/10-install-jhipster.sh diff --git a/.github/workflows/incremental-changelog.yml b/.github/workflows/incremental-changelog.yml index ac30cf17342..d7c4538e864 100644 --- a/.github/workflows/incremental-changelog.yml +++ b/.github/workflows/incremental-changelog.yml @@ -38,28 +38,6 @@ on: - 'generators/entity/**' - 'generators/database-changelog/**' - 'generators/database-changelog-liquibase/**' -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 }} @@ -79,7 +57,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] app-type: @@ -88,17 +65,9 @@ jobs: - app-type: liquibase-jdl-rename-field entity: jdl liquibase: jdl - profile: prod + environment: prod war: 0 e2e: 1 - env: - JHI_ENTITY: ${{ matrix.entity }} - JHI_APP: ${{ matrix.app-type }} - JHI_LIQUIBASE: ${{ matrix.liquibase }} - JHI_PROFILE: ${{ matrix.profile }} - JHI_WAR: ${{ matrix.war }} - JHI_E2E: ${{ matrix.e2e }} - JHI_TESTCONTAINERS: ${{ matrix.testcontainers }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -107,40 +76,41 @@ jobs: uses: actions/checkout@v2 with: path: generator-jhipster - - name: 'SETUP: Create required structure' - run: | - mkdir app - working-directory: ${{ github.workspace }} + - name: 'SETUP: environment' + id: setup + uses: ./generator-jhipster/.github/actions/setup + with: + application-sample: ${{ matrix.app-type }} + entities-sample: ${{ matrix.entity }} + 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 @@ -148,10 +118,10 @@ jobs: 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' @@ -163,8 +133,8 @@ jobs: #---------------------------------------------------------------------- - name: 'GENERATION: install JHipster' run: $JHI_SCRIPTS/10-install-jhipster.sh - - name: 'GENERATION: entities' - run: $JHI_SCRIPTS/11-generate-entities.sh + - name: 'GENERATION: config' + run: $JHI_SCRIPTS/11-generate-config.sh - name: 'GENERATION: project' run: $JHI_SCRIPTS/12-generate-project.sh --with-entities --force --skip-jhipster-dependencies --creation-timestamp '2020-01-01' env: @@ -201,7 +171,7 @@ jobs: 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' run: $JHI_SCRIPTS/25-sonar-analyze.sh env: diff --git a/.github/workflows/jdl.yml b/.github/workflows/jdl.yml index 2995adae60f..bfe090baa37 100644 --- a/.github/workflows/jdl.yml +++ b/.github/workflows/jdl.yml @@ -33,28 +33,6 @@ on: - '*' paths-ignore: - 'package*.json' -env: - 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_JDL_SAMPLES: ${{ github.workspace }}/generator-jhipster/test-integration/jdl-samples - JHI_FOLDER_APP: ${{ github.workspace }}/app - NG_CLI_ANALYTICS: 'false' - JHI_GITHUB_CI: true - FORCE_COLOR: 1 - SPRING_PROFILES_ACTIVE: testcontainers - # 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.jdl }} @@ -73,7 +51,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] jdl: @@ -85,8 +62,6 @@ jobs: extra-args: --workspaces --monorepository # Backend is failing, disable it skip-backend-tests: 1 - env: - JHI_PROFILE: ${{ matrix.environment }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -96,42 +71,40 @@ 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: + jdl-sample: ${{ matrix.jdl }} + 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: matrix.gradle == 1 uses: actions/cache@v2.1.6 @@ -139,10 +112,10 @@ jobs: 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' @@ -151,17 +124,18 @@ jobs: run: $JHI_SCRIPTS/04-git-config.sh # Update global NPM for workspaces support - name: 'Install required NPM version' - run: npm install -g npm@$(node -e "console.log(require('${{ github.workspace }}/generator-jhipster/generators/generator-constants').NPM_VERSION);") || true + run: npm install -g npm@${{ steps.setup.outputs.npm-version }} || true #---------------------------------------------------------------------- # Install JHipster and generate project+entities #---------------------------------------------------------------------- - name: 'GENERATION: install JHipster' run: $JHI_SCRIPTS/10-install-jhipster.sh - - name: 'GENERATION: copy jdl' - run: cp $JHI_JDL_SAMPLES/${{ matrix.jdl }}/*.jdl . + - name: 'GENERATION: config' + run: $JHI_SCRIPTS/11-generate-config.sh + - name: 'GENERATION: project' + run: $JHI_SCRIPTS/12-generate-project.sh --skip-jhipster-dependencies ${{ matrix.extra-args }} - name: 'GENERATION: project' run: | - jhipster jdl *.jdl --skip-jhipster-dependencies ${{ matrix.extra-args }} git add . git commit -m "Commit workspaces" - name: 'GENERATION: replace version in generated project' @@ -171,6 +145,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 @@ -183,19 +162,18 @@ jobs: npm uninstall -g generator-jhipster npm install npm install -g . - - name: 'MERGE: copy jdl' - if: steps.base-checkout.outcome == 'success' - working-directory: ${{ github.workspace }}/base/app - run: cp $JHI_JDL_SAMPLES/${{ matrix.jdl }}/*.jdl . - - name: 'MERGE: base project' + - name: 'MERGE: merge base project' continue-on-error: true id: base-app if: steps.base-checkout.outcome == 'success' working-directory: ${{ github.workspace }}/base/app run: | + $JHI_SCRIPTS/11-generate-config.sh # docker-compose is not reproducible, so copy old config ls ${{ github.workspace }}/app/docker-compose && mkdir docker-compose && cp ${{ github.workspace }}/app/docker-compose/.yo-rc.json docker-compose || true - jhipster jdl *.jdl --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }} --skip-git + $JHI_SCRIPTS/12-generate-project.sh --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }} --skip-git + env: + JHI_FOLDER_APP: ${{ github.workspace }}/base/app - name: 'MERGE: merge diff' continue-on-error: true id: merge-is-equal @@ -249,13 +227,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: Dump docker logs on failure if: failure() uses: jwalton/gh-docker-logs@v2 diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml index 38b9214ffdc..fd0b7458df0 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -38,28 +38,6 @@ on: - 'package*.json' - 'generators/*client/templates/angular/**' - '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 }} @@ -82,7 +60,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [react] app-type: @@ -150,14 +127,6 @@ jobs: # war: 0 # e2e: 1 # testcontainers: 0 - env: - JHI_GENERATE_SKIP_CONFIG: 1 - JHI_ENTITY: ${{ matrix.entity }} - JHI_APP: ${{ 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 @@ -167,42 +136,41 @@ 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 }} + application-sample: ${{ 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 @@ -210,10 +178,10 @@ jobs: 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' @@ -236,6 +204,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 @@ -255,7 +228,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: @@ -312,13 +284,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' run: $JHI_SCRIPTS/25-sonar-analyze.sh diff --git a/.github/workflows/vue.yml b/.github/workflows/vue.yml index 963fd458d86..96ffe30e25c 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -38,28 +38,6 @@ on: - 'package*.json' - 'generators/*client/templates/angular/**' - 'generators/*client/templates/react/**' -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 }} @@ -82,7 +60,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [vue] app-type: @@ -148,14 +125,6 @@ jobs: war: 0 e2e: 1 testcontainers: 1 - env: - JHI_GENERATE_SKIP_CONFIG: 1 - JHI_ENTITY: ${{ matrix.entity }} - JHI_APP: ${{ 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 @@ -165,42 +134,41 @@ 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 }} + application-sample: ${{ 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 @@ -208,10 +176,10 @@ jobs: 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' @@ -234,6 +202,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 @@ -253,7 +226,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: @@ -310,13 +282,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' run: $JHI_SCRIPTS/25-sonar-analyze.sh diff --git a/.github/workflows/webflux.yml b/.github/workflows/webflux.yml index 611c44b25d6..92173ee5ea6 100644 --- a/.github/workflows/webflux.yml +++ b/.github/workflows/webflux.yml @@ -37,28 +37,6 @@ on: paths-ignore: - 'package*.json' - 'generators/*client/**' -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 }} @@ -84,7 +62,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] app-type: @@ -157,14 +134,6 @@ jobs: war: 0 e2e: 1 testcontainers: 0 - env: - JHI_GENERATE_SKIP_CONFIG: 1 - JHI_ENTITY: ${{ matrix.entity }} - JHI_APP: ${{ 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 @@ -174,42 +143,41 @@ 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 }} + application-sample: ${{ 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 @@ -217,10 +185,10 @@ jobs: 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' @@ -243,6 +211,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 @@ -262,7 +235,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: @@ -319,13 +291,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' run: $JHI_SCRIPTS/25-sonar-analyze.sh diff --git a/test-integration/scripts/00-init-env.sh b/test-integration/scripts/00-init-env.sh index eba7fc69e7e..aaa6b320eac 100755 --- a/test-integration/scripts/00-init-env.sh +++ b/test-integration/scripts/00-init-env.sh @@ -15,11 +15,26 @@ init_var() { } # uri of repo -JHI_REPO=$(init_var "$BUILD_REPOSITORY_URI" "$GITHUB_WORKSPACE" ) +if [[ "$JHI_REPO" == "" ]]; then + JHI_REPO=$(init_var "$BUILD_REPOSITORY_URI" "$GITHUB_WORKSPACE" ) +fi -# folder where the repo is cloned +# folder for generator-jhipster if [[ "$JHI_HOME" == "" ]]; then - JHI_HOME=$(init_var "$BUILD_REPOSITORY_LOCALPATH" "$GITHUB_WORKSPACE" "$JHI_DETECTED_DIR") + JHI_HOME="$JHI_DETECTED_DIR" +fi + +# folder where the repo is cloned +if [[ "$JHI_REPO_PATH" == "" ]]; then + JHI_REPO_PATH=$(init_var "$BUILD_REPOSITORY_LOCALPATH" "$GITHUB_WORKSPACE") +fi + +if [[ "$JHI_LIB_HOME" == "" ]]; then + if [[ "$JHI_REPO" == *"/jhipster-bom" ]]; then + JHI_LIB_HOME="$JHI_REPO_PATH" + else + JHI_LIB_HOME="$HOME"/jhipster-bom + fi fi # folder for test-integration @@ -32,6 +47,11 @@ if [[ "$JHI_SAMPLES" == "" ]]; then JHI_SAMPLES="$JHI_INTEG"/samples fi +# folder for jdls samples +if [[ "$JHI_JDL_SAMPLES" == "" ]]; then + JHI_JDL_SAMPLES="$JHI_INTEG"/jdl-samples +fi + # folder for scripts if [[ "$JHI_SCRIPTS" == "" ]]; then JHI_SCRIPTS="$JHI_INTEG"/scripts @@ -42,7 +62,18 @@ if [[ "$JHI_FOLDER_APP" == "" ]]; then JHI_FOLDER_APP="$HOME"/app fi +# jdk version +if [[ "$JHI_JDK" == "" ]]; then + JHI_JDK=$(grep -o "JAVA_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.js | cut -f2 -d "'") +fi + # set correct OpenJDK version if [[ "$JHI_JDK" == "11" && "$JHI_GITHUB_CI" != "true" ]]; then JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::") fi + +# node version +JHI_NODE_VERSION=$(grep -o "NODE_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.js | cut -f2 -d "'") + +# npm version +JHI_NPM_VERSION=$(grep -o '"npm": "[^"]*"' $JHI_HOME/generators/common/templates/package.json | cut -f4 -d '"') diff --git a/test-integration/scripts/01-display-configuration.sh b/test-integration/scripts/01-display-configuration.sh index e76e1202796..ecc9dba610f 100755 --- a/test-integration/scripts/01-display-configuration.sh +++ b/test-integration/scripts/01-display-configuration.sh @@ -25,3 +25,5 @@ echo JHI_SAMPLES="$JHI_SAMPLES" echo JHI_SCRIPTS="$JHI_SCRIPTS" echo JHI_FOLDER_APP="$JHI_FOLDER_APP" echo JAVA_HOME="$JAVA_HOME" +echo JHI_NODE_VERSION="$JHI_NODE_VERSION" +echo JHI_NPM_VERSION="$JHI_NPM_VERSION" diff --git a/test-integration/scripts/10-install-jhipster.sh b/test-integration/scripts/10-install-jhipster.sh index 6cedebecb4a..4296d5806f5 100755 --- a/test-integration/scripts/10-install-jhipster.sh +++ b/test-integration/scripts/10-install-jhipster.sh @@ -7,21 +7,28 @@ source $(dirname $0)/00-init-env.sh # Install JHipster Dependencies and Server-side library #------------------------------------------------------------------------------- cd "$HOME" -if [[ "$JHI_REPO" == *"/jhipster" ]]; then - echo "*** jhipster: use local version at JHI_REPO=$JHI_REPO" - cd "$JHI_HOME" +if [[ "$JHI_REPO" == *"/jhipster-bom" ]]; then + echo "*** jhipster: use local version at JHI_LIB_HOME=$JHI_LIB_HOME" + + cd "$JHI_LIB_HOME" 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 - ./mvnw -ntp clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true --batch-mode + test-integration/scripts/10-replace-version-jhipster.sh -elif [[ "$JHI_LIB_BRANCH" == "release" ]]; then + ./mvnw -ntp clean install -Dgpg.skip=true --batch-mode + ls -al ~/.m2/repository/tech/jhipster/jhipster-framework/ + ls -al ~/.m2/repository/tech/jhipster/jhipster-dependencies/ + ls -al ~/.m2/repository/tech/jhipster/jhipster-parent/ + +elif [[ "$JHI_LIB_BRANCH" == "release" || "$JHI_LIB_BRANCH" == "ignore" ]]; then echo "*** jhipster: use release version" else echo "*** jhipster: JHI_LIB_REPO=$JHI_LIB_REPO with JHI_LIB_BRANCH=$JHI_LIB_BRANCH" - git clone "$JHI_LIB_REPO" jhipster - cd jhipster + + git clone "$JHI_LIB_REPO" $JHI_LIB_HOME + cd $JHI_LIB_HOME if [ "$JHI_LIB_BRANCH" == "latest" ]; then LATEST=$(git describe --abbrev=0) git checkout "$LATEST" @@ -42,13 +49,14 @@ fi # Install JHipster Generator #------------------------------------------------------------------------------- cd "$HOME" -if [[ "$JHI_REPO" == *"/generator-jhipster" ]]; then - echo "*** generator-jhipster: use local version at JHI_REPO=$JHI_REPO" +if [[ "$JHI_REPO" == *"/generator-jhipster" || "$JHI_GEN_BRANCH" == "local" ]]; then + echo "*** generator-jhipster: use local version at JHI_HOME=$JHI_HOME" cd "$JHI_HOME" 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" + elif [[ "$JHI_GEN_BRANCH" == "release" ]]; then echo "*** generator-jhipster: use release version" npm install -g generator-jhipster @@ -66,5 +74,5 @@ else 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 "$HOME"/generator-jhipster + npm install -g . fi diff --git a/test-integration/scripts/11-generate-config.sh b/test-integration/scripts/11-generate-config.sh index 59eb391c275..c8d5791e7d3 100755 --- a/test-integration/scripts/11-generate-config.sh +++ b/test-integration/scripts/11-generate-config.sh @@ -44,11 +44,13 @@ fi mkdir -p "$JHI_FOLDER_APP"/.jhipster/ cd "$JHI_FOLDER_APP" -if [[ "$JHI_ENTITY" != "jdl" ]]; then +if [[ "$JHI_ENTITY" != "jdl" && "$JHI_APP" != "jdl" ]]; then #------------------------------------------------------------------------------- # Copy jhipster config #------------------------------------------------------------------------------- cp -f "$JHI_SAMPLES"/"$JHI_APP"/.yo-rc.json "$JHI_FOLDER_APP"/ + echo "$JHI_APP:" + ls -al "$JHI_FOLDER_APP"/ fi if [[ ("$JHI_ENTITY" == "mongodb") || ("$JHI_ENTITY" == "couchbase") ]]; then diff --git a/test-integration/scripts/11-generate-entities.sh b/test-integration/scripts/11-generate-entities.sh index 9a326e7746b..1b2aa1a0827 100755 --- a/test-integration/scripts/11-generate-entities.sh +++ b/test-integration/scripts/11-generate-entities.sh @@ -8,6 +8,9 @@ else fi echo "11-generate-entities.sh script is deprecated, use 11-generate-config.sh instead" +if [[ "$JHI_GENERATE_SKIP_CONFIG" == "1" ]]; then + exit 1 +fi #------------------------------------------------------------------------------- # Functions @@ -18,7 +21,9 @@ moveEntity() { } prepareFolder() { - rm -rf "$JHI_FOLDER_APP" + if [[$(dirname $(pwd)) != $(dirname $JHI_FOLDER_APP)]]; then + rm -rf "$JHI_FOLDER_APP" + fi mkdir -p "$JHI_FOLDER_APP"/.jhipster/ } #------------------------------------------------------------------------------- diff --git a/test-integration/scripts/12-generate-project.sh b/test-integration/scripts/12-generate-project.sh index 1abaed65411..6b94abd2bbe 100755 --- a/test-integration/scripts/12-generate-project.sh +++ b/test-integration/scripts/12-generate-project.sh @@ -17,6 +17,28 @@ if [[ "$JHI_ENTITY" == "jdl" ]]; then #------------------------------------------------------------------------------- mkdir -p "$JHI_FOLDER_APP" 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 $@ + +elif [[ "$JHI_APP" == "jdl" ]]; then + #------------------------------------------------------------------------------- + # Generate project with jhipster using jdl + #------------------------------------------------------------------------------- + mkdir -p "$JHI_FOLDER_APP" + + if [[ -f "$JHI_JDL_APP" ]]; then + cp -f "$JHI_JDL_APP" "$JHI_FOLDER_APP"/ + + elif [[ -d "$JHI_JDL_APP" ]]; then + cp -f "$JHI_JDL_APP"/*.jdl "$JHI_FOLDER_APP"/ + + else + cp -f "$JHI_JDL_SAMPLES"/"$JHI_JDL_APP"/*.jdl "$JHI_FOLDER_APP"/ + fi + + ls -la "$JHI_FOLDER_APP"/ + cd "$JHI_FOLDER_APP" jhipster import-jdl *.jdl --no-insight $@