Add Fleet Management > Agents view #127
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ✨ **ESLint and Prettier Code Quality Assurance Workflow** | |
# | |
# ⚡ **Overview:** | |
# This GitHub Action runs ESLint and Prettier on all JavaScript and TypeScript files | |
# (.js, .jsx, .ts, .tsx) that have changed in a pull request, ensuring that the code | |
# adheres to both linting standards and formatting rules, helping maintain code quality | |
# and consistency across the project. | |
# | |
# 🛠️ **Key Features:** | |
# - 🚨 Runs ESLint and Prettier checks only on changed or renamed JS/TS files (ignores deleted files). | |
# - 🚀 Ensures code consistency and formatting before PRs are merged. | |
# | |
# ⚠️ **Notes:** | |
# - If any file fails the formatting check, the workflow will fail, prompting the contributor to fix formatting issues. | |
# | |
# 📖 **References:** | |
# - ESLint: https://eslint.org | |
# - ESLint GitHub Repo: https://github.com/eslint/eslint | |
# - Prettier: https://prettier.io/docs/en/cli.html | |
name: Code Quality Assurance | |
on: | |
pull_request: | |
branches-ignore: | |
- 2.* | |
- 3.* | |
- 4.* | |
concurrency: | |
group: pr-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint_and_format: | |
name: Ensure code quality and format on the changed files | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
tool: | |
- { command: 'eslint', flags: '' } | |
- { command: 'prettier', flags: '--check --ignore-unknown' } # use `--ignore-unknown` to skip unsupported file types. | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Fetch required branches | |
run: | | |
REMOTE_NAME=origin | |
echo "Base ref: $GITHUB_BASE_REF" | |
echo "Head ref: $GITHUB_HEAD_REF" | |
git fetch origin $GITHUB_BASE_REF | |
git fetch origin $GITHUB_HEAD_REF | |
echo "Listing branches:" | |
git branch -a | |
- name: Get changed files | |
id: changed-files | |
run: | | |
CHANGED_FILES=$(git diff --name-status --diff-filter d ${REMOTE_NAME}/${GITHUB_BASE_REF}..${REMOTE_NAME}/${GITHUB_HEAD_REF} | awk '{print $NF}' | grep -E '.*\.[jt]sx?$' || echo "false") | |
if [ "$CHANGED_FILES" = "false" ]; then | |
echo "No changed files found with the extension .js, .jsx, .ts or .tsx" | |
echo "changed_files=" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "Changed files:" | |
echo "${CHANGED_FILES}" | |
echo "changed_files=${CHANGED_FILES}" >> $GITHUB_OUTPUT | |
- name: Checkout PR branch | |
if: steps.changed-files.outputs.changed_files != '' | |
run: git checkout $GITHUB_HEAD_REF | |
- name: Install dependencies | |
if: steps.changed-files.outputs.changed_files != '' | |
run: yarn | |
- name: Run ${{ matrix.tool.command }} | |
if: steps.changed-files.outputs.changed_files != '' | |
run: npx ${{ matrix.tool.command }} ${{ steps.changed-files.outputs.changed_files }} ${{ matrix.tool.flags }} |