From 61adf65944365090f8a9eff4cd02bd4181430cb4 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Tue, 1 Jun 2021 00:58:23 -0300 Subject: [PATCH] Use setup action at others workflows. --- .github/workflows/cache.yml | 63 +++++++--------- .github/workflows/incremental-changelog.yml | 80 ++++++-------------- .github/workflows/jdl.yml | 83 ++++++++------------ .github/workflows/react.yml | 84 +++++++-------------- .github/workflows/vue.yml | 84 +++++++-------------- .github/workflows/webflux.yml | 84 +++++++-------------- 6 files changed, 167 insertions(+), 311 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 06516ebb9de6..aa33eaed351a 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 956071b46ac4..676dcae96abe 100644 --- a/.github/workflows/incremental-changelog.yml +++ b/.github/workflows/incremental-changelog.yml @@ -37,28 +37,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 }} @@ -77,7 +55,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] app-type: @@ -86,17 +63,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 @@ -105,40 +74,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 @@ -146,10 +116,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' @@ -161,8 +131,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: @@ -199,7 +169,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 1d53f0653660..8b6458a1af16 100644 --- a/.github/workflows/jdl.yml +++ b/.github/workflows/jdl.yml @@ -32,28 +32,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 }} @@ -71,7 +49,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] jdl: @@ -94,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 @@ -137,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' @@ -149,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' @@ -169,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 @@ -247,13 +228,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 3bd6afec086e..6ce03f5bee00 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -37,28 +37,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 }} @@ -80,7 +58,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [react] app-type: @@ -148,14 +125,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 @@ -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/vue.yml b/.github/workflows/vue.yml index c2a9facf72d5..bba95c905f53 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -37,28 +37,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 }} @@ -80,7 +58,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [vue] app-type: @@ -146,14 +123,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 @@ -163,42 +132,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 @@ -206,10 +174,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' @@ -232,6 +200,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 @@ -251,7 +224,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: @@ -308,13 +280,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 295ae6e5c69c..849c444a9535 100644 --- a/.github/workflows/webflux.yml +++ b/.github/workflows/webflux.yml @@ -36,28 +36,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 }} @@ -82,7 +60,6 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.16.0] os: [ubuntu-20.04] cache: [angular] app-type: @@ -155,14 +132,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 @@ -172,42 +141,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 @@ -215,10 +183,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' @@ -241,6 +209,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 @@ -260,7 +233,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: @@ -317,13 +289,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