PromucFlow_constructor/.github/workflows/client-prettier.yml
Arpit Mohan 2650ea161d
ci: Updating actions/checkout to v4 and defaulting to fetch-depth 1 instead of 0 (#29281)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated GitHub Actions workflows to use `actions/checkout@v4` for
improved performance and reliability.
- Removed `fetch-depth` parameter to simplify checkout steps across
various workflows.
  - Standardized quote usage for consistency in workflow files.

- **Documentation**
- Adjusted formatting and descriptions in workflow files for better
clarity and readability.

- **Refactor**
- Aligned multiple workflow files to follow a consistent structure and
naming convention.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

fetch-depth 0 causes the Github workflow to checkout the entire Git
history. This is not required. We only need to check out the head of the
commit. By default, actions/checkout has fetch-depth=1, hence removing
it from the workflow completely for simplicity.
2023-12-05 13:44:43 +05:30

82 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Client Prettier 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/client
jobs:
prettier-check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
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@v4
with:
ref: refs/pull/${{ inputs.pr }}/merge
# 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
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-client
# Fetch prior run result
- name: Get the previous run result
id: run_result
run: cat ~/run_result 2>/dev/null || echo 'default'
# In case of prior failure run the job
- if: steps.run_result.outputs.run_result != 'success'
run: echo "I'm alive!" && exit 0
- name: Use Node.js
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-node@v3
with:
node-version-file: app/client/package.json
# actions/setup-node@v3 doesnt work properly with Yarn 3
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
# Restoring the cache manually instead
- name: Restore Yarn cache
if: steps.run_result.outputs.run_result != 'success'
uses: actions/cache@v3
with:
path: app/client/.yarn/cache
key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }}
restore-keys: v1-yarn3-
# Install all the dependencies
- name: Install dependencies
if: steps.run_result.outputs.run_result != 'success'
run: yarn install --immutable
# Run the Prettier for client and packages
- name: Run Prettier
if: steps.run_result.outputs.run_result != 'success'
run: yarn run prettier:ci
# Saving the cache to use it in subsequent runs
- name: Save Yarn cache
uses: actions/cache/save@v3
with:
path: app/client/.yarn/cache
key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }}
restore-keys: v1-yarn3-