Cortesy @maisim. This commit allow to use docker-in-docker to run tests. Also it will run the tests on python version defined in the PYTHON_VERSION array. The tox.ini file is not needed anymore. Test locally can be run on the user python version, and check against several python version will be done by the CI. Notice the ODOO_RPC_URL environment variable which allow to mock the RPC request to the right url. This tests needs to be run on custom privileged runner. ! Using gitlab runner does not work !
89 lines
2.2 KiB
YAML
89 lines
2.2 KiB
YAML
stages:
|
|
- lint
|
|
- test
|
|
- build
|
|
- release
|
|
|
|
pre-commit:
|
|
image: python
|
|
stage: lint
|
|
only:
|
|
- merge_requests
|
|
before_script:
|
|
- pip install pre-commit
|
|
script:
|
|
- pre-commit run --all --show-diff-on-failure --verbose --color always
|
|
|
|
pytest:
|
|
image:
|
|
name: python:$PYTHON_VERSION
|
|
stage: test
|
|
tags:
|
|
- cie-oow-dind-runner
|
|
only:
|
|
- merge_requests
|
|
- "main"
|
|
services:
|
|
- name: docker:dind
|
|
alias: dind
|
|
variables:
|
|
ODOO_RPC_URL: dind
|
|
DOCKER_HOST: tcp://dind:2375/
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)\%/'
|
|
before_script:
|
|
- pip install poetry
|
|
- export PATH="$HOME/.local/bin:$PATH"
|
|
- poetry install --all-extras
|
|
script:
|
|
- poetry run pytest -vv -x --cov=odoo_openupgrade_wizard
|
|
parallel:
|
|
matrix:
|
|
- PYTHON_VERSION:
|
|
- "3.7"
|
|
- "3.8"
|
|
- "3.9"
|
|
|
|
build:
|
|
stage: build
|
|
image: python:latest
|
|
rules:
|
|
# Do not run this job when a tag is created manually
|
|
- if: $CI_COMMIT_TAG
|
|
when: never
|
|
# Run this job when commits are pushed or merged to the default branch
|
|
# and the commit message contains "Bump to version"
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
|
script:
|
|
- pip install poetry
|
|
- poetry --version
|
|
- poetry build
|
|
- poetry publish --username $PYPI_USER --password $PYPI_TOKEN
|
|
- echo "VERSION=$(poetry version --short)" >> variables.env
|
|
artifacts:
|
|
reports:
|
|
# Use artifacts:reports:dotenv to expose the variables to other jobs
|
|
dotenv: variables.env
|
|
|
|
release:
|
|
stage: release
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
needs:
|
|
- job: build
|
|
artifacts: true
|
|
rules:
|
|
# Do not run this job when a tag is created manually
|
|
- if: $CI_COMMIT_TAG
|
|
when: never
|
|
# Run this job when commits are pushed or merged to the default branch
|
|
# and the commit message contains "Bump to version"
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
|
script:
|
|
- echo "running release_job for $VERSION"
|
|
release:
|
|
name: "$VERSION"
|
|
description: "$CI_COMMIT_DESCRIPTION"
|
|
tag_name: "$VERSION"
|
|
ref: "$CI_COMMIT_SHA"
|