-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
159 lines (143 loc) · 4.25 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
variables:
FF_TIMESTAMPS: true
default:
image: python:3.11.9-bookworm
stages:
- check
- build
- test
- deploy
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
- if: "$CI_COMMIT_BRANCH"
.check:
stage: check
tags:
- lint
- internet
check_manifest_format_changes:
extends: .check
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- |
if git diff-tree --name-only -r --no-commit-id "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" "${CI_COMMIT_SHA}" | grep -q "schemas.py"; then
[[ "${CI_MERGE_REQUEST_LABELS}" =~ ^(.*,)*manifest_changes_handled(,.*)*$ ]] || \
(echo "Please create a registry MR and add 'manifest_changes_handled' label if necessary" && exit 1)
fi
check_tests:
extends: .check
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- |
(git diff-tree --name-only -r --no-commit-id "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" "${CI_COMMIT_SHA}" | (grep "tests/" || grep "integration_tests/")) || \
[[ "${CI_MERGE_REQUEST_LABELS}" =~ ^(.*,)*no_tests(,.*)*$ ]] || \
(echo "Please either cover changes with tests or add 'no_tests' label" && exit 1)
pre-commit-mr:
stage: check
extends: .check
before_script:
- pip install '.[dev]'
script:
- echo "Merge request is from ${CI_COMMIT_REF_NAME} into ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
- git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} ${CI_COMMIT_REF_NAME}
- export from_sha=$(git merge-base HEAD origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})
- echo "Checking changes from ${from_sha} to ${CI_COMMIT_SHA}:"
- git log --oneline ${from_sha}..${CI_COMMIT_SHA}
- echo "Modified files:"
- git diff-tree --no-commit-id --name-only -r ${from_sha} ${CI_COMMIT_SHA}
- echo "Running pre-commit:"
- pre-commit run --from ${from_sha} --to ${CI_COMMIT_SHA}
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Include this job in merge request pipelines, only
prepare_tests:
extends: .check
script:
- python ci/prepare_tests.py
artifacts:
paths:
- ci/tests.yml
.build-docs:
stage: test
tags:
- internet
script:
- git checkout -f $REF
- pip install '.[docs]'
- sphinx-build docs/en ${OUTPUT_DIR}
after_script:
- 'echo "preview link: ${GITLAB_PAGE_HTTPS_URL}/-/idf-component-manager/-/jobs/${CI_JOB_ID}/artifacts/html_output/index.html"'
artifacts:
paths:
- $OUTPUT_DIR/
when: always
expire_in: 4 days
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Include this job in merge request pipelines, only
build-preview-docs:
extends: .build-docs
variables:
OUTPUT_DIR: html_output_preview
REF: HEAD
build-main-docs:
extends: .build-docs
variables:
OUTPUT_DIR: html_output_main
REF: HEAD~1 # merged result pipeline
diff-docs:
stage: test
tags:
- internet
needs:
- build-preview-docs
- build-main-docs
script:
- pip install prettytable python-gitlab
- python ci/diff_docs.py html_output_main html_output_preview --output html_diff
artifacts:
paths:
- html_diff/
when: always
expire_in: 4 days
expose_as: docs_diff
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Include this job in merge request pipelines, only
tests:
stage: test
needs:
- prepare_tests
trigger:
strategy: depend
include:
- artifact: ci/tests.yml
job: prepare_tests
publish_on_pypi:
stage: deploy
tags:
- internet
variables:
TWINE_NON_INTERACTIVE: "true"
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${PYPI_TOKEN}
before_script:
- apt update && apt install curl jq -y
- pip install build twine
script:
- ./publish.sh
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH =~ /^release\/v.*/
include:
- project: "espressif/shared-ci-dangerjs"
ref: master
file: "danger.yaml"
- local: ci/common.yml
run-danger-mr-linter:
stage: check
variables:
ENABLE_CHECK_UPDATED_CHANGELOG: "false"
COMMIT_MESSAGE_ALLOWED_TYPES: "change,chore,ci,docs,feat,fix,refactor,remove,revert,test"