Skip to content

Commit 4757cd7

Browse files
author
Amanda Butler
authored
Merge branch 'development' into timer64
2 parents ae7c194 + b1b11d5 commit 4757cd7

File tree

183 files changed

+2928
-1837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+2928
-1837
lines changed

.travis.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Language and cache settings
2+
language: python
3+
python: 2.7
4+
cache:
5+
pip: true
6+
directories:
7+
- $HOME/.cache/apt
8+
9+
# Common install step
10+
install:
11+
# Make sure pipefail
12+
- set -o pipefail
13+
# Set up apt to cache
14+
- mkdir -p $HOME/.cache/apt/partial
15+
- sudo rm -rf /var/cache/apt/archives
16+
- sudo ln -s $HOME/.cache/apt /var/cache/apt/archives
17+
# Set up ppa to make sure arm-none-eabi-gcc is the correct version
18+
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
19+
# Fix for "The following signatures were invalid: KEYEXPIRED 1515625755" failed". See https://github.com/travis-ci/travis-ci/issues/9037
20+
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
21+
# Loop until update succeeds (timeouts can occur)
22+
- travis_retry $(! sudo apt-get update 2>&1 | grep Failed)
23+
# Finally install gcc-arm-embedded
24+
- sudo apt-get install gcc-arm-embedded
25+
# Get mbed-os
26+
- git clone https://github.com/armmbed/mbed-os.git
27+
# Install python dependencies
28+
- pip install -r mbed-os/requirements.txt
29+
30+
# CI matrix
31+
jobs:
32+
include:
33+
# native testing
34+
- stage: test
35+
env:
36+
- NAME=code-snippets
37+
script:
38+
# Run script to validate code snippets
39+
- ./check_tools/find_bad_code_snippets.sh
40+
# Grep to find remaining TODOs
41+
- |
42+
TODO_COUNT=0
43+
for f in $(find -name mbed-os -prune -o -name '*.md' -print)
44+
do
45+
for l in $(sed -n '/```.*TODO/I=' $f)
46+
do
47+
echo "TODO in $f line $l"
48+
TODO_COUNT=$(expr $TODO_COUNT + 1)
49+
done
50+
done
51+
echo "Total number of TODOs: $TODO_COUNT"
52+
# Update status with number of found TODOs if we passed testing
53+
- |
54+
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
55+
then
56+
CURR=$TODO_COUNT
57+
PREV=$(curl -u "$MBED_BOT" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
58+
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
59+
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
60+
| capture(\"(?<count>[0-9]+) TODOs\").count" \
61+
|| echo 0)
62+
STATUS="Passed, ${CURR} TODOs"
63+
if [ "$PREV" -ne 0 ]
64+
then
65+
STATUS="$STATUS ($(python -c "print '%+d' % ($CURR-$PREV)") TODOs)"
66+
fi
67+
fi
68+
69+
# Manage statuses
70+
before_install:
71+
- |
72+
curl -u "$MBED_BOT" -X POST \
73+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
74+
-d "{
75+
\"context\": \"travis-ci/$NAME\",
76+
\"state\": \"pending\",
77+
\"description\": \"${STATUS:-In progress}\",
78+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
79+
}"
80+
81+
after_failure:
82+
- |
83+
curl -u "$MBED_BOT" -X POST \
84+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
85+
-d "{
86+
\"context\": \"travis-ci/$NAME\",
87+
\"state\": \"failure\",
88+
\"description\": \"${STATUS:-Failed}\",
89+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
90+
}"
91+
92+
after_success:
93+
- |
94+
curl -u "$MBED_BOT" -X POST \
95+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
96+
-d "{
97+
\"context\": \"travis-ci/$NAME\",
98+
\"state\": \"success\",
99+
\"description\": \"${STATUS:-Passed}\",
100+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
101+
}"
102+
103+
# Job control
104+
stages:
105+
- name: test
106+

check_tools/find_bad_code_snippets.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
mkdir -p BUILD
6+
echo '*' > BUILD/.mbedignore
7+
8+
# simple fake main for snippets without a main function
9+
cat > fake_main.c <<MAIN
10+
#include "mbed_toolchain.h"
11+
MBED_WEAK int main(void) { return 0; }
12+
MAIN
13+
14+
function compile {
15+
if [ "$1" != "NOCI" -a "$1" != "TODO" ]
16+
then
17+
PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m ${1:-K64F} --source=. --build=BUILD/${1:-K64F}/GCC_ARM | sed '/\(error\|warning\)/I!d'
18+
fi
19+
}
20+
21+
for f in $(find -name mbed-os -prune -o -name '*.md' -print)
22+
do
23+
# compile c++ snippets
24+
for l in $(sed -n '/``` *\(cpp\|c++\)\($\| \+\)/I=' $f)
25+
do
26+
echo "Validating cpp $f:$l ..."
27+
echo "#include \"mbed.h\"" > main.cpp
28+
sed -n $l',/```/{/```/d;p}' $f >> main.cpp
29+
compile "$(sed -n $l's/ *``` *\(cpp\|c++\)\($\| \+\)//Ip' $f)"
30+
rm main.cpp
31+
done
32+
33+
# compile c snippets
34+
for l in $(sed -n '/``` *c\($\| \+\)/I=' $f)
35+
do
36+
echo "Validating c $f:$l ..."
37+
sed -n $l',/```/{/```/d;p}' $f > main.c
38+
compile "$(sed -n $l's/ *``` *c\($\| \+\)//Ip' $f)"
39+
rm main.c
40+
done
41+
42+
# validate json snippets
43+
for l in $(sed -n '/``` *json\($\| \+\)/I=' $f)
44+
do
45+
echo "Validating json $f:$l ..."
46+
sed -n $l',/```/{/```/d;p}' $f > main.json
47+
if [ "$(sed -n $l's/ *``` *json\($\| \+\)//Ip' $f)" != "NO" ]
48+
then
49+
if sed -n '/ *"/q0;/ *[^ ]/q1' main.json
50+
then
51+
(echo "{" ; cat main.json ; echo "}") | python -m json.tool > /dev/null
52+
else
53+
cat main.json | python -m json.tool > /dev/null
54+
fi
55+
fi
56+
rm main.json
57+
done
58+
done

0 commit comments

Comments
 (0)