forked from eclipse-uprotocol/up-tck
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (143 loc) · 6.1 KB
/
tck-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
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
name: TCK Tests
on:
push:
branches: [ "main"]
pull_request:
branches: [ "main"]
permissions:
contents: read
jobs:
run_tests:
runs-on: ubuntu-20.04
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Rust Test Agent
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path test_agent/rust/Cargo.toml
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build up_client_socket_java with Maven
working-directory: up_client_socket/java
run: |
mvn clean install --file pom.xml
- name: Build java_test_agent with Maven
working-directory: test_agent/java
run: |
mvn clean install --file pom.xml
- name: Set up Python 3.8.7
uses: actions/setup-python@v3
with:
python-version: "3.8.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install multimethod
cd scripts
python install_dependencies.py
- name: Get Behave Scripts
uses: actions/github-script@v6
id: check-env
with:
result-encoding: string
script: |
const feature_file_list = [];
const fs = require('fs');
const path = require('path');
function traverseDir(dir) {
fs.readdirSync(dir).forEach(file => {
let fullPath = path.join(dir, file);
if (fs.lstatSync(fullPath).isDirectory()) {
traverseDir(fullPath);
} else {
core.info("Adding file: " + fullPath);
feature_file_list.push({ filename: file, path: fullPath.replace("test_manager/", "") });
}
});
}
traverseDir("./test_manager/features/tests");
fs.writeFileSync('./test_manager/feature_file_list.json', JSON.stringify(feature_file_list));
var feature_json = JSON.parse(fs.readFileSync('./test_manager/testData/workflow_test_data.json', 'utf8'));
const command_list = [];
for(var feature_file_name in feature_json){
for (var language in feature_json[feature_file_name]["ue1"]){
for (var transport in feature_json[feature_file_name]["transports"]){
var port_language = feature_json[feature_file_name]["ue1"][language]
var port_transport = feature_json[feature_file_name]["transports"][transport]
if ("ue2" in feature_json[feature_file_name]){
for (var language_two in feature_json[feature_file_name]["ue2"]){
var second_ue = feature_json[feature_file_name]["ue2"][language_two]
var command_str = "behave --define uE1=" + port_language + " --define uE2=" + second_ue + " --define transport=" + port_transport + " --format json --outfile './reports/" + feature_file_name + "_" + port_language + ".json' --format html --outfile './reports/" + feature_file_name + "_" + port_language + ".html' './features/tests/" + feature_json[feature_file_name]["path"] + "/" + feature_file_name + ".feature'"
command_list.push(command_str);
}
} else {
var command_str = "behave --define uE1=" + port_language + " --define transport=" + port_transport + " --format json --outfile './reports/" + feature_file_name + "_" + port_language + ".json' --format html --outfile './reports/" + feature_file_name + "_" + port_language + ".html' './features/tests/" + feature_json[feature_file_name]["path"] + "/" + feature_file_name + ".feature'"
command_list.push(command_str);
}
}
}
}
fs.writeFileSync('./test_manager/command_list.json', JSON.stringify(command_list));
- name: TCK Behave Tests
run: |
cd test_manager
content=$(<./command_list.json)
echo "$content" | jq -c '.[]' | while IFS='' read -r obj; do
obj=$(sed -e 's/^"//' -e 's/"$//' <<< "$obj")
echo "Running Test: $obj"
eval "$obj"
echo "Finished Test: $obj"
done
- name: Read Behave Results
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const feature_file_list = []
const fs = require('fs')
const path = require('path');
function traverseDir(dir) {
fs.readdirSync(dir).forEach(file => {
let fullPath = path.join(dir, file);
if (fs.lstatSync(fullPath).isDirectory()) {
traverseDir(fullPath);
} else {
feature_file_list.push({ filename: file, path: fullPath });
}
});
}
traverseDir("./test_manager/reports");
const json_list = []
try {
for (let i = 0; i < feature_file_list.length; i++){
file_extension = path.parse(feature_file_list[i]["filename"]).ext
file_name = path.parse(feature_file_list[i]["filename"]).name
if (file_extension == ".json" && file_name != "summary") {
json_list.push(JSON.parse(fs.readFileSync(feature_file_list[i]["path"])));
}
}
for (let i = 0; i < json_list.length; i++) {
if (json_list[i][0].status != "passed") {
core.setFailed("One or more features failed")
core.error("\u001b[38;2;255;0;0mFeature:" + json_list[i][0].name + " [failed]")
} else{
core.info("\u001b[38;2;0;255;0mFeature:" + json_list[i][0].name + " [passed]")
}
}
} catch(err) {
core.error("\u001b[38;2;255;0;0mError while reading or parsing the JSON")
core.setFailed(err)
}
- name: Upload Test Reports
uses: actions/upload-artifact@v4
with:
name: behave-test-reports
path: ./test_manager/reports/*.html