-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
173 lines (148 loc) · 4.63 KB
/
.gitlab-ci.yml
File metadata and controls
173 lines (148 loc) · 4.63 KB
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
# Based on https://docs.platformio.org/en/latest/integration/ci/gitlab.html#using-cmd-ci-command
default:
image: python:3.12
cache:
- key: $CI_JOB_NAME
paths:
- $CI_PROJECT_DIR/.cache/pip
- $CI_PROJECT_DIR/.cache/platformio
workflow:
auto_cancel:
on_new_commit: interruptible
rules:
# Never auto cancel for anything in the main branch
- if: '$CI_COMMIT_BRANCH == "main"'
auto_cancel:
on_new_commit: none
- when: always
variables: # Change pip's cache directory to be inside the project directory since we can only cache local items.
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PLATFORMIO_CACHE_DIR: "$CI_PROJECT_DIR/.cache/platformio"
stages:
- test
- build
.before_script: &before_script
- git config --global advice.detachedHead false
- git remote set-url origin ${CI_PROJECT_URL/gitlab.com/gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com}.git
- ./scripts/check_version.sh
- pip install -U platformio
# Move all firmware images to the top-level folder for easier extraction
.after_script: &after_script
- ls -hola
- find .pio -type f -iname "*@*.bin" -exec mv -t . {} +
.esp32-script:
before_script: *before_script
script: platformio run -e esp32doit-devkit-v1 -e esp32doit-devkit-v1-dbg
after_script: *after_script
.esp32-s3-script:
before_script: *before_script
script: platformio run -e esp32-s3-devkitc-1 -e voc-sensor-mk1 -e voc-sensor-mk1-dbg
after_script: *after_script
.tiaki-co2-script:
before_script: *before_script
script: platformio run -e tiaki-co2-monitor -e tiaki-co2-monitor-dbg
after_script: *after_script
.fire-data-logger-script:
before_script: *before_script
script: platformio run -e fire-data-logger -e fire-data-logger-dbg
after_script: *after_script
##############################################################################
# Test jobs
.test-base:
rules:
# Never run for push events
- if: '$CI_PIPELINE_SOURCE == "push"'
when: never
# Never run when tags are created
- if: "$CI_COMMIT_TAG"
when: never
# Run for all commits in merge requests to the main branch
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
when: always
# Manually started jobs are allowed to fail
- when: manual
allow_failure: true
artifacts:
when: on_success
name: "$CI_JOB_NAME"
expire_in: "30 days"
paths:
- ./*@*.bin
test:esp32:
extends: [.test-base, .esp32-script]
stage: test
test:esp32-s3:
extends: [.test-base, .esp32-s3-script]
stage: test
test:tiaki-co2-script:
extends: [.test-base, .tiaki-co2-script]
stage: test
test:fire-data-logger-script:
extends: [.test-base, .fire-data-logger-script]
stage: test
##############################################################################
# Format & Linting
.lint-base:
rules:
# Never run for push events
- if: '$CI_PIPELINE_SOURCE == "push"'
when: never
# Never run when tags are created
- if: "$CI_COMMIT_TAG"
when: never
# Run for all commits in merge requests to the main branch
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
when: always
# Manually started jobs are allowed to fail
- when: manual
allow_failure: true
lint:clang-format:
extends: [.lint-base]
image: alpine:latest
stage: test
cache: []
before_script:
- apk add --no-cache clang21-extra-tools
- clang-format --version
script:
- find src -type f \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | xargs -0 clang-format --dry-run --Werror
##############################################################################
# Build jobs on merged MR
.build-base:
rules:
# Always run CI if it is on the main branch
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
interruptible: false
# Never run for push events
- if: '$CI_PIPELINE_SOURCE == "push"'
when: never
# Never run when tags are created
- if: "$CI_COMMIT_TAG"
when: never
artifacts:
when: on_success
name: "$CI_JOB_NAME"
expire_in: never
paths:
- ./*@*.bin
dependencies: []
interruptible: false
build:esp32:
extends: [.build-base, .esp32-script]
stage: build
build:esp32-s3:
extends: [.build-base, .esp32-s3-script]
stage: build
build:tiaki-co2-script:
extends: [.build-base, .tiaki-co2-script]
stage: build
build:fire-data-logger-script:
extends: [.build-base, .fire-data-logger-script]
stage: build
build:tag-commit:
extends: [.build-base]
stage: build
artifacts: {}
before_script: "git remote set-url origin ${CI_PROJECT_URL/gitlab.com/ci-build:${PROJECT_TOKEN}@gitlab.com}.git"
script: "./scripts/tag_commit.sh"