-
Notifications
You must be signed in to change notification settings - Fork 243
test: added workflow to test post-install patch on fresh site #3903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
8cd2b07
b43f804
81eafe8
97fd3d9
1a0e4da
6b5720c
c971528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Check for merge conflicts before proceeding | ||||||||||||||||||||||||||||||||||||||
| python -m compileall -f "${GITHUB_WORKSPACE}" | ||||||||||||||||||||||||||||||||||||||
| if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}" | ||||||||||||||||||||||||||||||||||||||
| then echo "Found merge conflicts" | ||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| cd ~ || exit | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| echo "Setting Up System Dependencies..." | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| sudo apt update | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| sudo apt remove mysql-server mysql-client | ||||||||||||||||||||||||||||||||||||||
| sudo apt install libcups2-dev redis-server mariadb-client | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Proposed fix-sudo apt remove mysql-server mysql-client
+sudo apt remove mysql-server mysql-client || true📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| install_whktml() { | ||||||||||||||||||||||||||||||||||||||
| wget -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 | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add The Proposed fix- sudo apt install /tmp/wkhtmltox.deb
+ sudo apt install -y /tmp/wkhtmltox.deb📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in function name and missing The function name 🔧 Proposed fix-install_whktml() {
+install_wkhtmltopdf() {
wget -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
+ sudo apt install /tmp/wkhtmltox.deb -y
}
-install_whktml &
+install_wkhtmltopdf &🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| install_whktml & | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in function name and missing The function name has a typo ( Suggested fix-install_whktml() {
+install_wkhtmltopdf() {
wget -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
+ sudo apt install -y /tmp/wkhtmltox.deb
}
-install_whktml &
+install_wkhtmltopdf &📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| wkpid=$! | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in function name and add The function name Proposed fix-install_whktml() {
+install_wkhtmltox() {
wget -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
+ sudo apt install -y /tmp/wkhtmltox.deb
}
-install_whktml &
+install_wkhtmltox &📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| pip install frappe-bench | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| git clone "https://github.com/frappe/frappe" --branch "$BRANCH_TO_CLONE" --depth 1 | ||||||||||||||||||||||||||||||||||||||
| bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| mkdir ~/frappe-bench/sites/test_site | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site/ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| mariadb --host 127.0.0.1 --port 3306 -u root -ptravis -e " | ||||||||||||||||||||||||||||||||||||||
| SET GLOBAL character_set_server = 'utf8mb4'; | ||||||||||||||||||||||||||||||||||||||
| SET GLOBAL collation_server = 'utf8mb4_unicode_ci'; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| CREATE USER 'test_resilient'@'localhost' IDENTIFIED BY 'test_resilient'; | ||||||||||||||||||||||||||||||||||||||
| CREATE DATABASE test_resilient; | ||||||||||||||||||||||||||||||||||||||
| GRANT ALL PRIVILEGES ON \`test_resilient\`.* TO 'test_resilient'@'localhost'; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| FLUSH PRIVILEGES; | ||||||||||||||||||||||||||||||||||||||
| " | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| cd ~/frappe-bench || exit | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| sed -i 's/watch:/# watch:/g' Procfile | ||||||||||||||||||||||||||||||||||||||
| sed -i 's/schedule:/# schedule:/g' Procfile | ||||||||||||||||||||||||||||||||||||||
| sed -i 's/socketio:/# socketio:/g' Procfile | ||||||||||||||||||||||||||||||||||||||
| sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| bench get-app erpnext --branch "$BRANCH_TO_CLONE" --resolve-deps | ||||||||||||||||||||||||||||||||||||||
| bench setup requirements --dev | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| wait $wkpid | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| bench use test_site | ||||||||||||||||||||||||||||||||||||||
| bench start & | ||||||||||||||||||||||||||||||||||||||
| bench reinstall --yes | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential race condition:
Proposed fix: Add a delay or readiness check bench use test_site
bench start &
+
+# Wait for bench to be ready
+sleep 10
+
bench reinstall --yesAlternatively, consider using a more robust readiness check: bench use test_site
bench start &
+
+# Wait for bench to be ready
+until curl -s http://localhost:8000 > /dev/null 2>&1; do
+ echo "Waiting for bench to start..."
+ sleep 2
+done
+
bench reinstall --yes📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+62
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Race condition:
Proposed fix - add a readiness check bench start &
+
+# Wait for the server to be ready
+timeout 60 bash -c 'until curl -s http://localhost:8000 > /dev/null 2>&1; do sleep 2; done'
+
bench reinstall --yes📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Get India Compliance AFTER reinstall (so it's not installed during reinstall) | ||||||||||||||||||||||||||||||||||||||
| bench get-app india_compliance "${GITHUB_WORKSPACE}" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Create an India company BEFORE installing India Compliance | ||||||||||||||||||||||||||||||||||||||
| echo "Creating India Company..." | ||||||||||||||||||||||||||||||||||||||
| cd ~/frappe-bench/sites | ||||||||||||||||||||||||||||||||||||||
| python -c " | ||||||||||||||||||||||||||||||||||||||
| import frappe | ||||||||||||||||||||||||||||||||||||||
| frappe.init('test_site') | ||||||||||||||||||||||||||||||||||||||
| frappe.connect() | ||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||
| sys.path.insert(0, '${GITHUB_WORKSPACE}') | ||||||||||||||||||||||||||||||||||||||
| from india_compliance.tests import setup_post_install_test_data | ||||||||||||||||||||||||||||||||||||||
| setup_post_install_test_data() | ||||||||||||||||||||||||||||||||||||||
| frappe.db.commit() | ||||||||||||||||||||||||||||||||||||||
| " | ||||||||||||||||||||||||||||||||||||||
| cd ~/frappe-bench | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Install India Compliance | ||||||||||||||||||||||||||||||||||||||
| echo "Installing India Compliance..." | ||||||||||||||||||||||||||||||||||||||
| bench --verbose install-app india_compliance | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| bench add-to-hosts | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| echo "Post-install patches test setup complete!" | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Post Install Patches Tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| base_ref: | ||
| type: string | ||
|
|
||
|
|
||
| pull_request: | ||
| paths-ignore: | ||
| - "**.css" | ||
| - "**.js" | ||
| - "**.md" | ||
| - "**.html" | ||
| - "**.csv" | ||
|
|
||
| push: | ||
| branches: [develop, version-14-hotfix, version-14, version-15-hotfix, version-15] | ||
| paths-ignore: | ||
| - "**.css" | ||
| - "**.js" | ||
| - "**.md" | ||
| - "**.html" | ||
| - "**.csv" | ||
| env: | ||
| BRANCH: ${{ inputs.base_ref || github.base_ref || github.ref_name }} | ||
|
|
||
| jobs: | ||
| post-install-tests: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
|
|
||
| name: Post Install Patches | ||
|
|
||
| services: | ||
| mariadb: | ||
| image: mariadb:11.8 | ||
| env: | ||
| MARIADB_ROOT_PASSWORD: 'travis' | ||
| ports: | ||
| - 3306:3306 | ||
| options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | ||
|
|
||
| steps: | ||
| - name: Clone | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.14" | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| check-latest: true | ||
|
|
||
| - name: Add to Hosts | ||
| run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts | ||
|
|
||
| - name: Cache pip | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| ${{ runner.os }}- | ||
|
|
||
| - name: Cache node modules | ||
| uses: actions/cache@v5 | ||
| env: | ||
| cache-name: cache-node-modules | ||
| with: | ||
| path: ~/.npm | ||
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-build-${{ env.cache-name }}- | ||
| ${{ runner.os }}-build- | ||
| ${{ runner.os }}- | ||
|
|
||
| - name: Get yarn cache directory path | ||
| id: yarn-cache-dir-path | ||
| run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
|
|
||
| - uses: actions/cache@v5 | ||
| id: yarn-cache | ||
| with: | ||
| path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
|
|
||
| - name: Install with Post Install Patches | ||
| run: | | ||
| bash ${GITHUB_WORKSPACE}/.github/helper/post_install.sh | ||
| env: | ||
| BRANCH_TO_CLONE: ${{ env.BRANCH }} | ||
|
|
||
| - name: Show bench output | ||
| if: ${{ always() }} | ||
| run: cat ~/frappe-bench/bench_start.log || true | ||
|
Comment on lines
+105
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The workflow tries to display Update -bench start &
+bench start > ~/frappe-bench/bench_start.log 2>&1 &🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,33 +9,7 @@ | |
|
|
||
|
|
||
| def before_tests(): | ||
| frappe.clear_cache() | ||
|
|
||
| if not frappe.db.a_row_exists("Company"): | ||
| today = getdate() | ||
| year = today.year if today.month > 3 else today.year - 1 | ||
|
|
||
| setup_complete( | ||
| { | ||
| "currency": "INR", | ||
| "full_name": "Test User", | ||
| "company_name": "Wind Power LLP", | ||
| "timezone": "Asia/Kolkata", | ||
| "company_abbr": "WP", | ||
| "industry": "Manufacturing", | ||
| "country": "India", | ||
| "fy_start_date": f"{year}-04-01", | ||
| "fy_end_date": f"{year + 1}-03-31", | ||
| "language": "English", | ||
| "company_tagline": "Testing", | ||
| "email": "test@example.com", | ||
| "password": "test", | ||
| "chart_of_accounts": "Standard", | ||
| "company_gstin": "29MUMB22923F1D", | ||
| "default_gst_rate": "18.0", | ||
| "enable_audit_trail": 0, | ||
| } | ||
| ) | ||
| setup_india_company() | ||
|
|
||
| set_default_settings_for_tests() | ||
| create_test_records() | ||
|
|
@@ -47,6 +21,41 @@ def before_tests(): | |
| frappe.enqueue = partial(frappe.enqueue, now=True) | ||
|
|
||
|
|
||
| def setup_india_company(): | ||
| frappe.clear_cache() | ||
|
|
||
| if not frappe.db.a_row_exists("Company"): | ||
| today = getdate() | ||
| year = today.year if today.month > 3 else today.year - 1 | ||
|
|
||
| setup_args = { | ||
| "currency": "INR", | ||
| "full_name": "Test User", | ||
| "company_name": "Wind Power LLP", | ||
| "timezone": "Asia/Kolkata", | ||
| "company_abbr": "WP", | ||
| "industry": "Manufacturing", | ||
| "country": "India", | ||
| "fy_start_date": f"{year}-04-01", | ||
| "fy_end_date": f"{year + 1}-03-31", | ||
| "language": "English", | ||
| "company_tagline": "Testing", | ||
| "email": "test@example.com", | ||
| "password": "test", | ||
| "chart_of_accounts": "Standard", | ||
| "enable_audit_trail": 0, | ||
| "company_gstin": "29MUMB22923F1D", | ||
| "default_gst_rate": "18.0", | ||
| } | ||
|
|
||
| setup_complete(setup_args) | ||
|
|
||
|
Comment on lines
+24
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Count characters in the GSTIN
echo "GSTIN character count:"
echo -n "29MUMB22923F1D" | wc -c
# Find GSTIN_FORMAT regex in the codebase
echo ""
echo "Searching for GSTIN_FORMAT definition:"
rg -n "GSTIN_FORMAT" --type py -B2 -A2
# Find other company_gstin values in tests
echo ""
echo "Searching for other test GSTINs:"
rg -n "company_gstin" --type py -A1 | head -20Repository: resilient-tech/india-compliance Length of output: 5688 🏁 Script executed: #!/bin/bash
# Find validate_gstin function implementation
echo "Finding validate_gstin implementation:"
rg -n "def validate_gstin" --type py -A20
# Also check the GSTIN_FORMATS patterns definition
echo ""
echo "Checking GSTIN_FORMATS patterns:"
rg -n "GSTIN_FORMATS\s*=" --type py -A10Repository: resilient-tech/india-compliance Length of output: 9918 🏁 Script executed: #!/bin/bash
# Find setup_complete function
echo "Finding setup_complete function:"
rg -n "def setup_complete" --type py -A30
# Also check where setup_complete is imported from in tests/__init__.py
echo ""
echo "Checking imports in tests/__init__.py:"
head -30 india_compliance/tests/__init__.pyRepository: resilient-tech/india-compliance Length of output: 939 🏁 Script executed: #!/bin/bash
# Search for setup_wizard in india_compliance
echo "Searching for setup_wizard hooks or overrides in india_compliance:"
rg -n "setup_wizard\|setup_complete" india_compliance --type py -B2 -A2
# Check if validate_gstin is called during company creation
echo ""
echo "Searching for where validate_gstin is called:"
rg -n "validate_gstin\(" --type py | head -20Repository: resilient-tech/india-compliance Length of output: 989 🏁 Script executed: #!/bin/bash
# Check the full setup_wizard.py to see how it integrates
echo "Reading india_compliance/setup_wizard.py:"
cat india_compliance/setup_wizard.pyRepository: resilient-tech/india-compliance Length of output: 3675 Correct the test GSTIN to 15 characters. The GSTIN 🤖 Prompt for AI Agents |
||
|
|
||
| def setup_post_install_test_data(): | ||
| setup_india_company() | ||
| frappe.db.commit() | ||
|
|
||
|
|
||
| def set_default_settings_for_tests(): | ||
| # e.g. set "All Customer Groups" as the default Customer Group | ||
| for key in ("Customer Group", "Supplier Group", "Item Group", "Territory"): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
-yflag toaptcommands to prevent interactive prompts in CI.The
apt removeandapt installcommands will prompt for confirmation, causing the CI workflow to hang indefinitely. Add the-yflag for non-interactive execution.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents