Skip to content

Commit cb1b3be

Browse files
committed
CI: build single headers
1 parent 5ccd62a commit cb1b3be

File tree

2 files changed

+73
-23
lines changed

2 files changed

+73
-23
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ jobs:
335335
- name: Upload HTML report
336336
uses: actions/upload-artifact@v2
337337
with:
338-
name: coverage
338+
name: Coverage report
339339
path: coverage
340340
- name: Upload to Coveralls
341341
uses: coverallsapp/github-action@master
@@ -379,3 +379,71 @@ jobs:
379379
CXX: clang++-10
380380
- name: Check
381381
run: cmake --build . -- -k 0
382+
383+
amalgamate-h:
384+
needs: gcc
385+
name: Amalgamate ArduinoJson.h
386+
runs-on: ubuntu-20.04
387+
steps:
388+
- name: Checkout
389+
uses: actions/checkout@v2
390+
- name: Amalgamate
391+
id: amalgamate
392+
run: |
393+
if [[ $GITHUB_REF == refs/tags/* ]]; then
394+
VERSION=${GITHUB_REF#refs/tags/}
395+
else
396+
VERSION=${GITHUB_SHA::7}
397+
fi
398+
INPUT=src/ArduinoJson.h
399+
OUTPUT=ArduinoJson-$VERSION.h
400+
extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
401+
echo ::set-output name=filename::${OUTPUT}
402+
- name: Smoke test
403+
run: |
404+
g++ -x c++ - <<END
405+
#include "${{ steps.amalgamate.outputs.filename }}"
406+
int main() {
407+
StaticJsonDocument<300> doc;
408+
deserializeJson(doc, "{}");
409+
}
410+
END
411+
- name: Upload artifact
412+
uses: actions/upload-artifact@v2
413+
with:
414+
name: Single headers
415+
path: ${{ steps.amalgamate.outputs.filename }}
416+
417+
amalgamate-hpp:
418+
needs: gcc
419+
name: Amalgamate ArduinoJson.hpp
420+
runs-on: ubuntu-20.04
421+
steps:
422+
- name: Checkout
423+
uses: actions/checkout@v2
424+
- name: Amalgamate
425+
id: amalgamate
426+
run: |
427+
if [[ $GITHUB_REF == refs/tags/* ]]; then
428+
VERSION=${GITHUB_REF#refs/tags/}
429+
else
430+
VERSION=${GITHUB_SHA::7}
431+
fi
432+
INPUT=src/ArduinoJson.hpp
433+
OUTPUT=ArduinoJson-$VERSION.hpp
434+
extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
435+
echo ::set-output name=filename::${OUTPUT}
436+
- name: Smoke test
437+
run: |
438+
g++ -x c++ - <<END
439+
#include "${{ steps.amalgamate.outputs.filename }}"
440+
int main() {
441+
ArduinoJson::StaticJsonDocument<300> doc;
442+
deserializeJson(doc, "{}");
443+
}
444+
END
445+
- name: Upload artifact
446+
uses: actions/upload-artifact@v2
447+
with:
448+
name: Single headers
449+
path: ${{ steps.amalgamate.outputs.filename }}

extras/scripts/build-single-header.sh

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -e
44

5-
TAG=$(git describe)
65
RE_RELATIVE_INCLUDE='^#include[[:space:]]*"(.*)"'
76
RE_ABSOLUTE_INCLUDE='^#include[[:space:]]*<(ArduinoJson/.*)>'
87
RE_SYSTEM_INCLUDE='^#include[[:space:]]*<(.*)>'
@@ -58,25 +57,8 @@ simplify_namespaces() {
5857
rm -f "$1.bak"
5958
}
6059

61-
cd $(dirname $0)/../..
6260
INCLUDED=()
63-
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
64-
simplify_namespaces ../ArduinoJson-$TAG.h
65-
g++ -x c++ -c -o ../smoketest.o - <<END
66-
#include "../ArduinoJson-$TAG.h"
67-
int main() {
68-
StaticJsonDocument<300> doc;
69-
deserializeJson(doc, "{}");
70-
}
71-
END
72-
73-
INCLUDED=()
74-
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
75-
simplify_namespaces ../ArduinoJson-$TAG.hpp
76-
g++ -x c++ -c -o ../smoketest.o - <<END
77-
#include "../ArduinoJson-$TAG.hpp"
78-
int main() {
79-
ArduinoJson::StaticJsonDocument<300> doc;
80-
ArduinoJson::deserializeJson(doc, "{}");
81-
}
82-
END
61+
INPUT=$1
62+
OUTPUT=$2
63+
process "$INPUT" true > "$OUTPUT"
64+
simplify_namespaces "$OUTPUT"

0 commit comments

Comments
 (0)