Skip to content

Commit dd445a0

Browse files
committed
CI: Map file names from temporary build dir to repo path
1 parent fd7ea2c commit dd445a0

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

extras/ci/scripts/build-example.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ fi
8383
# Try building the application (+e as we want to test every example and get a
8484
# summary on what is working)
8585
set +e
86-
pio --no-ansi run -d "$PROJECTDIR" -e "$BOARD" 2>&1 | "$CIDIR/scripts/pio-to-gh-log.py"
86+
pio --no-ansi run -d "$PROJECTDIR" -e "$BOARD" 2>&1 | \
87+
"$CIDIR/scripts/pio-to-gh-log.py" \
88+
"src/main.cpp:examples/$EXAMPLENAME/$EXAMPLENAME.ino:-1" \
89+
"lib/esp32_https_server/:src/" \
90+
"$REPODIR/:"
8791
RC=${PIPESTATUS[0]}
8892
if [[ "$RC" != "0" ]]; then
8993
echo "::error::pio returned with RC=$RC"

extras/ci/scripts/pio-to-gh-log.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@
77

88
re_err = re.compile(r"^([^:]+):([0-9]+):([0-9]+): error: (.*)$")
99

10+
# Parameters are strings of the form
11+
# path_prefix:replacement_prefix:line_offset
12+
# Where all paths starting with path_prefix will be replced with replacement_prefix,
13+
# and if such a replacement takes place, the line number will be shifted by line_offset.
14+
# That allows taking care for inserted code like the #include <Arduino.h>
15+
mappings = []
16+
for arg in sys.argv[1:]:
17+
parts = arg.split(":", 2)
18+
mappings.append((*parts[0:2], 0 if len(parts)==2 else int(parts[2])))
19+
1020
for line in sys.stdin:
1121
print(line, end="")
1222
m = re_err.match(line.strip())
1323
if m is not None:
24+
name = m.group(1)
25+
lineno = int(m.group(2))
26+
for mapping in mappings:
27+
if name.startswith(mapping[0]):
28+
name = mapping[1] + name[len(mapping[0]):]
29+
lineno += mapping[2]
1430
print("::error file={name},line={line},col={col}::{message}".format(
15-
name=m.group(1), line=m.group(2), col=m.group(3), message=m.group(4)
31+
name=name, line=lineno, col=m.group(3), message=m.group(4)
1632
))

0 commit comments

Comments
 (0)