From 0aba91ee687e76997c6abb1fcc5a1e01f0068254 Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Wed, 30 Oct 2024 17:16:35 +0530 Subject: [PATCH] Added github action for individual CM script tests --- .../workflows/run-individual-script-tests.yml | 31 +++++++++++++++++++ tests/script/process_tests.py | 24 ++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/run-individual-script-tests.yml create mode 100644 tests/script/process_tests.py diff --git a/.github/workflows/run-individual-script-tests.yml b/.github/workflows/run-individual-script-tests.yml new file mode 100644 index 000000000..8a4add344 --- /dev/null +++ b/.github/workflows/run-individual-script-tests.yml @@ -0,0 +1,31 @@ +# This workflow will add/update the README.md files for any updated CM scripts +name: Readme update for CM scripts + +on: + pull_request: + branches: [ "main", "mlperf-inference", "dev" ] + paths: + - 'script/**_cm.json' + - 'script/**_cm.yml' + +jobs: + run-script-tests: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Get changed files + id: getfile + run: | + echo "files=$(git diff --name-only ${{ github.event.before }} | xargs)" >> $GITHUB_OUTPUT + - name: RUN Script Tests + run: | + echo ${{ steps.getfile.outputs.files }} + for file in ${{ steps.getfile.outputs.files }}; do + echo $file + done + python3 -m pip install cmind + cm pull repo --url=https://github.com/${{ github.repository }} --checkout=${{ github.ref_name }} + python3 tests/script/process_tests.py ${{ steps.getfile.outputs.files }} diff --git a/tests/script/process_tests.py b/tests/script/process_tests.py new file mode 100644 index 000000000..386110edf --- /dev/null +++ b/tests/script/process_tests.py @@ -0,0 +1,24 @@ +import sys +import os +import cmind as cm +import check as checks +import json +import yaml + +files=sys.argv[1:] + +for file in files: + if not os.path.isfile(file): + continue + if not file.endswith("_cm.json") and not file.endswith("_cm.yaml"): + continue + script_path = os.path.dirname(file) + f = open(file) + if file.endswith(".json"): + data = json.load(f) + elif file.endswith(".yaml"): + data = yaml.safe_load(f) + uid = data['uid'] + + r = cm.access({'action':'test', 'automation':'script', 'artifact': uid, 'quiet': 'yes'}) + checks.check_return(r)