Skip to content

Commit

Permalink
fix: check on node-workflow-common
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-sartori-zupit committed Sep 26, 2024
1 parent e89564c commit cb378b0
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions .github/workflows/node-workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand All @@ -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}}
Expand All @@ -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

0 comments on commit cb378b0

Please sign in to comment.