Skip to content
Snippets Groups Projects
.gitlab-ci.yml 8.97 KiB
Newer Older
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
include:
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  - file: python3-ruff.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: python-pylint.gitlab-ci.yaml
  - file: python-package.gitlab-ci.yaml
    project: xcg/ci-templates
  - file: docker-build.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:
  TEMP_IMAGE_BASENAME: ${CI_REGISTRY_IMAGE}/ci
  TEMP_IMAGE: ${CI_REGISTRY_IMAGE}/ci:ci-pipeline-${CI_PIPELINE_ID}
  TAG_COMMIT_SHA: "no"
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
ruff:
# build a temporary image for doc and tests
build-docker-image:
  needs:
    - job: create_package
      artifacts: true
  stage: build
  variables:
    TAG_COMMIT_REF_SLUG: "no"
    TAG_BRANCH: "no"
    TAG_PIPELINE: "yes"
    DOCKER_IMAGE: $TEMP_IMAGE_BASENAME
    TAG_TAG: "no"
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  extends: .pylint
  needs:
    - job: build-docker-image
  image: $TEMP_IMAGE
  variables:
    PYLINT_FILES: odoo_scripts doc tests
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  before_script:
    # list all non empty optional dependencies
    - pip install ".[doc,docker,import_sql,import_base_import]"
    - !reference [.pylint, before_script]
mypy:
  needs:
    - job: build-docker-image
  image: $TEMP_IMAGE
  script:
    - python3 -m pip install mypy types-PyYAML types-psycopg2 types-python-dateutil
      types-requests build twine ".[docker]"
    - mypy odoo_scripts tests
  rules: !reference [pylint, rules]

prettier:
  rules: !reference [pylint, rules]

yamllint:
  rules: !reference [pylint, rules]
unittest:
  needs: []
  stage: test
    - tox --workdir=.cache/tox --parallel all -e
      36,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
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  needs:
    - job: create_package
      artifacts: true
    name: quay.orus.io/odoo/odoo:11.0.git20230705.01717dc-20.04.3
    entrypoint: [""]
  services:
    - name: postgres:12-alpine
      command: ["-c", "fsync=off"]
      alias: db
  variables:
    POSTGRES_USER: odoo
    POSTGRES_HOST_AUTH_METHOD: trust
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    ODOO_DATA_DIR: /var/lib/odoo
  before_script:
    - python3 -m pip show pip setuptools
    - export PATH=$HOME/.local/bin:$PATH
    - python3 -m pip install pip>10
    # install current version as this is the one tested, not the one in the image
    - python3 -m pip install dist/*.whl
    - &install_modules $CI_PROJECT_DIR/start --db_host=db -d test_setup
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
      --max-cron-threads=0 --without-demo=all --data-dir $ODOO_DATA_DIR --init base
      --stop-after-init
    # restart odoo with installed modules and use it in background
    - start --db_host=db -d test_setup --max-cron-threads=0 --data-dir $ODOO_DATA_DIR &
    - process_to_kill_pid=$!
    - 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
    - kill $process_to_kill_pid
import_jsonrpc_odoo11_test:
  extends: import_jsonrpc_odoo11_test-focal
    name: quay.orus.io/odoo/odoo:11.0.git20230705.01717dc-18.04.2
  before_script:
    - export PATH=$HOME/.local/bin:$PATH
    - python3 -m pip install pip>10
    # specific for 3.6: need pre compiled 3.6 backports-datetime-fromisoformat
    - pip install
      --index-url=https://gitlab-ci-token:$CI_JOB_TOKEN@orus.io/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
      backports-datetime-fromisoformat
    # install current version as this is the one tested, not the one in the image
    - python3 -m pip install dist/*.whl
    # install modules
    - *install_modules
import_base_import_odoo11_test:
  extends: import_jsonrpc_odoo11_test
  script:
    # restart odoo with installed modules and use it in background
    - start --db_host=db -d test_setup --max-cron-threads=0 --data-dir /var/lib/odoo &
    - process_to_kill_pid=$!
    - 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
    - kill $process_to_kill_pid
  extends: import_jsonrpc_odoo11_test-focal
    name: quay.orus.io/odoo/odoo:13.0.git20230608.038354c-2
    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.git20230227.439095d-2
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo14

import_jsonrpc_odoo15_test:
  extends: import_jsonrpc_odoo11_test-focal
    name: quay.orus.io/odoo/odoo:15.0.git20230710.a70cbd5-3
    entrypoint: [""]
  variables:
    ODOO_TYPE: odoo15
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    ODOO_DATA_DIR: /var/opt/odoo
import_jsonrpc_odoo16_test:
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  extends: import_jsonrpc_odoo15_test
  image:
    name: quay.orus.io/odoo/odoo:16.0.20240826-3
    entrypoint: [""]
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
  services:
    - name: postgres:15-alpine
      command: ["-c", "fsync=off"]
      alias: db
  variables:
    ODOO_TYPE: odoo16

import_jsonrpc_odoo17_test:
  extends: import_jsonrpc_odoo15_test
  image:
    name: quay.orus.io/odoo/odoo:17.0.git20240411.1a1c5907-1
  variables:
    ODOO_TYPE: odoo17

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
    # shell tests for colorize/analyse
    - ./shell_tests.zsh
  # 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
  stage: deploy
  script:
    - mkdir public
    - cp -Lr doc/_build/html/fr/$CI_COMMIT_HG_BRANCH public/fr
    - cp -Lr doc/_build/html/en/$CI_COMMIT_HG_BRANCH public/en
    - |
      cat > public/_redirects <<EOF
      / /fr/ 302
      EOF
  artifacts:
    paths:
      - public
    - if: "$CI_COMMIT_HG_TOPIC"
      when: never
    - if: $CI_COMMIT_HG_BRANCH == "default"
  extends: build-docker-image
  stage: deploy
  needs:
    - job: build-docker-image
    - 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:
    - DOCKER_BASE_IMAGE_NAME="$TEMP_IMAGE" DOCKER_IMAGE="${CI_REGISTRY_IMAGE}" tag-img
    - DOCKER_BASE_IMAGE_NAME="$TEMP_IMAGE" DOCKER_IMAGE="xcgd/odoo_scripts" tag-img
  rules: !reference [publish_package, rules]
  stage: deploy
  image: $TEMP_IMAGE
    - job: publish_package
    - job: build-docker-image
  rules:
    - if: $CI_COMMIT_TAG
  script:
    # Go back just before the tag
    - hg up .~1
    - towncrier build --version=$CI_COMMIT_TAG --draft > changes
    - echo "DESCRIPTION='$(cat changes)'" >> variables.env
  artifacts:
    reports:
      dotenv: variables.env

release_job:
  stage: !reference [prepare_job, stage]
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - job: prepare_job
      artifacts: true
      optional: true
  rules: !reference [prepare_job, rules]
  variables:
    GIT_STRATEGY: none
  script:
    - echo "running release_job"
  release:
    name: "$CI_COMMIT_TAG"
    description: "$DESCRIPTION"
    tag_name: "$CI_COMMIT_TAG"
    ref: "$CI_COMMIT_TAG"
    # TODO find a way to automatically add the packages to the release (need a valid generic URL)