From cb378b0619bd95f45557e68148fdad6145a9a254 Mon Sep 17 00:00:00 2001 From: luca-sartori-zupit Date: Thu, 26 Sep 2024 22:44:18 +0200 Subject: [PATCH] fix: check on node-workflow-common --- .github/workflows/node-workflow-common.yml | 57 +++++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/node-workflow-common.yml b/.github/workflows/node-workflow-common.yml index 23540b2c..9d6d8d0a 100644 --- a/.github/workflows/node-workflow-common.yml +++ b/.github/workflows/node-workflow-common.yml @@ -29,11 +29,11 @@ on: RUN_ON: required: false type: string - default: 'zupit-agents' + default: "zupit-agents" RUNNERS_CONTAINER_GROUP: required: false type: string - default: 'Container' + default: "Container" RUN: required: false type: boolean @@ -42,11 +42,47 @@ on: required: false type: string default: "" + CHECK_WORKDIR_CHANGES: + required: true + type: boolean + default: false + CHECK_CUSTOM_DIR: + required: false + type: string + default: "" + CHECK_CHANGES_BY_JOBS: + required: false + type: string + default: "all" + +env: + CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }} jobs: + workdir-has-changes: + runs-on: ubuntu-latest + outputs: + changes-detected: ${{ steps.filter.outputs.changes-detected }} + steps: + - name: Set CHECK_DIR to custom directory if provided + if: ${{ inputs.CHECK_CUSTOM_DIR != '' }} + run: echo "CHECK_DIR=${{ inputs.CHECK_CUSTOM_DIR }}" >> $GITHUB_ENV + - name: Set default CHECK_DIR + if: ${{ inputs.CHECK_CUSTOM_DIR == '' }} + run: echo "CHECK_DIR=${{ inputs.WORKING_DIRECTORY }}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + changes-detected: + - ${{ env.CHECK_DIR }} + lint-check-build: - uses: - ./.github/workflows/node-step-format-lint-build.yml + needs: workdir-has-changes + if: ${{ !inputs.CHECK_WORKDIR_CHANGES || (needs.workdir-has-changes.outputs.changes-detected == 'true' && (inputs.CHECK_CHANGES_BY_JOBS == 'all' || contains(fromJson(inputs.CHECK_CHANGES_BY_JOBS), github.job)))}} + uses: ./.github/workflows/node-step-format-lint-build.yml with: RUN_ON: ${{inputs.RUN_ON}} RUNNERS_CONTAINER_GROUP: ${{inputs.RUNNERS_CONTAINER_GROUP}} @@ -57,9 +93,9 @@ jobs: secrets: inherit cypress-run: - if: ${{ inputs.ENABLE_TESTS }} - uses: - ./.github/workflows/node-step-test-cypress.yml + needs: workdir-has-changes + if: ${{ inputs.ENABLE_TESTS && !inputs.CHECK_WORKDIR_CHANGES || (needs.workdir-has-changes.outputs.changes-detected == 'true' && (inputs.CHECK_CHANGES_BY_JOBS == 'all' || contains(fromJson(inputs.CHECK_CHANGES_BY_JOBS), github.job))) }} + uses: ./.github/workflows/node-step-test-cypress.yml with: RUN_ON: ${{inputs.RUN_ON}} RUNNERS_CONTAINER_GROUP: ${{inputs.RUNNERS_CONTAINER_GROUP}} @@ -71,3 +107,10 @@ jobs: PROJECT: ${{ inputs.PROJECT }} secrets: inherit + jobs-succeded: + needs: ["lint-check-build", "cypress-run"] + runs-on: ubuntu-latest + if: ${{ always()}} + steps: + - name: Jobs succeeded. + run: if [ "${{ needs.lint-check-build.result }}" == "failure" || "${{ needs.cypress-run.result }}" == "failure" ]; then exit 1; fi