From f08d3d576ffb8f7945b15d060e6953c567d7107d Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 24 Oct 2024 10:22:55 -0300 Subject: [PATCH] switch react and vue workflows to github-build-matrix (#27676) * switch react and vue workflows to github-build-matrix * Update .github/workflows/vue.yml Co-authored-by: Daniel Franco --------- Co-authored-by: Daniel Franco --- .github/workflows/react.yml | 34 ++++++++++++++++------------------ .github/workflows/vue.yml | 34 ++++++++++++++++------------------ 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml index 867e2c61e27b..a028d560cec3 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -51,13 +51,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 2 - - name: 'Build matrix' - id: build - uses: ./.github/actions/build-matrix - with: - workflow-samples-file: react + - run: npm ci --ignore-scripts + - id: build + run: bin/jhipster.cjs github-build-matrix react --event-name ${{ github.event_name }} applications: - name: ${{ matrix.name }} (n${{ matrix.node }}/j${{ matrix.java }}) + name: ${{ matrix.job-name }} runs-on: ${{ matrix.os || 'ubuntu-20.04' }} needs: build-matrix defaults: @@ -74,12 +72,12 @@ jobs: !contains(github.event.pull_request.title, '[ci skip]') && github.event.action != 'closed' && !contains(github.event.pull_request.labels.*.name, 'pr: skip-ci') && - needs.build-matrix.outputs.workflow-react == 'true' + fromJson(needs.build-matrix.outputs.matrix).include[0] != null timeout-minutes: 50 strategy: fail-fast: false # Matrix available at https://github.com/jhipster/generator-jhipster/tree/main/test-integration/workflow-samples/ - matrix: ${{fromJson(needs.build-matrix.outputs.matrix)}} + matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -91,8 +89,8 @@ jobs: fetch-depth: 2 - uses: jhipster/actions/setup-runner@v0 with: - node-version: ${{ matrix.node }} - java-version: ${{ matrix.java }} + node-version: ${{ matrix.node-version }} + java-version: ${{ matrix.java-version }} npm-version: ${{ matrix.npm-version }} maven-cache: true gradle-cache: ${{ matrix.gradle-cache }} @@ -103,7 +101,7 @@ jobs: - run: npm ci --ignore-scripts working-directory: ${{ github.workspace }}/generator-jhipster - name: 'GENERATION: project' - run: jhipster.cjs generate-sample ${{ matrix.name }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight + run: jhipster.cjs generate-sample ${{ matrix.sample }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight env: JHI_FOLDER_APP: ${{ github.workspace }}/app JHIPSTER_DEPENDENCIES_VERSION: ${{ matrix.jhipster-bom-cicd-version }} @@ -119,7 +117,7 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') with: generator-path: generator-jhipster - cmd: jhipster.cjs generate-sample ${{ matrix.name }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight + cmd: jhipster.cjs generate-sample ${{ matrix.sample }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight env: # generate-sample uses JHI_FOLDER_APP to generate the application. JHI_FOLDER_APP: ${{ github.workspace }}/base/app @@ -134,13 +132,13 @@ jobs: jhipster-bom-ref: ${{ matrix.jhipster-bom-branch }} - name: 'TESTS: backend' id: backend - if: steps.compare.outputs.equals != 'true' && matrix.skip-backend-tests != 'true' && needs.build-matrix.outputs.server != 'false' + if: steps.compare.outputs.equals != 'true' && matrix.skip-backend-tests != 'true' run: npm run ci:backend:test continue-on-error: ${{matrix.continue-on-backend-tests-error || false}} timeout-minutes: 15 # Run npm install for workspaces only, as it is done in packaging for non-workspaces - name: 'PREPARE: npm install' - if: matrix.workspaces == 'true' && steps.compare.outputs.equals != 'true' + if: steps.compare.outputs.equals != 'true' && matrix.workspaces == 'true' run: npm install timeout-minutes: 7 - name: 'TESTS: packaging' @@ -150,7 +148,7 @@ jobs: timeout-minutes: 12 - name: 'TESTS: frontend' id: frontend - if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' && needs.build-matrix.outputs.client != 'false' + if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' run: npm run ci:frontend:test timeout-minutes: 15 - name: 'TESTS: Start docker compose containers for e2e tests' @@ -166,7 +164,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() && (steps.backend.outcome == 'failure' || steps.e2e.outcome == 'failure' || steps.frontend.outcome == 'failure' || steps.packaging.outcome == 'failure') with: - name: app-${{ matrix.name }} + name: app-${{ matrix.sample }} include-hidden-files: true path: | ${{ github.workspace }}/app/**/* @@ -181,13 +179,13 @@ jobs: uses: actions/upload-artifact@v4 if: always() && steps.backend.outcome == 'failure' with: - name: log-${{ matrix.name }} + name: log-${{ matrix.sample }} path: ${{ github.workspace }}/app/**/test-results/**/*.xml - name: 'E2E: Store failure screenshots' uses: actions/upload-artifact@v4 if: always() && steps.e2e.outcome == 'failure' with: - name: screenshots-${{ matrix.name }} + name: screenshots-${{ matrix.sample }} path: ${{ github.workspace }}/app/**/cypress/screenshots - name: Dump docker logs if: always() diff --git a/.github/workflows/vue.yml b/.github/workflows/vue.yml index c6e9576fba9d..b3d8ec265b6c 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -51,13 +51,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 2 - - name: 'Build matrix' - id: build - uses: ./.github/actions/build-matrix - with: - workflow-samples-file: vue + - run: npm ci --ignore-scripts + - id: build + run: bin/jhipster.cjs github-build-matrix vue --event-name ${{ github.event_name }} applications: - name: ${{ matrix.name }} (n${{ matrix.node }}/j${{ matrix.java }}) + name: ${{ matrix.job-name }} runs-on: ${{ matrix.os || 'ubuntu-20.04' }} needs: build-matrix defaults: @@ -74,12 +72,12 @@ jobs: !contains(github.event.pull_request.title, '[ci skip]') && github.event.action != 'closed' && !contains(github.event.pull_request.labels.*.name, 'pr: skip-ci') && - needs.build-matrix.outputs.workflow-vue == 'true' + fromJson(needs.build-matrix.outputs.matrix).include[0] != null timeout-minutes: 50 strategy: fail-fast: false # Matrix available at https://github.com/jhipster/generator-jhipster/tree/main/test-integration/workflow-samples/ - matrix: ${{fromJson(needs.build-matrix.outputs.matrix)}} + matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -91,8 +89,8 @@ jobs: fetch-depth: 2 - uses: jhipster/actions/setup-runner@v0 with: - node-version: ${{ matrix.node }} - java-version: ${{ matrix.java }} + node-version: ${{ matrix.node-version }} + java-version: ${{ matrix.java-version }} npm-version: ${{ matrix.npm-version }} maven-cache: true gradle-cache: ${{ matrix.gradle-cache }} @@ -103,7 +101,7 @@ jobs: - run: npm ci --ignore-scripts working-directory: ${{ github.workspace }}/generator-jhipster - name: 'GENERATION: project' - run: jhipster.cjs generate-sample ${{ matrix.name }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight + run: jhipster.cjs generate-sample ${{ matrix.sample }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight env: JHI_FOLDER_APP: ${{ github.workspace }}/app JHIPSTER_DEPENDENCIES_VERSION: ${{ matrix.jhipster-bom-cicd-version }} @@ -119,7 +117,7 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') with: generator-path: generator-jhipster - cmd: jhipster.cjs generate-sample ${{ matrix.name }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight + cmd: jhipster.cjs generate-sample ${{ matrix.sample }} --skip-jhipster-dependencies --skip-checks --skip-install --no-insight env: # generate-sample uses JHI_FOLDER_APP to generate the application. JHI_FOLDER_APP: ${{ github.workspace }}/base/app @@ -134,13 +132,13 @@ jobs: jhipster-bom-ref: ${{ matrix.jhipster-bom-branch }} - name: 'TESTS: backend' id: backend - if: steps.compare.outputs.equals != 'true' && matrix.skip-backend-tests != 'true' && needs.build-matrix.outputs.server != 'false' + if: steps.compare.outputs.equals != 'true' && matrix.skip-backend-tests != 'true' run: npm run ci:backend:test continue-on-error: ${{matrix.continue-on-backend-tests-error || false}} timeout-minutes: 15 # Run npm install for workspaces only, as it is done in packaging for non-workspaces - name: 'PREPARE: npm install' - if: matrix.workspaces == 'true' && steps.compare.outputs.equals != 'true' + if: steps.compare.outputs.equals != 'true' && matrix.workspaces == 'true' run: npm install timeout-minutes: 7 - name: 'TESTS: packaging' @@ -150,7 +148,7 @@ jobs: timeout-minutes: 12 - name: 'TESTS: frontend' id: frontend - if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' && needs.build-matrix.outputs.client != 'false' + if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' run: npm run ci:frontend:test timeout-minutes: 15 - name: 'TESTS: Start docker compose containers for e2e tests' @@ -166,7 +164,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() && (steps.backend.outcome == 'failure' || steps.e2e.outcome == 'failure' || steps.frontend.outcome == 'failure' || steps.packaging.outcome == 'failure') with: - name: app-${{ matrix.name }} + name: app-${{ matrix.sample }} include-hidden-files: true path: | ${{ github.workspace }}/app/**/* @@ -181,13 +179,13 @@ jobs: uses: actions/upload-artifact@v4 if: always() && steps.backend.outcome == 'failure' with: - name: log-${{ matrix.name }} + name: log-${{ matrix.sample }} path: ${{ github.workspace }}/app/**/test-results/**/*.xml - name: 'E2E: Store failure screenshots' uses: actions/upload-artifact@v4 if: always() && steps.e2e.outcome == 'failure' with: - name: screenshots-${{ matrix.name }} + name: screenshots-${{ matrix.sample }} path: ${{ github.workspace }}/app/**/cypress/screenshots - name: Dump docker logs if: always()