|
| 1 | +{% if use_github_ci %} |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "{{ branch_name }}*" |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - "{{ branch_name }}*" |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest |
| 16 | + services: |
| 17 | + postgres: |
| 18 | + image: postgres:12.0 |
| 19 | + env: |
| 20 | + POSTGRES_USER: odoo |
| 21 | + POSTGRES_PASSWORD: odoo |
| 22 | + POSTGRES_DB: odoo |
| 23 | + ports: |
| 24 | + - 5432:5432 |
| 25 | + env: |
| 26 | + COVERAGE_INCLUDE: "{% raw %}${{ github.workspace }}/odoo/local-src/*{% endraw %}" |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Fix file ownership |
| 33 | + run: chown -R $(id -u):$(id -g) . |
| 34 | + |
| 35 | + - name: Install Python dependencies |
| 36 | + run: | |
| 37 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 38 | + /github/home/.local/bin/uv pip install -r odoo/requirements.txt pyyaml git+https://github.com/akretion/ak |
| 39 | + |
| 40 | + - name: Build addons paths and fetch dependencies |
| 41 | + id: build_addons |
| 42 | + working-directory: odoo |
| 43 | + run: | |
| 44 | + # 1. Download dependencies |
| 45 | + ak clone && ak build |
| 46 | + |
| 47 | + # 2. Define Base Paths |
| 48 | + # /opt/odoo/addons is the Odoo core inside the OCA CI container |
| 49 | + BASE_PATH="/opt/odoo/addons" |
| 50 | + LOCAL_PATH="$(pwd)/local-src" |
| 51 | + |
| 52 | + # 3. Generate External Paths dynamically |
| 53 | + # List all directories in external-src, distinct them, and join with commas |
| 54 | + # $(pwd) ensures we use absolute paths required by Odoo |
| 55 | + EXTERNAL_PATHS=$(ls -d "$(pwd)/external-src"/* | paste -sd ",") |
| 56 | + |
| 57 | + # 4. Combine them |
| 58 | + FINAL_ADDONS_PATH="$BASE_PATH,$LOCAL_PATH,$EXTERNAL_PATHS" |
| 59 | + |
| 60 | + # 5. Export to GITHUB_ENV |
| 61 | + # ADDONS_DIR is usually just the relative path to your modules for test discovery |
| 62 | + echo "ADDONS_DIR=local-src" >> $GITHUB_ENV |
| 63 | + echo "ADDONS_PATH=$FINAL_ADDONS_PATH" >> $GITHUB_ENV |
| 64 | + |
| 65 | + # Debug print |
| 66 | + echo "Calculated ADDONS_DIR: local-src" |
| 67 | + echo "Calculated ADDONS_PATH: $FINAL_ADDONS_PATH" |
| 68 | + |
| 69 | + - name: Install Odoo addons dependencies |
| 70 | + working-directory: odoo |
| 71 | + run: oca_install_addons |
| 72 | + |
| 73 | + - name: Initialize test database |
| 74 | + working-directory: odoo |
| 75 | + run: oca_init_test_database |
| 76 | + |
| 77 | + - name: Run Odoo tests |
| 78 | + working-directory: odoo |
| 79 | + run: oca_run_tests |
| 80 | + |
| 81 | + - name: Upload coverage to Codecov |
| 82 | + uses: codecov/codecov-action@v4 |
| 83 | + with: |
| 84 | + token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} |
| 85 | + fail_ci_if_error: true |
| 86 | +{% endif %} |
0 commit comments