Refactor code and enhance maintainability. #91
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 # Python project | |
| web-frontend_DIR: web-frontend # Node/JS project | |
| steps: | |
| # ------------------------------- | |
| # Checkout | |
| # ------------------------------- | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| # ------------------------------- | |
| # Python Setup + Formatting | |
| # ------------------------------- | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Python Formatters | |
| run: | | |
| pip install autoflake isort black | |
| - name: Run Python Formatting Checks | |
| working-directory: ${{ env.BACKEND_DIR }} | |
| run: | | |
| echo "=== Running autoflake (diff mode) ===" | |
| cp -r . /tmp/python_copy | |
| autoflake \ | |
| --remove-all-unused-imports \ | |
| --remove-unused-variables \ | |
| --recursive \ | |
| --ignore-init-module-imports \ | |
| --in-place \ | |
| /tmp/python_copy | |
| echo "Comparing files..." | |
| diff -r . /tmp/python_copy > /dev/null || { | |
| echo "autoflake found issues." | |
| exit 1 | |
| } | |
| echo "=== Running black ===" | |
| black . --check | |
| # ------------------------------- | |
| # Node + Prettier Setup | |
| # ------------------------------- | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| - name: Install Node Dependencies | |
| working-directory: ${{ env.web-frontend_DIR }} | |
| run: npm install | |
| - name: Run Prettier Checks | |
| working-directory: ${{ env.web-frontend_DIR }} | |
| run: | | |
| echo "=== Running Prettier ===" | |
| npx prettier --check "**/*.{js,jsx,ts,tsx,json,html,css,md}" | |
| # ------------------------------- | |
| # Done | |
| # ------------------------------- | |
| - name: Finalize Check | |
| run: echo "All formatting checks completed successfully." |