-
Notifications
You must be signed in to change notification settings - Fork 9
189 lines (184 loc) · 6.7 KB
/
make.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: mbed-edge-examples-make-and-test
on:
workflow_dispatch:
push:
paths-ignore:
- '**/README.md'
schedule:
# Once week 04:14 on Saturday
- cron: '14 4 * * Sat'
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
make-examples-and-test:
runs-on: client
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
API_KEY: ${{ secrets.EDGE_EXAMPLES_API_KEY }}
DEV_CERT: ${{ secrets.EDGE_EXAMPLES_DEV_CERT}}
SYSTEM_TESTS: pelion-system-tests
EDGE_LOG: edge-core.log
PT_LOG: pt-example.log
SCRIPTS_INTERNAL: scripts-internal
RESULT_LOG_FILE: result_pytest.log
RESULT_HTML: result.html
RESULT_XML: result.xml
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Checkout continuous-integration
uses: actions/checkout@v4
# Self hosted has dependencies in place already
# - name: Install dependencies
# run: |
# sudo apt install build-essential git libc6-dev cmake
# sudo apt install libmosquitto-dev mosquitto-clients
# sudo apt install libglib2.0-dev
# sudo apt install doxygen
- name: git submodule update
run: git submodule update --init --recursive
# This builds release, debug and sanitize versions.
- run: make all
- name: Build edge-core
run: |
echo "$DEV_CERT" > lib/mbed-edge/config/mbed_cloud_dev_credentials.c
cd lib/mbed-edge
if [[ ! -d "build" ]]; then
rm -rf build
fi
mkdir -p build
cd build
cmake -DDEVELOPER_MODE=ON -DFIRMWARE_UPDATE=OFF ..
make -j$(nproc)
- name: Start edge-core
run: |
cd lib/mbed-edge/build
bin/edge-core >../../../${{ env.EDGE_LOG }} &
# Wait a bit for it to connect..
sleep 5
- name: Check out ${{ env.SYSTEM_TESTS }} repository
uses: actions/checkout@v4
with:
repository: PelionIoT/${{ env.SYSTEM_TESTS }}
token: ${{ secrets.ACCESS_TOKEN }}
path: ${{ env.SYSTEM_TESTS }}
- name: Check out $${{ env.SCRIPTS_INTERNAL }} repository
uses: actions/checkout@v4
with:
repository: PelionIoT/${{ env.SCRIPTS_INTERNAL }}
token: ${{ secrets.ACCESS_TOKEN }}
path: ${{ env.SCRIPTS_INTERNAL }}
- name: Create pytest config
run: |
CONFIG_FILE=${{ env.SYSTEM_TESTS }}/prod-edge-core-config.json
cp .github/workflows/prod-edge-core-config.json "$CONFIG_FILE"
jq '.api_key = "${{ env.API_KEY }}"' "$CONFIG_FILE" > tmp.json && mv tmp.json "$CONFIG_FILE"
- name: Start pt-example
run: |
cd build-debug
./bin/pt-example -n pt-example >../../${{ env.PT_LOG }} &
sleep 5
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Run pt-example-tests
run: |
cd ${{ env.SYSTEM_TESTS }}
# Check if venv folder exists, if not create it
if [[ ! -d "venv" ]]; then
python3 -m venv venv
fi
source venv/bin/activate
pip install --upgrade pip
pip install -U -r requirements.txt
pip install packages/*.whl
pip install -e systemtest-library
pytest -v --config_path=prod-edge-core-config.json --html=../${{ env.RESULT_HTML }} \
--self-contained-html -log_cli=true --log-cli-level=DEBUG \
--log-file=../${{ env.RESULT_LOG_FILE }} --log-file-level=DEBUG \
--junitxml=../${{ env.RESULT_XML }} test_cases/edge/test_pt_example.py
deactivate
- name: Cleanup - delete device from Izuma DM
if: always()
run: |
devid=$(curl --no-progress-meter localhost:8080/status | jq -r '."endpoint-name"')
if [[ -n "$devid" ]]; then
echo "Delete $devid via Izuma V3 REST API"
scripts-internal/cloud/delete-device.sh $devid ${{ secrets.EDGE_EXAMPLES_API_KEY }}
fi
- name: Cleanup - remove mcc_config -folder.
if: always()
run: |
# Delete the old identity/MCC contents to change identity in the next run
ls -al
rm -rf lib/mbed-edge/build/mcc_config
rm -rf mbed-edge-examples/lib/mbed-edge/build/mcc_config
rm -rf lib/mbed-edge/config/mbed_cloud_dev_credentials.c
rm -rf pelion-system-tests/prod-edge-core-config.json
- name: Cleanup - kill edge-core process
if: always()
run: |
edgepid=$(ps -aux |grep bin/edge-core | awk '{print $2}' | head -n1)
if [[ -n "$edgepid" ]]; then
# Kill edge-core if pid is not empty
echo "Kill edge-core with pid: $edgepid"
kill $edgepid
fi
- name: Cleanup - kill pt-example
if: always()
run: |
ptpid=$(ps -aux |grep pt-example | awk '{print $2}' | head -n1)
if [[ -n "$ptpid" ]]; then
# Kill pt-example if pid is not empty
echo "Kill pt-example with pid: $ptpid"
kill $ptpid
fi
- name: Archive clitest logs and results
uses: actions/upload-artifact@v3
if: always()
with:
name: mbed-edge-examples-logs
path: '**/*.log'
if-no-files-found: error
- name: Publish pytest result
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
junit_files: ${{ env.RESULT_XML }}
report_individual_runs: true
action_fail: true
action_fail_on_inconclusive: true
check_name: mbed-edge-examples-result
- name: Post status to Slack testing_builds
if: always()
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
channel: '#testing_builds'
docker-build:
runs-on: client
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Checkout continuous-integration
uses: actions/checkout@v4
- name: git submodule update
run: git submodule update --init --recursive
- name: Docker build pt-example
run: docker build -t pt-example:latest -f ./Dockerfile.pt-example .
# Don't run it - it will run forever essentially.
- name: Docker build pt-example
run: docker build -t simple-example:latest -f ./Dockerfile.simple-pt-example .
# Don't run it - it will run forever essentially.
- name: Docker system prune
if: always()
run: docker system prune -f
- name: Post status to Slack testing_builds
if: always()
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
channel: '#testing_builds'