-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
172 lines (150 loc) · 4.4 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
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
stages:
- check
- build
- test
- deploy
variables:
PIO_LIB_FOLDER: libspookyaction
PIO_PROJ_FOLDER: tests
.pio-cache: &pio-cache
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- "${PIO_PROJ_FOLDER}/.pio"
.rules-changes-sources: &rules-changes-sources
changes:
- ${PIO_LIB_FOLDER}/src/**/*
- ${PIO_LIB_FOLDER}/include/**/*
- ${PIO_LIB_FOLDER}/examples/**/*
- ${PIO_PROJ_FOLDER}/src/**/*
- ${PIO_PROJ_FOLDER}/test/**/*
- ${PIO_PROJ_FOLDER}/include/**/*
- ${PIO_PROJ_FOLDER}/lib/**/*
- cicd/platformio.ini
.rules-changes-cicd: &rules-changes-cicd
changes:
- cicd/*
- .gitlab-ci.yml
.rules-merge-to-master: &rules-merge-to-master
if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
when: always
.rules-master: &rules-master
if: '$CI_COMMIT_BRANCH == "master"'
when: always
check format:
stage: check
image: alpine
allow_failure: true
before_script:
- apk add --update --no-cache git clang clang-extra-tools
script:
- >
find . -not -path '*/\.*' -and \( -name '*.[hc]' -or -name '*.[hc]pp' \) | while read -r FILE; do
echo "Formatting $FILE"
clang-format --style file -i "$FILE"
done
- git diff --patch | tee 0001-Clang-format.patch
- test ! -s 0001-Clang-format.patch
artifacts:
paths:
- 0001-Clang-format.patch
expire_in: 1 week
when: on_failure
rules:
# Run always, on merge request too
- when: always
build test firmware:
stage: build
image: ${CI_REGISTRY}/proj/testinator/esp32:latest
<<: *pio-cache
before_script:
- cp cicd/platformio.ini "${PIO_PROJ_FOLDER}/platformio.ini"
- cd "${PIO_PROJ_FOLDER}"
script:
# Remove the cached firmwares to ensure we will rebuild
- rm -f .pio/**/firmware.{bin,elf}
- pio test -vv --without-uploading --without-testing
artifacts:
paths:
- "${PIO_PROJ_FOLDER}/.pio/**/*.checksum" # Without this, `pio run` deletes the firmware
- "${PIO_PROJ_FOLDER}/.pio/**/firmware.bin"
- "${PIO_PROJ_FOLDER}/.pio/**/firmware.elf"
rules:
- when: always
build examples:
image: ${CI_REGISTRY}/proj/testinator/esp32:latest
stage: build
<<: *pio-cache
script: # Note that we need to setup sdkconfig.defaults before, so we make our own folder and we manage it ourselves
- >
for file in ${PIO_LIB_FOLDER}/examples/*.cpp; do
BUILD_DIR="$(mktemp -d)"
cp ${PIO_LIB_FOLDER}/examples/sdkconfig.defaults "${BUILD_DIR}"
pio ci \
--build-dir="${BUILD_DIR}" \
--project-conf=cicd/platformio.ini \
--lib=${PIO_LIB_FOLDER} \
--keep-build-dir \
$file
rm -rf "${BUILD_DIR}"
done
rules:
# [skip examples] tag for skipping
- if: '$CI_COMMIT_MESSAGE =~ /skip examples/'
when: never
# Run on merge request
- <<: *rules-merge-to-master
# But skip by default if the sources did not change
- <<: *rules-changes-sources
- <<: *rules-changes-cicd
test hardware:
stage: test
image: ${CI_REGISTRY}/proj/testinator/esp32:latest
tags:
- pn532
dependencies:
- build test firmware
before_script:
- cp cicd/platformio.ini "${PIO_PROJ_FOLDER}/platformio.ini"
- cd "${PIO_PROJ_FOLDER}"
script:
# Make two attempts at uploading.
- pio test --without-building --without-testing -vv || pio test --without-building --without-testing -vv
- pio test --without-building --without-uploading -vv
rules:
# Run always, on merge request too
- <<: *rules-merge-to-master
# But skip by default if the sources did not change
- <<: *rules-changes-sources
- <<: *rules-changes-cicd
publish library:
image: ${CI_REGISTRY}/proj/testinator/esp32:latest
stage: deploy
before_script:
- python3 -m pip install --user gitpython
script:
- |
python3 cicd/check_version.py ${PIO_LIB_FOLDER}/library.json && \
pio package publish --owner ${PLATFORMIO_ORG} --non-interactive ${PIO_LIB_FOLDER}
only:
- tags
except:
- branches
pages:
stage: deploy
image: alpine
needs:
- check format
before_script:
- apk add --update --no-cache doxygen graphviz ttf-opensans
script:
- doxygen ./doxygen.conf
- mkdir -p public
- cp -r docs/_build/html/* public
artifacts:
paths:
- public
rules:
- <<: *rules-master