-
Notifications
You must be signed in to change notification settings - Fork 65
79 lines (69 loc) · 3.84 KB
/
pr-test.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
# This pipeline is to build anax binaries
name: pr-test
on:
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
env:
HZN_EXCHANGE_URL: https://stg.edge-fabric.com/v1
EVTSTREAMS_TOPIC: cpu2evtstreams
HZN_DEVICE_ID: travis-test
HZN_EXCHANGE_USER_AUTH: iamapikey:blah2
steps:
- name: Checkout
uses: actions/checkout@v2
# prepare the environment
- name: Prep Env
run: |
sudo apt-get update
sudo apt-get install librdkafka-dev libyajl-dev kafkacat qemu qemu-user-static binfmt-support dpkg-cross
# Install the hzn cli
- name: Install hzn
run: |
wget https://github.com/open-horizon/anax/releases/latest/download/horizon-agent-linux-deb-amd64.tar.gz -O /tmp/horizon-agent-linux-deb-amd64.tar.gz
tar -zxf /tmp/horizon-agent-linux-deb-amd64.tar.gz -C /tmp/
sudo apt-get install -y /tmp/horizon-cli*.deb
# Build and test the example services that were changed in the PR for all arches
# Note: tools/travis-find determines if the specified "service" was modified, so we know if we should test it.
# The three docker commands are to simulate the arm and arm64 arches for cross-compiling
# cpu2evtstreams is the only service that is checked end to end, making sure data is delivered to IBM Event Streams
- name: Build and Test
shell: bash {0}
run: |
# test services
# set -x
# Note that several services are omitted due to the unavailability of a publicly accessible Exchange server which used to be stg.edge-fabric.com
# services=( edge/services/helloworld edge/services/cpu_percent edge/services/gps edge/services/sdr edge/services/helloMMS edge/services/mqtt_broker edge/services/mqtt2kafka edge/services/hotword_detection edge/services/stopword_removal edge/services/audio2text edge/services/text2speech edge/services/voice2audio edge/services/processtext edge/evtstreams/cpu2evtstreams edge/evtstreams/sdr2evtstreams edge/evtstreams/watson_speech2text )
services=( edge/services/helloworld edge/services/cpu_percent edge/services/gps edge/services/sdr edge/services/helloMMS edge/services/mqtt_broker edge/services/stopword_removal )
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -t arm32v6/alpine uname -m
docker run --rm -t arm64v8/ubuntu uname -m
for service in "${services[@]}"; do
echo "*********************************** Testing example service: $service *********************************** "
if [[ $service == *"cpu2evtstreams"* ]]; then
echo "Monitoring IBM Event Streams"
kafkacat -C -c 1 -q -o end -f "%t/%p/%o/%k: %s\n" -b $EVTSTREAMS_BROKER_URL -X api.version.request=true -X security.protocol=sasl_ssl -X sasl.mechanisms=PLAIN -X sasl.username=token -X sasl.password=$EVTSTREAMS_API_KEY -t $EVTSTREAMS_TOPIC > $GITHUB_WORKSPACE/output.txt 2>&1 &
fi
cd $GITHUB_WORKSPACE/$service
make test-all-arches
if [ $? -eq 0 ]; then
echo "Make exited 0"
if [[ $service == *"cpu2evtstreams"* ]]; then
if grep -Fq "$HZN_DEVICE_ID" $GITHUB_WORKSPACE/output.txt; then
cat $GITHUB_WORKSPACE/output.txt
passed=( "${passed[@]}" "$service" )
fi
else
passed=( "${passed[@]}" "$service" )
fi
else
echo "***********************************"
echo "*********************************** Make exited with non-zero result *********************************** "
echo "***********************************"
exit 1
fi
done
cd $GITHUB_WORKSPACE