Skip to content

cleanup cache in tests #2616

cleanup cache in tests

cleanup cache in tests #2616

#
# Copyright 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: Linked Issue Check
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
linked-issue-check:
runs-on: ubuntu-latest
permissions:
issues: read
pull-requests: read
outputs:
linked-issues: ${{ steps.get-linked-issues.outputs.issues }}
linked-issues-count: ${{ steps.get-linked-issues.outputs.linked_issues_count }}
steps:
- name: Get Linked Issues
id: get-linked-issues
uses: nearform-actions/github-action-check-linked-issues@v1
with:
custom-body-comment: 'This PR is not linked to any issues. Please consider adding the corresponding issues if they exist, in the pull request description.'
continue-on-error: true
closing-issues:
name: ${{ matrix.linked-issue }}
strategy:
fail-fast: false
matrix:
linked-issue: ${{ fromJSON(needs.linked-issue-check.outputs.linked-issues) }}
runs-on: ubuntu-latest
needs: linked-issue-check
defaults:
run:
working-directory: ${{ github.workspace }}/app
if: >-
fromJSON(needs.linked-issue-check.outputs.linked-issues-count) > 0 &&
!contains(github.event.pull_request.labels.*.name, 'pr: skip-closing-issues-check')
steps:
#----------------------------------------------------------------------
# Install all tools and check configuration
#----------------------------------------------------------------------
- name: 'SETUP: Checkout generator-jhipster'
uses: actions/checkout@v4
with:
path: generator-jhipster
fetch-depth: 2
- uses: ./generator-jhipster/.github/actions/setup-default-node-java
- uses: jhipster/actions/setup-runner@v0
with:
maven-cache: true
gradle-cache: true
binary-dir: ${{ github.workspace }}/generator-jhipster/bin
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- run: npm ci --ignore-scripts
working-directory: ${{ github.workspace }}/generator-jhipster
- name: 'GENERATION: project'
id: project
run: jhipster.cjs from-issue "${{ matrix.linked-issue }}" --no-code-workspace --disable-blueprints
env:
# generate-sample uses JHI_FOLDER_APP to generate the application.
JHI_FOLDER_APP: ${{ github.workspace }}/app
- run: jhipster.cjs info
if: steps.project.outputs.contains-sample != 'false'
#----------------------------------------------------------------------
# Launch tests
#----------------------------------------------------------------------
- uses: jhipster/actions/build-jhipster-bom@v0
with:
jhipster-bom-ref: main
- name: 'TESTS: backend'
if: steps.project.outputs.contains-sample != 'false'
id: backend
run: npm run ci:backend:test --if-present
timeout-minutes: 15
- name: 'PREPARE: npm install'
if: steps.project.outputs.contains-sample != 'false'
run: npm install
timeout-minutes: 7
- name: 'TESTS: frontend'
if: steps.project.outputs.contains-sample != 'false'
id: frontend
run: npm run ci:frontend:test --if-present
timeout-minutes: 15
- name: 'TESTS: packaging'
if: steps.project.outputs.contains-sample != 'false'
run: npm run ci:e2e:package --if-present
timeout-minutes: 12
- name: 'TESTS: Start docker compose containers for e2e tests'
if: steps.project.outputs.contains-sample != 'false'
run: npm run ci:e2e:prepare --if-present
timeout-minutes: 5
- name: 'E2E: Run'
if: steps.project.outputs.contains-sample != 'false'
id: e2e
run: npm run ci:e2e:run --if-present
timeout-minutes: 15
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v4
if: always() && steps.backend.outcome == 'failure' && steps.project.outputs.contains-sample != 'false'
with:
name: log-${{ matrix.number }}
path: app/**/test-results/**/*.xml
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v4
if: always() && steps.e2e.outcome == 'failure' && steps.project.outputs.contains-sample != 'false'
with:
name: screenshots-${{ matrix.number }}
path: app/**/cypress/screenshots
- name: Dump docker logs
if: always() && steps.project.outputs.contains-sample != 'false'
uses: jwalton/gh-docker-logs@v2
check-closing-issues:
permissions:
contents: none
runs-on: ubuntu-latest
needs: [closing-issues]
if: always()
steps:
- run: |
echo '${{ toJSON(needs) }}'
if [ 'skipped' == '${{ needs.closing-issues.result }}' ] || [ 'success' == '${{ needs.closing-issues.result }}' ] || [ 'closed' == '${{ github.event.action }}' ]; then
exit 0
fi
exit 12