Update tck-test.yml #16
Workflow file for this run
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", "workflow_test" ] | |
pull_request: | |
branches: [ "main", "workflow_test" ] | |
permissions: | |
contents: read | |
jobs: | |
run_tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- 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.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
pip install -r requirements.txt | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- 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'); | |
const { execSync } = require('child_process'); | |
function traverseDir(dir) { | |
fs.readdirSync(dir).forEach(file => { | |
let fullPath = path.join(dir, file); | |
if (fs.lstatSync(fullPath).isDirectory()) { | |
traverseDir(fullPath); | |
} | |
core.info(fullPath); | |
feature_file_list.push([file, fullPath]); | |
}); | |
} | |
traverseDir("./test_manager/features/tests"); | |
fs.writeFileSync('./test_manager/feature_file_list.json', JSON.stringify(feature_file_list)); | |
- name: TCK Behave Tests | |
run: | | |
content=`cat ./test_manager/feature_file_list.json` | |
for i in "${arr[@]}" | |
do | |
echo "$i" | |
behave --format json --outfile ./test_manager/reports/"$i[0]".json --format plain --outfile ./test_manager/reports/"$i[0].txt ./"$i[1]" | |
sleep 70 | |
# or do whatever with individual element of the array | |
done | |
- name: Get Behave Scripts | |
uses: actions/github-script@v6 | |
with: | |
result-encoding: string | |
script: | | |
const feature_file_list = [] | |
const fs = require('fs') | |
const path = require('path'); | |
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][0]).ext | |
if (file_extension == ".json") { | |
json_list.push(JSON.parse(fs.readFileSync(feature_file_list[i][1]))); | |
} | |
} | |
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("Feature:" + json_list[i][0].name + " [failed]") | |
} else{ | |
core.info("Feature:" + json_list[i][0].name + " [passed]") | |
} | |
} | |
} catch(err) { | |
core.error("Error while reading or parsing the JSON") | |
core.setFailed(err) | |
} |