Skip to content
Snippets Groups Projects
.gitlab-ci.yml 7.15 KiB
Newer Older
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
include:
  - file: python3-lint-needs.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: python-package.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: docker-build.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: deploy-doc.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: prettier.gitlab-ci.yaml
    project: xcg/ci-templates
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  - file: yamllint.gitlab-ci.yaml
    project: xcg/ci-templates
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  - template: "Workflows/Branch-Pipelines.gitlab-ci.yml"
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

variables:
  DOCKER_IMAGE: quay.orus.io/xcgd/odoo_scripts
  # do not use $TEMP_IMAGE_BASENAME, it will not be correctly replaced by GitLab
  TEMP_IMAGE: quay.orus.io/xcgd/odoo_scripts:hg-${CI_COMMIT_HG_SHA}
yamllint:
  needs: []
# build a temporary image for doc and tests
build-docker-image:
  needs: []
  stage: build
  variables:
    TAG_COMMIT_REF_SLUG: "no"
    TAG_BRANCH: "no"
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

pylint:
  needs:
    - job: build-docker-image
  image: $TEMP_IMAGE
  variables:
    PYLINT_FILES: odoo_scripts doc tests
mypy:
  needs:
    - job: build-docker-image
  image: $TEMP_IMAGE
  script:
    - python3 -m pip install mypy types-PyYAML types-psycopg2 types-python-dateutil
    - mypy odoo_scripts tests
unittest:
  needs: []
  stage: test
    - tox --workdir=.cache/tox --parallel all -e
      py36,py37,py38,py39,py310,py311,py312,coverage-report,coverage-xml
  artifacts:
    when: always
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml
      junit: report.py36.xml
    paths:
      - report.py36.xml
  coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
  cache:
    paths:
      - .cache
  variables:
    PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
import_jsonrpc_odoo11_test-focal:
  stage: test
    name: quay.orus.io/odoo/odoo:11.0-focal
    entrypoint: [""]
  services:
    - name: postgres:12-alpine
      command: ["-c", "fsync=off"]
      alias: db
  variables:
    POSTGRES_USER: odoo
    POSTGRES_HOST_AUTH_METHOD: trust
  before_script:
    - python3 -m pip show pip setuptools
    - python3 -m pip install pip>10
    - &install_modules $CI_PROJECT_DIR/start --db_host=db -d test_setup
      --max-cron-threads=0 --without-demo=all --data-dir /var/lib/odoo --init base
      --stop-after-init
    # install current version as this is the one tested, not the one in the image
    - python3 -m pip install --disable-pip-version-check --no-cache-dir --upgrade
      $CI_PROJECT_DIR
    # restart odoo with installed modules and use it in background
    - $CI_PROJECT_DIR/start --db_host=db -d test_setup --max-cron-threads=0 --data-dir
      /var/lib/odoo &
    - sleep 3
    # then test the setup files
    - import_jsonrpc -v --host localhost --password admin -d test_setup --protocol
      jsonrpc -p 8069 --directory tests/import
    - import_jsonrpc -v --host localhost --password admin -d test_setup --protocol
      jsonrpc -p 8069 --file tests/context_import/res.company.csv --context test=value
    - import_jsonrpc -v --host localhost --password admin -d test_setup --protocol
      jsonrpc -p 8069 --directory tests/import_emptyyaml --delimiter ";"
    - import_sql -v --host postgres --user odoo --database test_setup --directory
      tests/import_sql
    # clean up background process
    - pkill --echo --full /usr/bin/python3
    - pkill --echo --full zsh
import_jsonrpc_odoo11_test:
  extends: import_jsonrpc_odoo11_test-focal
  needs:
    - job: create_package
      artifacts: true
    name: quay.orus.io/odoo/odoo:11.0-bionic
  before_script:
    - export PATH=$HOME/.local/bin:$PATH
    - python3 -m pip install dist/*.whl
    - *install_modules
import_base_import_odoo11_test:
  extends: import_jsonrpc_odoo11_test
  script:
    # restart odoo with installed modules and use it in background
    - $CI_PROJECT_DIR/start --db_host=db -d test_setup --max-cron-threads=0 --data-dir
      /var/lib/odoo &
    - sleep 3
    # then test the setup files
    - import_base_import -v --host localhost --password admin -d test_setup --protocol
      jsonrpc -p 8069 --directory tests/import
    - import_sql -vv --host postgres --user odoo --database test_setup --directory
      tests/import_sql
    # clean up background process
    - pkill --echo --full /usr/bin/python3
    - pkill --echo --full zsh
  extends: import_jsonrpc_odoo11_test-focal
    name: quay.orus.io/odoo/odoo:13.0
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo13

Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
import_jsonrpc_odoo14_test:
  extends: import_jsonrpc_odoo11_test-focal
  image:
    name: quay.orus.io/odoo/odoo:14.0
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo14

import_jsonrpc_odoo15_test:
  extends: import_jsonrpc_odoo11_test-focal
    name: quay.orus.io/odoo/odoo:15.0
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo15

import_jsonrpc_odoo16_test:
  extends: import_jsonrpc_odoo11_test-focal
  image:
    name: quay.orus.io/odoo/odoo:16.0
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo16

docker_build_copy_test:
  needs:
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - job: build-docker-image
  stage: test
  image: $TEMP_IMAGE
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - docker_build_copy
    - docker_build_clean
  # done in test stage to be able to use the built image
  stage: test
  needs:
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - job: build-docker-image
  image: $TEMP_IMAGE
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
      - doc/_build
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - apk add make
    - pip3 install hg-evolve .[doc]
    - cd doc
    - for language in en fr ; do make LANGUAGE=$language
      BUILDDIRSUFFIX=/$CI_COMMIT_HG_BRANCH html ; done
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - job: build-documentation
      artifacts: true
  rules:
    - if: $CI_COMMIT_BRANCH =~ /^branch\/.*/
  extends: build-docker-image
  stage: deploy
  needs:
    - job: docker_build_copy_test
    - job: import_jsonrpc_odoo11_test
    - job: import_jsonrpc_odoo11_test-focal
    - job: import_jsonrpc_odoo13_test
    - job: import_base_import_odoo11_test
  variables:
    TAG_LATEST: branch/default
  script:
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    - DOCKER_BASE_IMAGE_NAME="$TEMP_IMAGE" tag-img
    - TAG_COMMIT_SHA="no" DOCKER_BASE_IMAGE_NAME="$TEMP_IMAGE"
      DOCKER_IMAGE="xcgd/odoo_scripts" tag-img
release_job:
  stage: deploy
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - publish_package
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "running release_job"
    - export EXTRA_DESCRIPTION="test"
  release:
    name: "$CI_COMMIT_TAG"
    description: "Created using the release-cli $EXTRA_DESCRIPTION"
    tag_name: "$CI_COMMIT_TAG"
    ref: "$CI_COMMIT_TAG"
    # TODO find a way to automatically add the packages and changelog to the release