Implement updates for better performance #135
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 | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| jobs: | |
| # ============================================================ | |
| # Job 1 -- Code Quality Checks (Python & Prettier) | |
| # ============================================================ | |
| code_quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Python formatters | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install autoflake black==25.11.0 | |
| - name: Check Python Code Quality | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "=== Running autoflake check ===" | |
| autoflake --remove-all-unused-imports --remove-unused-variables --recursive --check . | |
| echo "=== Running black check ===" | |
| black . --check | |
| - name: Set up Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install Global Formatters | |
| run: npm install -g prettier prettier-plugin-solidity | |
| - name: Run Global Prettier Check | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| NODE_GLOBAL=$(npm root -g) | |
| echo "=== Running Prettier check ===" | |
| prettier --plugin="$NODE_GLOBAL/prettier-plugin-solidity/dist/index.js" \ | |
| --check "**/*.{js,jsx,ts,tsx,json,html,css,md,sol,yml,yaml}" | |
| # ============================================================ | |
| # Job 2 -- Backend Tests (Python / Pytest) | |
| # ============================================================ | |
| backend_tests: | |
| name: Backend Tests | |
| runs-on: ubuntu-latest | |
| needs: code_quality | |
| env: | |
| BACKEND_DIR: code/backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: code/backend/requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel | |
| if [ -f "${BACKEND_DIR}/requirements.txt" ]; then | |
| python -m pip install -r "${BACKEND_DIR}/requirements.txt" | |
| fi | |
| python -m pip install pytest pytest-cov pytest-asyncio | |
| - name: Run backend test suite | |
| working-directory: ${{ env.BACKEND_DIR }} | |
| run: | | |
| set -euo pipefail | |
| pytest tests/ \ | |
| --tb=short \ | |
| --strict-markers \ | |
| -v \ | |
| --cov=. \ | |
| --cov-report=xml:coverage.xml | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-coverage-report | |
| path: code/backend/coverage.xml | |
| retention-days: 30 | |
| # ============================================================ | |
| # Job 3 -- Web Frontend Build | |
| # ============================================================ | |
| frontend_build: | |
| name: Frontend Build | |
| runs-on: ubuntu-latest | |
| needs: code_quality | |
| defaults: | |
| run: | |
| working-directory: web-frontend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: web-frontend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Build web-frontend | |
| run: CI=false npm run build | |
| - name: Upload build artifacts | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: web-frontend/dist/ | |
| retention-days: 7 |