Implement updates for better performance #58
This file contains hidden or 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
| name: CI Formatting Check | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| jobs: | |
| formatting_check: | |
| runs-on: ubuntu-latest | |
| env: | |
| BACKEND_DIR: backend | |
| WEB_FRONTEND_DIR: web-frontend | |
| MOBILE_FRONTEND_DIR: mobile-frontend | |
| INFRASTRUCTURE_DIR: infrastructure | |
| steps: | |
| # ------------------------------- | |
| # Checkout Repository | |
| # ------------------------------- | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| # ------------------------------- | |
| # Java Setup + Formatting | |
| # ------------------------------- | |
| - name: Set up Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Install Google Java Format | |
| run: | | |
| curl -LJO https://github.com/google/google-java-format/releases/download/v1.17.0/google-java-format-1.17.0-all-deps.jar | |
| - name: Run Java Formatting Checks | |
| working-directory: ${{ env.BACKEND_DIR }} | |
| run: | | |
| echo "=== Running Google Java Format ===" | |
| find . -name "*.java" | while read file; do | |
| java -jar ../google-java-format-1.17.0-all-deps.jar --dry-run "$file" || exit 1 | |
| done | |
| # ------------------------------- | |
| # Node + npm caching | |
| # ------------------------------- | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: tools/package-lock.json | |
| - name: Install Node dependencies | |
| working-directory: tools | |
| run: npm ci | |
| # ------------------------------- | |
| # Prettier checks | |
| # ------------------------------- | |
| # 1) Web frontend | |
| - name: Run Prettier Checks (web-frontend) | |
| if: ${{ env.WEB_FRONTEND_DIR != '' }} | |
| working-directory: tools | |
| run: | | |
| echo "=== Running Prettier (web-frontend) ===" | |
| npx --no-install prettier --check "../${{ env.WEB_FRONTEND_DIR }}/**/*.{js,jsx,ts,tsx,json,html,css,md}" --ignore-path ../.prettierignore || { | |
| echo "Prettier issues found in ${WEB_FRONTEND_DIR}." | |
| exit 1 | |
| } | |
| # 2) Mobile frontend | |
| - name: Run Prettier Checks (mobile-frontend) | |
| if: ${{ env.MOBILE_FRONTEND_DIR != '' }} | |
| working-directory: tools | |
| run: | | |
| echo "=== Running Prettier (mobile-frontend) ===" | |
| npx --no-install prettier --check "../${{ env.MOBILE_FRONTEND_DIR }}/**/*.{js,jsx,ts,tsx,json,html,css,md}" --ignore-path ../.prettierignore || { | |
| echo "Prettier issues found in ${MOBILE_FRONTEND_DIR}." | |
| exit 1 | |
| } | |
| # 3) Repository-wide Markdown check (ALL .md files) | |
| - name: Run Prettier Checks (all .md files in repo) | |
| working-directory: tools | |
| run: | | |
| echo "=== Running Prettier (all .md files) ===" | |
| npx --no-install prettier --check "../**/*.md" --ignore-path ../.prettierignore || { | |
| echo "Prettier formatting issues detected in markdown files across the repo." | |
| exit 1 | |
| } | |
| # 4) Infrastructure YAML/YML files only | |
| - name: Run Prettier Checks (infrastructure YAML) | |
| working-directory: tools | |
| run: | | |
| if [ -n "${{ env.INFRASTRUCTURE_DIR }}" ] && [ -d "../${{ env.INFRASTRUCTURE_DIR }}" ]; then | |
| echo "=== Running Prettier (infrastructure YAML/YML files) in ${INFRASTRUCTURE_DIR} ===" | |
| npx --no-install prettier --check "../${{ env.INFRASTRUCTURE_DIR }}/**/*.{yml,yaml}" --ignore-path ../.prettierignore || { | |
| echo "Prettier formatting issues detected in ${INFRASTRUCTURE_DIR} YAML/YML files." | |
| exit 1 | |
| } | |
| else | |
| echo "No infrastructure directory '${{ env.INFRASTRUCTURE_DIR }}' found or INFRASTRUCTURE_DIR unset — skipping infra YAML checks." | |
| fi | |
| # ------------------------------- | |
| # Finalize | |
| # ------------------------------- | |
| - name: Finalize Check | |
| run: echo "All formatting checks completed successfully." |