Files
tryton/.gitlab-ci.yml
T

418 lines
10 KiB
YAML

workflow:
rules:
- if: $CI_COMMIT_BRANCH =~ /^topic\/.*/ && $CI_PIPELINE_SOURCE == "push"
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/
when: never
- when: always
stages:
- preparation
- check
- test
- build
variables:
TMPDIR: /tmp
packages:
stage: preparation
rules:
- when: always
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/ci
variables:
DOC_BASE_URL: ${CI_PROJECT_DIR}/docs
script:
- .gitlab-scripts/generate-packages.sh packages
artifacts:
paths:
- packages/
expire_in: 1 week
documentation:
stage: preparation
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/sphinxdoc/sphinx
script:
- .gitlab-scripts/generate-doc.sh docs
- find docs -type f -not -name 'objects.inv' -delete
- find docs -type d -empty -delete
artifacts:
paths:
- docs/
expire_in: 1 week
rules:
- changes:
- "**/*/doc/**/*"
- "**/*/tryton.cfg"
- "**/*/CHANGELOG"
- "doc/**/*"
.check:
stage: check
needs: []
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/ci
.check-doc:
extends: .check
needs:
- documentation
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/sphinxdoc/sphinx
variables:
DOC_BASE_URL: ${CI_PROJECT_DIR}/docs
DOC_DIR: doc
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install setuptools
- pip install -r "${PACKAGE}/${DOC_DIR}/requirements-doc.txt"
- pip install sphinx-lint rstcheck[sphinx]
script:
- cd "${PACKAGE}"
- python -m sphinx -T -E -W -n -b html -D html_theme_options.navigation_with_keys=False ${DOC_DIR} _build/html
- python -m sphinxlint ${DOC_DIR}
- rstcheck --recursive ${DOC_DIR}
- |
if [ "${CHECK_LINK}" ]; then
python -m sphinx -T -E -W -n -b linkcheck ${DOC_DIR} _build;
fi
rules:
- if: $CI_COMMIT_TAG == null
changes:
- ${PACKAGE}/${DOC_DIR}/**/*
- ${PACKAGE}/tryton.cfg
- ${PACKAGE}/CHANGELOG
when: on_success
- when: never
.check-doc-readme:
extends: .check-doc
script:
- python -m sphinxlint README.rst
- rstcheck README.rst
rules:
- if: $CI_COMMIT_TAG == null
changes:
- README.rst
when: on_success
- when: never
check-doc:
extends: .check-doc
variables:
PACKAGE: doc
DOC_DIR: .
rules:
- if: $CI_COMMIT_TAG == null
changes:
- ${PACKAGE}/**/*
when: on_success
- when: never
.check-code:
extends: .check
before_script:
- .gitlab-scripts/doctest2python.py
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
changes:
- "**/*.py"
- "**/tests/*.rst"
when: always
- when: never
check-flake8:
extends: .check-code
script:
- flake8 --exclude 'cookiecutter*'
check-isort:
extends: .check-code
script:
- isort --multi-line VERTICAL_GRID --check --diff --skip-glob 'cookiecutter*' .
check-dist:
stage: check
needs:
- packages
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/ci
script:
- twine check packages/*
check-eslint:
extends: .check
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:lts
variables:
NODE_CACHE_DIR: "$CI_PROJECT_DIR/.cache/npm"
cache:
paths:
- .cache/npm
before_script:
- sh .gitlab-scripts/bower_allow_root.sh
script:
- cd sao
- npm install --cache ${NODE_CACHE_DIR} --unsafe-perm --legacy-peer-deps
- npm run check
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
changes:
- "sao/**/*.js"
when: always
- when: never
check-ci-modules:
extends: .check
script:
- python .gitlab-scripts/generate-ci.py "${TMPDIR}/gitab-ci-modules.yml"
- cmp .gitlab-ci-modules.yml "${TMPDIR}/gitab-ci-modules.yml"
check-cookiecutter-module:
extends: .check
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install cookiecutter
script:
- cookiecutter --no-input cookiecutter-module -o "${TMPDIR}"
- flake8 "${TMPDIR}/my_module"
- isort --multi-line VERTICAL_GRID --check --diff "${TMPDIR}/my_module"
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
changes:
- cookiecutter-module/**/*
when: always
- when: never
check-template-modules:
extends: .check
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install cookiecutter
script:
- .gitlab-scripts/check-template-modules.sh
check-account-chart:
extends: .check
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine
before_script:
- apk add --no-cache libxslt
script:
- .gitlab-scripts/check-account-chart.sh
rules:
- if: $CI_COMMIT_TAG == null
changes:
- modules/*/localize.xsl
- modules/account/account_chart*.xml
- modules/account_be/account_be*.xml
- modules/account_be/tax_be*.xml
- modules/account_es/account*.xml
- modules/account_es/tax*.xml
- modules/account_syscohada/account_syscohada*.xml
when: on_success
- when: never
.test:
stage: test
rules:
- if: $CI_COMMIT_TAG == null
changes:
- ${PACKAGE}/**/*
when: on_success
- if: '$CI_COMMIT_TAG =~ $TAG_PATTERN'
when: on_success
- when: never
.test-tox:
extends: .test
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:${PYTHON_VERSION}
variables:
PIP_FIND_LINKS: file://${CI_PROJECT_DIR}/packages/
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install tox
script:
- tox -e "py${PYTHON_VERSION/./}" -c "${PACKAGE}" -- -v --output-file junit.xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
junit: ${PACKAGE}/junit.xml
coverage_report:
coverage_format: cobertura
path: ${PACKAGE}/coverage.xml
parallel:
matrix:
- PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
.test-db:
extends: .test-tox
variables:
DB_CACHE: "${TMPDIR}/cache"
script:
- tox -e "py${PYTHON_VERSION/./}-${DATABASE}" -c "${PACKAGE}" -- -v --output-file junit.xml
.test-sqlite:
extends: .test-db
variables:
DATABASE: sqlite
.test-postgresql:
extends: .test-db
variables:
DATABASE: postgresql
DB_CACHE: postgresql://
POSTGRESQL_URI: postgresql://postgres@postgresql:5432/
POSTGRES_HOST_AUTH_METHOD: trust
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/postgres
alias: postgresql
command: ["-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
parallel:
matrix:
- PYTHON_VERSION: ["3.13"]
.test-postgis:
extends: .test-db
variables:
DATABASE: postgis
POSTGIS_URI: postgis://postgres@postgis:5432/
POSTGRES_HOST_AUTH_METHOD: trust
script:
- tox -e "py${PYTHON_VERSION/./}" -c "${PACKAGE}" -- -v --output-file junit.xml
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/postgis/postgis
alias: postgis
command: ["-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
.test-npm:
extends: .test
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:lts
variables:
NODE_CACHE_DIR: "$CI_PROJECT_DIR/.cache/npm"
cache:
paths:
- .cache/npm
before_script:
- sh .gitlab-scripts/bower_allow_root.sh
script:
- cd "${PACKAGE}"
- npm -s install --cache ${NODE_CACHE_DIR} --unsafe-perm --legacy-peer-deps
- npm test
artifacts:
reports:
junit: ${PACKAGE}/_build/test-reports/*.xml
check-doc-trytond:
extends: .check-doc
variables:
PACKAGE: trytond
check-trytond-rng:
extends: .check
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install rnc2rng
script:
- python trytond/setup.py update_rng
- |
if [ `hg status trytond| wc -l` -ne 0 ]; then
false
fi
rules:
- changes:
- trytond/**/*.rnc
- trytond/**/*.rng
test-trytond-sqlite:
extends: .test-sqlite
variables:
PACKAGE: trytond
TAG_PATTERN: '/^trytond-.*/'
test-trytond-postgresql:
extends: .test-postgresql
variables:
PACKAGE: trytond
TAG_PATTERN: '/^trytond-.*/'
parallel:
matrix:
- PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
check-doc-trytond-gis:
extends: .check-doc
variables:
PACKAGE: trytond-gis
test-trytond-gis-postgis:
extends: .test-postgis
variables:
PACKAGE: trytond-gis
TAG_PATTERN: '/^trytond-gis-.*/'
check-doc-proteus:
extends: .check-doc
variables:
PACKAGE: proteus
test-proteus:
extends: .test-tox
variables:
PACKAGE: proteus
TAG_PATTERN: '/^proteus-.*/'
check-doc-tryton:
extends: .check-doc
variables:
PACKAGE: tryton
test-tryton:
extends: .test-tox
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/tryton-test:${PYTHON_VERSION}
variables:
PACKAGE: tryton
TAG_PATTERN: '/^tryton-.*/'
test-sao:
extends: .test-npm
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/sao-test
variables:
PACKAGE: sao
TAG_PATTERN: '/^sao-.*/'
test-demo:
stage: test
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.8
variables:
TRYTOND_DATABASE__PATH: "$TMPDIR"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip/http-v2
before_script:
- pip install packages/trytond* packages/proteus*
script:
- touch "${TRYTOND_DATABASE__PATH}/demo.sqlite"
- echo "admin" > "${TMPDIR}/password"
- TRYTONPASSFILE="${TMPDIR}/password" trytond-admin --database demo --all --email admin@example.com
- python -m demo --database demo
rules:
- changes:
- demo/**/*
- modules/{account,account_invoice,account_payment,account_statement,company,country,currency,party,product,production,production_routing,production_work,project,purchase,sale,stock,timesheet}/**/*
include: '.gitlab-ci-modules.yml'