-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.gitlab-ci.yml
119 lines (107 loc) · 3.63 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
stages:
- pre-check
- codecheck
- test
- report
# WORKFLOW RULES
# ------------------------------------------------------------------------------------------------------
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'
# ------------------------------------------------------------------------------------------------------
# TEMPLATES
# ------------------------------------------------------------------------------------------------------
.base_template:
image: python:3.7-slim-buster
tags:
- build
- internet
.idf_template:
image: espressif/idf:latest
tags:
- build
- internet
# --------------------------------------------------------------------------------------------------
# JOBS
# ------------------------------------------------------------------------------------------------------
include:
- project: espressif/shared-ci-dangerjs
ref: master
file: danger.yaml
run-danger-mr-linter:
stage: pre-check
variables:
ENABLE_CHECK_UPDATED_CHANGELOG: 'false'
# when changing please also update .pre-commit-config.yaml
COMMIT_MESSAGE_ALLOWED_TYPES: 'change,ci,docs,feat,fix,refactor,remove,revert,test,perf'
# CODE CHECK BY PRE-COMMIT HOOKS
pre-commit_hooks_MR:
stage: codecheck
extends: .base_template
before_script:
- apt-get update && apt-get install -y -q git
- python -m pip install pre-commit
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"'
# Check if parse_soc_h_script got changed on IDF side
parse_soc_h_script_check:
stage: codecheck
extends: .idf_template
script:
- pip install .
- python esp_coredump/corefile/_parse_soc_header.py
- git diff --exit-code -- esp_coredump/corefile/soc_headers/\* || exit 1;
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
test_espcoredump:
stage: test
extends: .idf_template
artifacts:
when: always
paths:
- "tests"
- ".coverage*"
expire_in: 1 week
script:
- pip install -e .[test]
- coverage run -m pytest
combine_reports:
stage: report
extends: .base_template
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura_report.xml
when: always
paths:
- ".coverage*"
- cobertura_report.xml
- ./html_report/
expire_in: 1 week
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
variables:
LC_ALL: C.UTF-8
COVERAGE_RCFILE: "${CI_PROJECT_DIR}/pyproject.toml"
script:
- pip install -e .[test]
# all .coverage files in sub-directories are moved to the parent dir first
- find . -mindepth 2 -type f -name ".coverage*" -print -exec mv --backup=numbered {} . \;
- coverage combine
- coverage report --precision=2
- coverage html -d html_report --precision=2
- coverage xml -o cobertura_report.xml
# ------------------------------------------------------------------------------------------------------