-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
64 lines (55 loc) · 2.16 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
stages:
- codecheck
- test
# WORKFLOW RULES
# ------------------------------------------------------------------------------------------------------
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# ------------------------------------------------------------------------------------------------------
# TEMPLATES
# ------------------------------------------------------------------------------------------------------
.base_template:
image: python:3.7-bullseye
tags:
- build
- internet
.idf_template:
image: "espressif/idf:latest"
tags:
- build
- internet
before_script:
- pip install -e .[dev]
# --------------------------------------------------------------------------------------------------
# JOBS
# ------------------------------------------------------------------------------------------------------
# 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"'
# ------------------------------------------------------------------------------------------------------
# TESTS
# ------------------------------------------------------------------------------------------------------
test-sbom:
stage: test
extends: .idf_template
script:
- pytest test
# ------------------------------------------------------------------------------------------------------