-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
105 lines (90 loc) · 2.75 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
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
stages:
- check
- build
- test
variables:
PIO_PROJ_FOLDER: keycard-access
GIT_SUBMODULE_STRATEGY: normal
.pio-cache: &pio-cache
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- "${PIO_PROJ_FOLDER}/.pio"
.rules-changes-sources: &rules-changes-sources
changes:
- ${PIO_PROJ_FOLDER}/src/**/*
- ${PIO_PROJ_FOLDER}/include/**/*
- ${PIO_PROJ_FOLDER}/lib/**/*
- ${PIO_PROJ_FOLDER}/test/**/*
- ${PIO_PROJ_FOLDER}/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
check format:
stage: check
image: alpine:3.17
allow_failure: true
before_script:
- apk add --update --no-cache git clang clang-extra-tools
script:
- cd "${PIO_PROJ_FOLDER}"
- >
find . -not -path '*/\.*' -and -not -path './components/*' -and -not -path './lib/_*' -and \( -name '*.[hc]' -or -name '*.[hc]pp' \) | while read -r FILE; do
echo "Formatting $FILE"
clang-format --style file -i "$FILE"
done
- cd ..
- 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:
- cd "${PIO_PROJ_FOLDER}"
script:
# Remove the cached firmwares to ensure we will rebuild
- rm -f .pio/**/firmware.{bin,elf}
- pio test -e cicdmachine -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
variables:
GIT_SUBMODULE_STRATEGY: recursive
test hardware:
stage: test
image: ${CI_REGISTRY}/proj/testinator/esp32:latest
tags:
- pn532
dependencies:
- build test firmware
before_script:
- cd "${PIO_PROJ_FOLDER}"
script:
# Make two attempts at uploading.
- pio test -e cicdmachine --without-building --without-testing -vv || pio test -e cicdmachine --without-building --without-testing -vv
- pio test -e cicdmachine --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