diff --git a/.github/workflows/run-individual-script-tests.yml b/.github/workflows/run-individual-script-tests.yml new file mode 100644 index 0000000000..8a4add3442 --- /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 0000000000..386110edf4 --- /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)