stages: - lint - test - build - e2e - notify variables: ODOO_IMAGE: odoo:17.0 POSTGRES_HOST: postgres POSTGRES_PORT: 5432 POSTGRES_DB: odoo_test POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo TEMPLATE_DATABASE: odoo_primed # ================================================================ # LINT & CODE QUALITY # ================================================================ pylint-odoo: stage: lint image: $ODOO_IMAGE script: - pip install --no-cache-dir pylint-odoo - pylint-odoo --rcfile=.pylintrc-odoo addons/itsulu_blog_publisher allow_failure: true black: stage: lint image: $ODOO_IMAGE script: - pip install --no-cache-dir black - black --check addons/itsulu_blog_publisher allow_failure: true # ================================================================ # UNIT TESTS (TDD) & BDD # ================================================================ unit_tests: stage: test image: $ODOO_IMAGE services: - name: postgres:15 alias: postgres command: - postgres - -c - fsync=off - -c - shared_buffers=512MB before_script: - export PGPASSWORD=$POSTGRES_PASSWORD # Create primed template database - createdb -h $POSTGRES_HOST -U $POSTGRES_USER $TEMPLATE_DATABASE # Install Odoo + modules into template DB - | odoo -d $TEMPLATE_DATABASE \ -i base,website,website_blog,mail,itsulu_blog_publisher \ --addons-path=/usr/lib/python3/dist-packages/odoo/addons,$CI_PROJECT_DIR/addons \ --without-demo=all --stop-after-init --db_host=$POSTGRES_HOST --db_user=$POSTGRES_USER \ --db_password=$POSTGRES_PASSWORD # Install test dependencies - pip install --no-cache-dir pytest pytest-odoo pytest-bdd pytest-cov pytest-html script: - export PGPASSWORD=$POSTGRES_PASSWORD # Clone template DB for test isolation - createdb -h $POSTGRES_HOST -U $POSTGRES_USER -T $TEMPLATE_DATABASE $POSTGRES_DB # Run TDD, BDD, and performance tests - | python3 -m pytest \ addons/itsulu_blog_publisher/tests \ -v \ --odoo-database=$POSTGRES_DB \ --cov=addons/itsulu_blog_publisher \ --cov-report=term-missing \ --cov-report=html \ --cov-report=xml \ --junitxml=report.xml \ --html=report-unit.html \ --self-contained-html artifacts: when: always reports: junit: report.xml coverage_report: coverage_format: cobertura path: coverage.xml paths: - htmlcov/ - report-unit.html expire_in: 30 days coverage: '/^TOTAL.*\s+(\d+%)$/' # ================================================================ # E2E TESTS (ITSulu K8s Cluster) # ================================================================ e2e_tests: stage: e2e image: bitnami/kubectl:latest needs: [build_image] before_script: - | mkdir -p ~/.kube echo "$KUBE_CONFIG" | base64 -d > ~/.kube/config script: # Create ephemeral E2E test job on K8s cluster - | TIMESTAMP=$(date +%s) JOB_NAME="blog-publisher-e2e-test-${TIMESTAMP}" kubectl apply -f - <