Skip to content

Commit

Permalink
use more shared actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 13, 2023
1 parent 1681d07 commit 0da7573
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 129 deletions.
54 changes: 54 additions & 0 deletions .github/actions/handle-logs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright 2013-2023 the original author or authors from the JHipster project.
#
# This file is part of the JHipster project, see https://www.jhipster.tech/
# for more information.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: Handle logs
description: Handle logs
inputs:
name-suffix:
description: Suffix to append to the name
required: true
application-path:
description: Application path
required: true
upload-java-test-results:
description: Upload Java test results
required: false
default: 'false'
upload-cypress-snapshots:
description: Upload Cypress snapshots
required: false
default: 'false'
runs:
using: composite
steps:
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v3
if: always() && upload-java-test-results != 'false'
with:
name: log-${{ inputs.name-suffix }}
path: ${{ inputs.application-path }}/**/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && inputs.upload-cypress-snapshots != 'false'
with:
name: screenshots-${{ inputs.name-suffix }}
path: ${{ inputs.application-path }}/**/cypress/screenshots
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
33 changes: 33 additions & 0 deletions .github/actions/setup-bom/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright 2013-2023 the original author or authors from the JHipster project.
#
# This file is part of the JHipster project, see https://www.jhipster.tech/
# for more information.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: Setup JHipster BOM
description: Checkout JHipster BOM and build it
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
path: jhipster-bom
repository: jhipster/jhipster-bom
ref: main
fetch-depth: 1
- uses: jhipster/actions/build-jhipster-bom@v0
with:
jhipster-bom-path: jhipster-bom
8 changes: 6 additions & 2 deletions .github/actions/setup-generator-jhipster-jit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
generator-path:
description: Generator folder relative to workspace, git checkout, npm remove, install, and link will be executed in the folder.
required: true
executable:
description: Executable name
required: false
default: 'jh'
runs:
using: composite
steps:
Expand All @@ -33,7 +37,7 @@ runs:
npm install
mkdir -p "${HOME}/.bin"
echo "${HOME}/.bin" >> $GITHUB_PATH
ln -s "${{ github.workspace }}/${{ inputs.generator-path }}/bin/jhipster.cjs" "${HOME}/.bin/jh"
ls -la "${HOME}/.bin/jh"
ln -s "${{ github.workspace }}/${{ inputs.generator-path }}/bin/jhipster.cjs" "${HOME}/.bin/${{ inputs.executable }}"
ls -la "${HOME}/.bin/${{ inputs.executable }}"
"${{ github.workspace }}/${{ inputs.generator-path }}/bin/jhipster.cjs" --install-path
working-directory: ${{ github.workspace }}/${{ inputs.generator-path }}
33 changes: 13 additions & 20 deletions .github/workflows/angular.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ jobs:
with:
path: generator-jhipster
fetch-depth: 2
- uses: ./generator-jhipster/.github/actions/setup-generator-jhipster-jit
with:
generator-path: generator-jhipster
executable: jhipster
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
Expand All @@ -100,6 +104,7 @@ jobs:
jdl-sample: ${{ matrix.setup-jdl-sample }}
application-environment: ${{ matrix.setup-application-environment }}
application-packaging: ${{ matrix.setup-application-packaging }}
jhipster-bom-branch: ignore
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
Expand All @@ -112,19 +117,16 @@ jobs:
npm: true
maven: true
gradle: ${{ matrix.workspaces == 'true' || matrix.gradle == 1 || contains(matrix.name, 'gradle') }}
- name: 'TOOLS: configure tools installed by the system'
run: $JHI_SCRIPTS/03-system.sh
- name: 'TOOLS: configure git'
run: $JHI_SCRIPTS/04-git-config.sh
- uses: jhipster/actions/setup-keycloak-hostname@v0
- uses: jhipster/actions/setup-git@v0
# Update global NPM for workspaces support
- name: 'Install required NPM version'
if: matrix.workspaces == '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
- uses: ./generator-jhipster/.github/actions/setup-bom
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
Expand Down Expand Up @@ -185,21 +187,12 @@ jobs:
if: steps.compare.outputs.equals != 'true'
run: npm run ci:e2e:run --if-present
timeout-minutes: 15
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v3
if: always() && steps.backend.outcome == 'failure'
with:
name: log-${{ matrix.name }}
path: ${{ steps.setup.outputs.application-path }}/**/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
- uses: ./generator-jhipster/.github/actions/handle-logs
with:
name: screenshots-${{ matrix.name }}
path: ${{ steps.setup.outputs.application-path }}/**/cypress/screenshots
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
name: ${{ matrix.name }}
application-path: ${{ steps.setup.outputs.application-path }}
upload-java-test-results: ${{ steps.backend.outcome == 'failure' }}
upload-cypress-snapshots: ${{ steps.e2e.outcome == 'failure' }}
- name: 'ANALYSIS: Sonar analysis'
if: >-
github.event_name == 'push' &&
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/devserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jobs:
with:
path: generator-jhipster
fetch-depth: 2
- uses: ./generator-jhipster/.github/actions/setup-generator-jhipster-jit
with:
generator-path: generator-jhipster
executable: jhipster
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
Expand All @@ -79,6 +83,7 @@ jobs:
jdl-sample: ${{ matrix.setup-jdl-sample }}
application-environment: ${{ matrix.setup-application-environment }}
application-packaging: ${{ matrix.setup-application-packaging }}
jhipster-bom-branch: ignore
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.setup.outputs.node-version }}
Expand All @@ -91,15 +96,12 @@ jobs:
npm: true
maven: true
gradle: ${{ matrix.workspaces == 'true' || matrix.gradle == 1 || contains(matrix.name, 'gradle') }}
- name: 'TOOLS: configure tools installed by the system'
run: $JHI_SCRIPTS/03-system.sh
- name: 'TOOLS: configure git'
run: $JHI_SCRIPTS/04-git-config.sh
- uses: jhipster/actions/setup-keycloak-hostname@v0
- uses: jhipster/actions/setup-git@v0
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- name: 'GENERATION: install JHipster'
run: $JHI_SCRIPTS/10-install-jhipster.sh
- uses: ./generator-jhipster/.github/actions/setup-bom
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
Expand All @@ -112,18 +114,11 @@ jobs:
- name: 'E2E: Run'
id: e2e
run: npm run e2e:devserver --if-present
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v3
if: always() && steps.backend.outcome == 'failure'
with:
name: log-${{ matrix.app-sample }}
path: ${{ steps.setup.outputs.application-path }}/*/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
- uses: ./generator-jhipster/.github/actions/handle-logs
with:
name: screenshots-${{ matrix.app-sample }}
path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots
name: ${{ matrix.name }}
application-path: ${{ steps.setup.outputs.application-path }}
upload-cypress-snapshots: ${{ steps.e2e.outcome == 'failure' }}
check-dev-server:
permissions:
contents: none
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/generator-database-changelog-liquibase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jobs:
uses: actions/checkout@v4
with:
path: generator-jhipster
- uses: ./generator-jhipster/.github/actions/setup-generator-jhipster-jit
with:
generator-path: generator-jhipster
executable: jhipster
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
Expand All @@ -62,6 +66,7 @@ jobs:
entities-sample: ${{ matrix.entity }}
application-environment: ${{ matrix.environment }}
application-packaging: ${{ (matrix.war == 1 && 'war') || 'jar' }}
jhipster-bom-branch: ignore
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.setup.outputs.node-version }}
Expand All @@ -74,15 +79,12 @@ jobs:
npm: true
maven: true
gradle: ${{ matrix.workspaces == 'true' || matrix.gradle == 1 || contains(matrix.name, 'gradle') }}
- name: 'TOOLS: configure tools installed by the system'
run: $JHI_SCRIPTS/03-system.sh
- name: 'TOOLS: configure git'
run: $JHI_SCRIPTS/04-git-config.sh
- uses: jhipster/actions/setup-keycloak-hostname@v0
- uses: jhipster/actions/setup-git@v0
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- name: 'GENERATION: install JHipster'
run: $JHI_SCRIPTS/10-install-jhipster.sh
- uses: ./generator-jhipster/.github/actions/setup-bom
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
Expand All @@ -104,6 +106,7 @@ jobs:
# Launch tests
#----------------------------------------------------------------------
- name: 'TESTS: backend'
id: backend
run: npm run ci:backend:test
- name: 'TESTS: frontend'
run: npm run ci:frontend:test
Expand All @@ -114,9 +117,9 @@ jobs:
- name: 'E2E: Run'
id: e2e
run: npm run ci:e2e:run --if-present
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
- uses: ./generator-jhipster/.github/actions/handle-logs
with:
name: screenshots-${{ matrix.app-type }}
path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots
name: ${{ matrix.app-type }}
application-path: ${{ steps.setup.outputs.application-path }}
upload-java-test-results: ${{ steps.backend.outcome == 'failure' }}
upload-cypress-snapshots: ${{ steps.e2e.outcome == 'failure' }}
32 changes: 13 additions & 19 deletions .github/workflows/generator-generate-blueprint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ jobs:
with:
path: generator-jhipster
fetch-depth: 2
- uses: ./generator-jhipster/.github/actions/setup-generator-jhipster-jit
with:
generator-path: generator-jhipster
executable: jhipster
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
with:
application-sample: ng-default
executable: jhipster-foo
jhipster-bom-branch: ignore
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.setup.outputs.node-version }}
Expand All @@ -59,15 +64,12 @@ jobs:
with:
npm: true
maven: true
- name: 'TOOLS: configure tools installed by the system'
run: $JHI_SCRIPTS/03-system.sh
- name: 'TOOLS: configure git'
run: $JHI_SCRIPTS/04-git-config.sh
- uses: jhipster/actions/setup-keycloak-hostname@v0
- uses: jhipster/actions/setup-git@v0
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- name: 'GENERATION: install JHipster'
run: $JHI_SCRIPTS/10-install-jhipster.sh
- uses: ./generator-jhipster/.github/actions/setup-bom
env:
JHI_INSTALL_GLOBALLY: 'true'
- name: 'GENERATION: generate blueprint'
Expand All @@ -82,7 +84,7 @@ jobs:
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
run: $JHI_SCRIPTS/12-generate-project.sh ${{ matrix.extra-args }} ${{ matrix.new-extra-args }} --blueprints foo
run: $JHI_SCRIPTS/12-generate-project.sh --blueprints foo
- name: 'GENERATION: jhipster info'
run: $JHI_SCRIPTS/14-jhipster-info.sh
#----------------------------------------------------------------------
Expand All @@ -96,17 +98,9 @@ jobs:
ls template-file-server
- name: 'TESTS: backend'
id: backend
if: steps.compare.outputs.equals != 'true' && matrix.skip-backend-tests != 'true'
run: npm run ci:backend:test
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v3
if: always() && steps.backend.outcome == 'failure'
with:
name: log-${{ matrix.app-sample }}
path: ${{ steps.setup.outputs.application-path }}/*/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
- uses: ./generator-jhipster/.github/actions/handle-logs
with:
name: screenshots-${{ matrix.app-sample }}
path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots
name: application
application-path: ${{ steps.setup.outputs.application-path }}
upload-java-test-results: ${{ steps.backend.outcome == 'failure' }}
Loading

0 comments on commit 0da7573

Please sign in to comment.