name: 'Setup Environment' description: 'Sets up the environment for Frappe development' inputs: python-version: description: 'Python version to use' required: false default: '3.12.6' node-version: description: 'Node.js version to use' required: false default: '22' build-assets: required: false description: 'Wether to build assets' default: true enable-coverage: required: false default: false enable-watch: required: false default: false enable-schedule: required: false default: false disable-web: required: false default: false disable-socketio: required: false default: false db: required: false default: mariadb db-root-password: required: true runs: using: "composite" steps: - shell: bash -e {0} run: | # Add 'test_site' to /etc/hosts & setup git config echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts git config --global init.defaultBranch main git config --global advice.detachedHead false - name: Clone uses: actions/checkout@v4 with: path: apps/${{ github.event.repository.name }} - name: Setup Python uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - shell: bash -e {0} run: | # Check for valid Python & Merge Conflicts python -m compileall -q -f "${GITHUB_WORKSPACE}/apps/${{ github.event.repository.name }}" if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}/apps/${{ github.event.repository.name }}" then echo "Found merge conflicts" exit 1 fi - name: Checkout Frappe uses: actions/checkout@v4 with: repository: ${{ env.FRAPPE_GH_ORG || github.repository_owner }}/frappe ref: ${{ github.event.client_payload.frappe_sha || github.base_ref || github.ref_name }} path: apps/frappe if: github.event.repository.name != 'frappe' - uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} check-latest: true - name: Cache pip uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }} restore-keys: | ${{ runner.os }}-pip- ${{ runner.os }}- - id: yarn-cache-dir-path shell: bash -e {0} run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - shell: bash -e {0} run: | # Install System Dependencies start_time=$(date +%s) curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt -qq update sudo apt -qq remove mysql-server mysql-client sudo apt -qq remove -y postgresql-client postgresql-client-16 postgresql-client-common sudo apt -qq install libcups2-dev redis-server mariadb-client libmariadb-dev postgresql-client-18 libpq-dev echo "/usr/lib/postgresql/18/bin" >> $GITHUB_PATH wget -q -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb sudo apt install /tmp/wkhtmltox.deb end_time=$(date +%s) echo -e "\033[33mInstall System Dependencies: $((end_time - start_time)) seconds\033[0m" - shell: bash -e {0} env: DB: ${{ inputs.db }} run: | # Init Bench & test_site start_time=$(date +%s) mkdir ${GITHUB_WORKSPACE}/{sites,config,logs,config/pids,sites/test_site} python -m venv ${GITHUB_WORKSPACE}/env source ${GITHUB_WORKSPACE}/env/bin/activate pip install --quiet --upgrade pip pip cache remove mysqlclient pip install --quiet frappe-bench python <> sites/apps.txt echo -e "\033[32mAdded $app_name to $PWD/sites/apps.txt\033[0m" done step_end_time=$(date +%s) echo -e "\033[33mInstall App(s): $((step_end_time - step_start_time)) seconds\033[0m" env: TYPE: server - shell: bash -e {0} run: | # Start Bench source ${GITHUB_WORKSPACE}/env/bin/activate bench start &> ${GITHUB_WORKSPACE}/bench_start.log & - shell: bash -e {0} if: ${{ inputs.build-assets == 'true' }} run: | # Build Assets start_time=$(date +%s) source ${GITHUB_WORKSPACE}/env/bin/activate CI=Yes bench build --force --production & build_pid=$! bench --site test_site reinstall --yes wait $build_pid end_time=$(date +%s) echo -e "\033[33mBuild Assets and reinstall site: $((end_time - start_time)) seconds\033[0m"