Merge branch 'update_ci' into 'main'
New CI to auto build and publish See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!51
This commit is contained in:
commit
e5921fe4c7
101
.gitlab-ci.yml
101
.gitlab-ci.yml
|
|
@ -2,27 +2,59 @@ stages:
|
||||||
- lint
|
- lint
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
|
- publish
|
||||||
- release
|
- release
|
||||||
|
|
||||||
pre-commit:
|
pre-commit:
|
||||||
image: python
|
image: python
|
||||||
stage: lint
|
stage: lint
|
||||||
only:
|
rules:
|
||||||
- merge_requests
|
# Run only if merge request
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||||
|
# Run if commit on default branch
|
||||||
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
before_script:
|
before_script:
|
||||||
- pip install pre-commit
|
- pip install pre-commit
|
||||||
script:
|
script:
|
||||||
- pre-commit run --all --show-diff-on-failure --verbose --color always
|
- pre-commit run --all --show-diff-on-failure --verbose --color always
|
||||||
|
|
||||||
|
check_version:
|
||||||
|
stage: lint
|
||||||
|
image: python:latest
|
||||||
|
rules:
|
||||||
|
# Run if commit that start with a version number is pushed
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+.*/
|
||||||
|
before_script:
|
||||||
|
- pip install poetry
|
||||||
|
- poetry --version
|
||||||
|
script:
|
||||||
|
# Ensure tag is the same as the program version
|
||||||
|
- test $(poetry version --short) = $CI_COMMIT_TAG
|
||||||
|
|
||||||
|
check_changelog:
|
||||||
|
stage: lint
|
||||||
|
image: python:latest
|
||||||
|
rules:
|
||||||
|
# Run if commit that start with a version number is pushed
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
|
||||||
|
before_script:
|
||||||
|
- pip install poetry
|
||||||
|
- poetry --version
|
||||||
|
script:
|
||||||
|
# Ensure change log is completed correctly
|
||||||
|
- cat CHANGES.rst | grep $CI_COMMIT_TAG
|
||||||
|
|
||||||
pytest:
|
pytest:
|
||||||
image:
|
image:
|
||||||
name: python:$PYTHON_VERSION
|
name: python:$PYTHON_VERSION
|
||||||
stage: test
|
stage: test
|
||||||
tags:
|
tags:
|
||||||
- cie-oow-dind-runner
|
- cie-oow-dind-runner
|
||||||
only:
|
rules:
|
||||||
- merge_requests
|
# Run if merge request
|
||||||
- "main"
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||||
|
# Run if commit on default branch
|
||||||
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
services:
|
services:
|
||||||
- name: docker:dind
|
- name: docker:dind
|
||||||
alias: dind
|
alias: dind
|
||||||
|
|
@ -49,40 +81,49 @@ build:
|
||||||
stage: build
|
stage: build
|
||||||
image: python:latest
|
image: python:latest
|
||||||
rules:
|
rules:
|
||||||
# Do not run this job when a tag is created manually
|
# Run if merge request
|
||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||||
when: never
|
# Run if commit on default branch
|
||||||
# Run this job when commits are pushed or merged to the default branch
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
# and the commit message contains "Bump to version"
|
# Run if commit that start with a version number is pushed
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+.*/
|
||||||
script:
|
before_script:
|
||||||
- pip install poetry
|
- pip install poetry
|
||||||
- poetry --version
|
- poetry --version
|
||||||
|
script:
|
||||||
- poetry build
|
- poetry build
|
||||||
- poetry publish --username $PYPI_USER --password $PYPI_TOKEN
|
|
||||||
- echo "VERSION=$(poetry version --short)" >> variables.env
|
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
untracked: true
|
||||||
# Use artifacts:reports:dotenv to expose the variables to other jobs
|
paths:
|
||||||
dotenv: variables.env
|
- dist/
|
||||||
|
|
||||||
|
publish:
|
||||||
|
stage: publish
|
||||||
|
image: python:latest
|
||||||
|
rules:
|
||||||
|
# Run if commit that start with a version number is pushed
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+.*/
|
||||||
|
before_script:
|
||||||
|
- pip install poetry
|
||||||
|
- poetry --version
|
||||||
|
- ls -l dist
|
||||||
|
# Uncomment for testing build publication on test.pypi.org
|
||||||
|
#- poetry config repo.pypitest https://test.pypi.org/legacy/
|
||||||
|
script:
|
||||||
|
- poetry publish --skip-existing --username $PYPI_USER --password $PYPI_TOKEN
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||||
needs:
|
|
||||||
- job: build
|
|
||||||
artifacts: true
|
|
||||||
rules:
|
rules:
|
||||||
# Do not run this job when a tag is created manually
|
# Run only for a patch, minor or major release
|
||||||
- if: $CI_COMMIT_TAG
|
# This avoid creating a release for alpha, beta, or other special
|
||||||
when: never
|
# releases
|
||||||
# Run this job when commits are pushed or merged to the default branch
|
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
|
||||||
# and the commit message contains "Bump to version"
|
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^Bump to version.+/
|
|
||||||
script:
|
script:
|
||||||
- echo "running release_job for $VERSION"
|
- echo "running release_job for $CI_COMMIT_TAG"
|
||||||
release:
|
release:
|
||||||
name: "$VERSION"
|
name: "$CI_COMMIT_TAG"
|
||||||
description: "$CI_COMMIT_DESCRIPTION"
|
description: "Change log here: ${CI_PROJECT_URL}/-/blob/main/CHANGES.rst"
|
||||||
tag_name: "$VERSION"
|
tag_name: "$CI_COMMIT_TAG"
|
||||||
ref: "$CI_COMMIT_SHA"
|
ref: "$CI_COMMIT_SHA"
|
||||||
|
|
|
||||||
0
CHANGES.rst
Normal file
0
CHANGES.rst
Normal file
35
DEVELOP.md
35
DEVELOP.md
|
|
@ -96,12 +96,43 @@ If you add new dependencies, you have to:
|
||||||
|
|
||||||
- run the following command in your virtualenv : ``poetry update``
|
- run the following command in your virtualenv : ``poetry update``
|
||||||
|
|
||||||
## Publish on pyPI
|
## Release on Gitlab and publish on PyPI
|
||||||
|
|
||||||
|
Building, releasing and publishing a new version works with tags.
|
||||||
|
|
||||||
|
Tags that trigger a build and a publication on PyPI must have a name
|
||||||
|
equal to the version of the program found in `pyproject.toml`.
|
||||||
|
|
||||||
|
Tags that matches an change in major, minor or patch version will
|
||||||
|
trigger a release on gitlab.
|
||||||
|
|
||||||
|
Tags that are alpha, beta, pre-release, etc does not trigger a release
|
||||||
|
on gitlab, but they trigger a publication on PyPI.
|
||||||
|
|
||||||
|
Before creating a tag, ensure that the version of the program is
|
||||||
|
updated. To update the program version you can use the command:
|
||||||
|
|
||||||
```
|
```
|
||||||
poetry publish
|
poetry version {major,minor,patch}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ensure that the `CHANGES.rst` file contains information about this new
|
||||||
|
release, if it is a major, minor or patch release. For alpha, beta, etc
|
||||||
|
release information will be published with the next major, minor or
|
||||||
|
patch release.
|
||||||
|
|
||||||
|
Then push a commit with the version and the changlog updated on the main
|
||||||
|
branch.
|
||||||
|
|
||||||
|
When everything is good on the main branch and that tests succeed,
|
||||||
|
create a new tag with the same name as the version in `pyproject.toml`
|
||||||
|
file. Tags can be created via Code > Tags > New tag.
|
||||||
|
|
||||||
|
To see if the publication on PyPI and the release on gitlab were done
|
||||||
|
correctly, go in Build > Pipelines. You will find a pipeline for the tag
|
||||||
|
you just created.
|
||||||
|
|
||||||
|
|
||||||
# Understanding the library
|
# Understanding the library
|
||||||
|
|
||||||
## Tools to understand
|
## Tools to understand
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user