Add ruff lint workflow and address linting issues (#50) #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |