-
Notifications
You must be signed in to change notification settings - Fork 22
/
.gitlab-ci.yml
174 lines (157 loc) · 5.32 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
image: ubuntu:20.04
variables:
GIT_SUBMODULE_STRATEGY: recursive
CI_RUN: '1'
ODOO_HELPER_INSTALL_PATH: "$CI_PROJECT_DIR"
TEST_TMP_DIR: "/tmp/odoo-helper-tests"
DEBIAN_FRONTEND: 'noninteractive'
ALWAYS_ANSWER_YES: '1'
LANG: 'C.UTF-8'
LC_ALL: 'C.UTF-8'
LANGUAGE: 'C.UTF-8'
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
APT_DIR: "$CI_PROJECT_DIR/.apt-cache"
APT_STATE_LISTS: "$APT_DIR/lists"
APT_CACHE_ARCHIVES: "$APT_DIR/archives"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/odoo-helper-scripts"
cache:
key: ${CI_JOB_NAME}
paths:
- .cache
stages:
- lint
- test
- build
- release
- deploy
shellcheck:
image: koalaman/shellcheck-alpine:stable
stage: lint
before_script:
- shellcheck --version
script:
- shellcheck -s bash -x -a --color -e "SC1090,SC1091,SC2034" ./bin/* ./lib/*.bash
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG !~ /^v\d.*/
flake8:
image: python:3
stage: lint
before_script:
- pip install flake8
script:
- flake8 ./lib/pylib/
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG !~ /^v\d.*/
.test:definition: &tests-definition
stage: test
before_script:
# Setup PIP Cache
- mkdir -p .cache && chmod a+rwx -R .cache
# Install deps
- apt-get update -qq && apt-get install -yqq adduser sudo locales ruby git
- update-locale LANG=C.UTF-8 && update-locale LC_ALL=C.UTF-8 && update-locale LANGUAGE=C.UTF-8
- gem install bashcov -v 1.8.2
- gem install codecov simplecov-console
# Configure Odoo user
- adduser -q odoo
- echo ' odoo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
- sudo -u odoo -HE git config --global user.email "[email protected]"
- sudo -u odoo -HE git config --global user.name "test-oh"
script:
- bash install-system.bash
- sudo -u odoo -HE bashcov tests/test.bash
coverage: '/COVERAGE:.*\s+(\d{1,3}\.\d{2}\%)/'
artifacts:
paths:
- coverage
expire_in: 3 day
when: always
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
tests:ubuntu:20.04:
image: ubuntu:20.04
<<: *tests-definition
tests:ubuntu:22.04:
image: ubuntu:22.04
<<: *tests-definition
.build:package:base:definition: &build-package-base-def
image: ubuntu:22.04
stage: build
variables:
ODOO_HELPER_ROOT: $CI_PROJECT_DIR
ODOO_HELPER_BIN: $CI_PROJECT_DIR/bin
ODOO_HELPER_LIB: $CI_PROJECT_DIR/lib
before_script:
- apt-get update -qq && apt-get install -qqy ruby ruby-dev make gcc curl
- gem install fpm
build:package:tag:
<<: *build-package-base-def
script:
- bash scripts/build_packages.bash
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb"'
rules:
- if: $CI_COMMIT_TAG =~ /^v\d.*/
build:package:branch:dev:
<<: *build-package-base-def
script:
- bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}"
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
when: manual
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
build:package:branch:master:
<<: *build-package-base-def
script:
- bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}"
after_script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"'
rules:
- if: $CI_COMMIT_BRANCH == "master"
do_release:tag:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
# Run this job when a tag is created manually
- if: $CI_COMMIT_TAG =~ /^v\d.*/
before_script:
- apk add coreutils
script:
- echo "Preparing release $CI_COMMIT_TAG."
- csplit --prefix=CHANGELOG. --suffix=%02d.md CHANGELOG.md '/---/'
release:
tag_name: $CI_COMMIT_TAG
name: "${CI_COMMIT_TAG}"
description: "./CHANGELOG.00.md"
assets:
links:
- name: "odoo-helper-scripts_${CI_COMMIT_TAG}.deb"
url: "$PACKAGE_REGISTRY_URL/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb"
link_type: "package"
pages:
image: ubuntu:20.04
stage: deploy
before_script:
- apt-get update
- apt-get install -y python3-pip
- bash install-system.bash
- python3 -m pip install mkdocs mkdocs-cinder==0.14.0
script:
- bash scripts/build_docs.bash
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "master"