$npx -y skills add Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-testing-cicdUse when setting up CI/CD pipelines for Frappe apps, configuring GitHub Actions test workflows, or adding linting and security scanning. Prevents broken CI from incorrect test matrix configuration, missing MariaDB/Redis services, and uncaught code quality issues. Covers GitHub Ac
| 1 | # CI/CD Pipelines |
| 2 | |
| 3 | ## Quick Reference |
| 4 | |
| 5 | | Task | Tool / File | |
| 6 | |------|------------| |
| 7 | | Install pre-commit hooks | `pre-commit install --hook-type pre-commit --hook-type commit-msg` | |
| 8 | | Run all pre-commit checks | `pre-commit run --all-files` | |
| 9 | | Run linter | `ruff check .` | |
| 10 | | Run formatter | `ruff format .` | |
| 11 | | Run ESLint | `npx eslint "**/*.js" --quiet` | |
| 12 | | Run tests in CI | `bench --site test_site run-tests --app myapp` | |
| 13 | | Run parallel tests | `bench --site test_site run-parallel-tests --total-builds 2 --build-number 0` | |
| 14 | | Generate coverage | `coverage run -m pytest && coverage xml` | |
| 15 | | Generate JUnit XML | `bench --site test_site run-tests --junit-xml-output report.xml` | |
| 16 | |
| 17 | ## Decision Tree: CI/CD Setup |
| 18 | |
| 19 | ``` |
| 20 | Setting up CI for a Frappe app? |
| 21 | ├─ Start with GitHub Actions workflow |
| 22 | │ ├─ ALWAYS include MariaDB + Redis services |
| 23 | │ ├─ ALWAYS use test matrix for Python versions |
| 24 | │ └─ Optionally add PostgreSQL for dual-DB support |
| 25 | ├─ Add pre-commit hooks |
| 26 | │ ├─ ALWAYS include ruff (Python linting + formatting) |
| 27 | │ ├─ ALWAYS include eslint + prettier (JS/Vue) |
| 28 | │ └─ Add commitlint for conventional commits |
| 29 | ├─ Add security scanning? |
| 30 | │ └─ YES → Add semgrep with Frappe-specific rules |
| 31 | └─ Need release automation? |
| 32 | └─ YES → Add tag-based release workflow |
| 33 | ``` |
| 34 | |
| 35 | ## GitHub Actions Workflow for Frappe Apps |
| 36 | |
| 37 | ### Standard Server Test Workflow |
| 38 | |
| 39 | ```yaml |
| 40 | name: Server Tests |
| 41 | on: |
| 42 | push: |
| 43 | branches: [main, develop] |
| 44 | pull_request: |
| 45 | branches: [main, develop] |
| 46 | |
| 47 | concurrency: |
| 48 | group: server-tests-${{ github.ref }} |
| 49 | cancel-in-progress: true |
| 50 | |
| 51 | jobs: |
| 52 | test: |
| 53 | runs-on: ubuntu-latest |
| 54 | timeout-minutes: 60 |
| 55 | |
| 56 | strategy: |
| 57 | fail-fast: false |
| 58 | matrix: |
| 59 | python-version: ["3.11", "3.12"] |
| 60 | db: ["mariadb"] |
| 61 | |
| 62 | services: |
| 63 | mariadb: |
| 64 | image: mariadb:11.4 |
| 65 | ports: |
| 66 | - 3306:3306 |
| 67 | env: |
| 68 | MARIADB_ROOT_PASSWORD: db_root |
| 69 | options: >- |
| 70 | --health-cmd="healthcheck.sh --connect --innodb_initialized" |
| 71 | --health-interval=5s |
| 72 | --health-timeout=5s |
| 73 | --health-retries=10 |
| 74 | |
| 75 | redis-cache: |
| 76 | image: redis:alpine |
| 77 | ports: |
| 78 | - 13000:6379 |
| 79 | redis-queue: |
| 80 | image: redis:alpine |
| 81 | ports: |
| 82 | - 11000:6379 |
| 83 | |
| 84 | steps: |
| 85 | - name: Checkout frappe |
| 86 | uses: actions/checkout@v4 |
| 87 | with: |
| 88 | repository: frappe/frappe |
| 89 | path: frappe-bench/apps/frappe |
| 90 | |
| 91 | - name: Checkout app |
| 92 | uses: actions/checkout@v4 |
| 93 | with: |
| 94 | path: frappe-bench/apps/myapp |
| 95 | |
| 96 | - name: Setup Python |
| 97 | uses: actions/setup-python@v5 |
| 98 | with: |
| 99 | python-version: ${{ matrix.python-version }} |
| 100 | |
| 101 | - name: Setup Node |
| 102 | uses: actions/setup-node@v4 |
| 103 | with: |
| 104 | node-version: 20 |
| 105 | |
| 106 | - name: Install bench |
| 107 | run: pip install frappe-bench |
| 108 | |
| 109 | - name: Init bench |
| 110 | working-directory: frappe-bench |
| 111 | run: | |
| 112 | bench init --skip-assets --skip-redis-config-generation . |
| 113 | bench set-config -g db_root_password db_root |
| 114 | bench set-config -g redis_cache redis://localhost:13000 |
| 115 | bench set-config -g redis_queue redis://localhost:11000 |
| 116 | |
| 117 | - name: Install app |
| 118 | working-directory: frappe-bench |
| 119 | run: | |
| 120 | bench get-app --skip-assets myapp ./apps/myapp |
| 121 | bench setup requirements --dev |
| 122 | bench new-site test_site \ |
| 123 | --db-root-password db_root \ |
| 124 | --admin-password admin \ |
| 125 | --no-mariadb-socket |
| 126 | bench --site test_site install-app myapp |
| 127 | bench build --apps myapp |
| 128 | |
| 129 | - name: Run tests |
| 130 | working-directory: frappe-bench |
| 131 | run: bench --site test_site run-tests --app myapp --failfast |
| 132 | |
| 133 | - name: Upload coverage |
| 134 | if: always() |
| 135 | uses: actions/upload-artifact@v4 |
| 136 | with: |
| 137 | name: coverage-${{ matrix.python-version }}-${{ matrix.db }} |
| 138 | path: frappe-bench/sites/coverage.xml |
| 139 | ``` |
| 140 | |
| 141 | ### PostgreSQL Support (Additional Matrix Entry) |
| 142 | |
| 143 | ```yaml |
| 144 | strategy: |
| 145 | matrix: |
| 146 | include: |
| 147 | - python-version: "3.12" |
| 148 | db: "postgres" |
| 149 | |
| 150 | services: |
| 151 | postgres: |
| 152 | image: postgres:16 |
| 153 | ports: |
| 154 | - |