diff --git a/.github/workflows/client-prettier.yml b/.github/workflows/client-prettier.yml index 834036c91d..f6fa9d01b0 100644 --- a/.github/workflows/client-prettier.yml +++ b/.github/workflows/client-prettier.yml @@ -1,25 +1,12 @@ -name: Client Prettier +name: Client Prettier Check on: - # This line enables manual triggering of this workflow. - workflow_dispatch: workflow_call: inputs: pr: description: "This is the PR number in case the workflow is being called in a pull request" required: false type: number - skip-tests: - description: "This is a boolean value in case the workflow is being called in build deploy-preview" - required: false - type: string - default: "false" - - pull_request: - branches: [release, master] - paths: - - "app/client/**" - - "!app/client/cypress/manual_TestSuite/**" # Change the working directory for all the jobs in this workflow defaults: @@ -27,40 +14,20 @@ defaults: working-directory: app/client jobs: - build: - runs-on: ubuntu-latest-8-cores - # Only run this workflow for internally triggered events - if: | - github.event.pull_request.head.repo.full_name == github.repository || - github.event_name == 'push' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'repository_dispatch' + prettier-check: + runs-on: ubuntu-latest defaults: run: working-directory: app/client shell: bash steps: - # The checkout steps MUST happen first because the default directory is set according to the code base. - # GitHub Action expects all future commands to be executed in the code directory. Hence, we need to check out - # the code before doing anything else. - # Check out merge commit with the base branch in case this workflow is invoked via pull request - name: Checkout the merged commit from PR and base branch - if: inputs.pr != 0 uses: actions/checkout@v3 with: - fetch-depth: 0 ref: refs/pull/${{ inputs.pr }}/merge - # Checkout the code in the current branch in case the workflow is called because of a branch push event - - name: Checkout the head commit of the branch - if: inputs.pr == 0 - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # In case this is second attempt try restoring status of the prior attempt from cache - name: Restore the previous run result uses: actions/cache@v3 @@ -93,8 +60,7 @@ jobs: with: path: app/client/.yarn/cache key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }} - restore-keys: | - v1-yarn3- + restore-keys: v1-yarn3- # Install all the dependencies - name: Install dependencies @@ -112,9 +78,4 @@ jobs: with: path: app/client/.yarn/cache key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }} - restore-keys: | - v1-yarn3- - - # Set status = success - - name: Save the status of the run - run: echo "run_result=success" >> $GITHUB_OUTPUT > ~/run_result + restore-keys: v1-yarn3- diff --git a/.github/workflows/formatting-checks.yml b/.github/workflows/formatting-checks.yml new file mode 100644 index 0000000000..939293b9db --- /dev/null +++ b/.github/workflows/formatting-checks.yml @@ -0,0 +1,64 @@ +name: Formatting checks + +on: + pull_request: + branches: [release, master] + +jobs: + path-filter: + runs-on: ubuntu-latest + outputs: + server: ${{ steps.filter.outputs.server }} + client: ${{ steps.filter.outputs.client }} + steps: + # Check out merge commit with the base branch in case this workflow is invoked via pull request + - name: Checkout the merged commit from PR and base branch + uses: actions/checkout@v3 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + server: + - 'app/server/**' + client: + - 'app/client/**' + + server-formatting: + name: server-formatting + needs: path-filter + if: needs.path-filter.outputs.server == 'true' + uses: ./.github/workflows/server-spotless.yml + secrets: inherit + with: + pr: ${{ github.event.pull_request.number }} + + client-formatting: + name: client-formatting + needs: path-filter + if: needs.path-filter.outputs.client == 'true' + uses: ./.github/workflows/client-prettier.yml + secrets: inherit + with: + pr: ${{ github.event.pull_request.number }} + + formatting-result: + name: formatting-result + needs: [server-formatting, client-formatting] + if: always() + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Return status for formatting checks + run: | + if [[ "${{ needs.server-formatting.result }}" == "failure" || "${{ needs.client-formatting.result }}" == "failure" ]]; then + echo "Formatting checks failed"; + exit 1; + else + echo "Formatting checks successful"; + exit 0; + fi diff --git a/.github/workflows/server-spotless.yml b/.github/workflows/server-spotless.yml new file mode 100644 index 0000000000..a9ab2c5305 --- /dev/null +++ b/.github/workflows/server-spotless.yml @@ -0,0 +1,36 @@ +# This workflow is responsible for running Spotless check on server code base +name: Server Spotless Check + +on: + workflow_call: + inputs: + pr: + description: "This is the PR number in case the workflow is being called in a pull request" + required: false + type: number + +# Change the working directory for all the jobs in this workflow +defaults: + run: + working-directory: app/server + +jobs: + spotless-check: + runs-on: ubuntu-latest + steps: + # Check out merge commit with the base branch in case this workflow is invoked via pull request + - name: Checkout the merged commit from PR and base branch + uses: actions/checkout@v3 + with: + ref: refs/pull/${{ inputs.pr }}/merge + + # Setup Java + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + # Run maven step for spotless check + - name: Run spotless check + run: mvn spotless:check