diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..3f6327f --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,51 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + pip install requests>=2.12.4, asyncssh>=1.16.1, matplotlib + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with pytest + env: + NCS_AUTH_TOKEN: ${{ secrets.NCS_AUTH_TOKEN }} + run: | + #pwd + #ls -al + ssh-keygen -q -f ~/.ssh/id_rsa -t rsa -N '' + #echo PYTHONPATH $PYTHONPATH + export PYTHONPATH=$PWD + export PATH=$PWD'/ncscli':$PATH + cd examples/batchMode + ./pytestQuick.sh + - name: Upload output data as artifacts + uses: actions/upload-artifact@v2 + with: + name: batchExamples-data-${{ matrix.python-version }} + path: examples/batchMode/data + # Use always() to always run this step to publish test results when there are test failures + if: ${{ always() }} diff --git a/examples/batchMode/pytestQuick.sh b/examples/batchMode/pytestQuick.sh index 63b930c..ee283bd 100755 --- a/examples/batchMode/pytestQuick.sh +++ b/examples/batchMode/pytestQuick.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -pytest -v --junitxml data/pytest.xml -o 'junit_family = xunit2' \ +pytest -v --rootdir . --junitxml data/pytest.xml -o 'junit_family = xunit2' \ --deselect test_runBatchExamples.py::test_runBatchBlender \ --deselect test_runBatchExamples.py::test_runBatchJMeter \ --deselect test_runBatchExamples.py::test_runBatchPuppeteerLighthouse diff --git a/examples/batchMode/test_runBatchExamples.py b/examples/batchMode/test_runBatchExamples.py index 4491610..d528b50 100644 --- a/examples/batchMode/test_runBatchExamples.py +++ b/examples/batchMode/test_runBatchExamples.py @@ -4,8 +4,12 @@ import json import os import re +import sys import subprocess +import pytest + + def check_batchRunner_results( jlogFilePath ): with open( jlogFilePath, 'r') as inFile: for line in inFile: @@ -27,6 +31,8 @@ def check_batchRunner_example( exampleName, frameFilePattern=None ): binPath = './' + exampleName + '.py' proc = subprocess.run( [binPath], stderr=subprocess.PIPE ) rc = proc.returncode + if rc: + print( proc.stderr.decode('utf-8'), file=sys.stderr ) assert rc==0, exampleName+' returned non-zero rc' stderr = proc.stderr.decode('utf-8') assert 'args.outDataDir' in stderr, 'no args.outDataDir in stderr' @@ -45,6 +51,14 @@ def check_batchRunner_example( exampleName, frameFilePattern=None ): def test_authToken(): assert os.getenv('NCS_AUTH_TOKEN'), 'env var NCS_AUTH_TOKEN not found' +def test_imports(): + import ncscli + import ncscli.batchRunner + +def test_path(): + subprocess.check_call( 'ncs.py --version', shell=True ) + +@pytest.mark.xfail def test_runBatchBinary(): # check if the built ARM executable already exists if not os.path.isfile('helloFrame_aarch64'): @@ -57,6 +71,7 @@ def test_runBatchBinary(): check_batchRunner_example( 'runBatchBinary', 'frame_*.out' ) +@pytest.mark.xfail def test_runBatchBinaryGo(): # check if the built ARM executable already exists if not os.path.isfile('helloFrameGo_aarch64'):