diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 00000000..658d2ce2 --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -0,0 +1,166 @@ +name: testRigor E2E Tests + +on: + push: + branches: + - "**" + +jobs: + e2e: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:13 + env: + POSTGRES_DB: odoo + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoo + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U odoo -d odoo" + --health-interval=10s + --health-timeout=5s + --health-retries=12 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Show Python being used + run: | + which python + python --version + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget git python3-dev libxml2-dev libxslt1-dev zlib1g-dev \ + libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libpq-dev + + - name: Install Odoo dependencies (into this Python) + run: | + python -m pip install --upgrade pip wheel + python -m pip install -r https://raw.githubusercontent.com/odoo/odoo/14.0/requirements.txt + + - name: Download Odoo 14 + run: | + git clone --depth 1 --branch 14.0 https://github.com/odoo/odoo.git odoo-14.0 + + - name: Install repository’s local HRMS modules (if present) + run: | + mkdir -p odoo-14.0/custom_addons + shopt -s nullglob + cp -r hrms_* odoo-14.0/custom_addons/ || true + + - name: Fetch OpenHRMS upstream addons (branch 14.0) + run: | + mkdir -p odoo-14.0/custom_addons + rm -rf odoo-14.0/custom_addons/openhrms + git clone --depth 1 --branch 14.0 https://github.com/CybroOdoo/OpenHRMS.git odoo-14.0/custom_addons/openhrms + + - name: Create Odoo Database (if not exists) + env: + PGPASSWORD: odoo + run: | + psql -h localhost -U odoo -c "CREATE DATABASE odoo;" || echo "DB already exists" + + - name: Write Odoo config + run: | + cat > odoo.conf <<'EOF' + [options] + addons_path = odoo-14.0/addons,odoo-14.0/custom_addons,odoo-14.0/custom_addons/openhrms + db_host = localhost + db_port = 5432 + db_user = odoo + db_password = odoo + xmlrpc_port = 8080 + log_level = info + admin_passwd = admin + EOF + + # Install core/base first so subsequent installs are faster/clean + - name: Initialize base (headless) + run: | + python odoo-14.0/odoo-bin -c odoo.conf -d odoo -i base --without-demo=all --stop-after-init + + # Install a curated set of OpenHRMS addons (skip known-problematic ones) + - name: Pre-install OpenHRMS addons (headless) + env: + MODS: >- + hr + hr_contract + hr_holidays + hr_attendance + hr_org_chart + hrms_employee_updation + hr_resignation + hr_payroll_community + hr_payroll_account_community + run: | + # Convert whitespace list to comma-separated for -i + CSV_MODS=$(echo "${MODS}" | tr -s '[:space:]' ',' | sed 's/^,\|,$//g') + echo "Installing addons: ${CSV_MODS}" + python odoo-14.0/odoo-bin -c odoo.conf -d odoo -i "${CSV_MODS}" --without-demo=all --stop-after-init + + - name: Start Odoo server (log to file) + run: | + # Start without -i; modules are already installed + python odoo-14.0/odoo-bin -c odoo.conf -d odoo > odoo.log 2>&1 & + echo $! > odoo.pid + sleep 5 + echo "Odoo PID: $(cat odoo.pid)" + + - name: Wait for Odoo to be ready + run: | + for i in {1..60}; do # up to ~5 minutes + if curl -fsS http://localhost:8080/web/login | grep -qi "Odoo"; then + echo "Odoo is up!" + exit 0 + fi + echo "Waiting for Odoo..." + sleep 5 + done + echo "Odoo did not start in time." + echo "==== Last 200 lines of odoo.log ====" + tail -n 200 odoo.log || true + exit 1 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install testRigor CLI + run: npm install -g testrigor-cli + + - name: Show testRigor CLI version + run: testrigor --version + + - name: Run testRigor E2E tests + run: > + testrigor test-suite run + ${{ vars.OPENHRMS_SUITE_ID }} + --token ${{ secrets.OPENHRMS_TOKEN }} + --localhost + --url http://localhost:8080 + --junit-report-save-path ./testrigor-report.xml + + - name: Upload testRigor report + if: always() + uses: actions/upload-artifact@v4 + with: + name: testrigor-report + path: ./testrigor-report.xml + + - name: Upload Odoo logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: odoo-logs + path: ./odoo.log