|
| 1 | +# --------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. |
| 4 | +# --------------------------------------------------------- |
| 5 | + |
| 6 | +name: azureml-tests |
| 7 | +description: "Submit experiment to AzureML cluster" |
| 8 | +inputs: |
| 9 | + # azureml experiment name |
| 10 | + EXP_NAME: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + # type of test - unit or nightly |
| 14 | + TEST_KIND: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + # test environment - cpu, gpu or spark |
| 18 | + TEST_ENV: |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + # azureml compute credentials |
| 22 | + AZUREML_TEST_CREDENTIALS: |
| 23 | + required: true |
| 24 | + type: string |
| 25 | + # azureml compute subid |
| 26 | + AZUREML_TEST_SUBID: |
| 27 | + required: true |
| 28 | + type: string |
| 29 | + # python version |
| 30 | + PYTHON_VERSION: |
| 31 | + required: true |
| 32 | + type: string |
| 33 | + # test group name |
| 34 | + TEST_GROUP: |
| 35 | + required: true |
| 36 | + type: string |
| 37 | + # cpu cluster name |
| 38 | + CPU_CLUSTER_NAME: |
| 39 | + required: false |
| 40 | + type: string |
| 41 | + default: "cpu-cluster" |
| 42 | + # gpu cluster name |
| 43 | + GPU_CLUSTER_NAME: |
| 44 | + required: false |
| 45 | + type: string |
| 46 | + default: "gpu-cluster" |
| 47 | + # AzureML resource group name |
| 48 | + RG: |
| 49 | + required: false |
| 50 | + type: string |
| 51 | + default: "recommenders_project_resources" |
| 52 | + # AzureML workspace name |
| 53 | + WS: |
| 54 | + required: false |
| 55 | + type: string |
| 56 | + default: "azureml-test-workspace" |
| 57 | + # test logs path |
| 58 | + TEST_LOGS_PATH: |
| 59 | + required: false |
| 60 | + type: string |
| 61 | + default: '"test_logs.log"' |
| 62 | + # pytest exit code |
| 63 | + PYTEST_EXIT_CODE: |
| 64 | + required: false |
| 65 | + type: string |
| 66 | + default: "pytest_exit_code.log" |
| 67 | + |
| 68 | +runs: |
| 69 | + using: "composite" |
| 70 | + steps: |
| 71 | + - name: Setup python |
| 72 | + uses: actions/setup-python@v2 |
| 73 | + with: |
| 74 | + python-version: "3.8" |
| 75 | + - name: Install azureml-core and azure-cli on a GitHub hosted server |
| 76 | + shell: bash |
| 77 | + run: pip install azureml-core azure-cli |
| 78 | + - name: Log in to Azure |
| 79 | + uses: azure/login@v1 |
| 80 | + with: |
| 81 | + creds: ${{inputs.AZUREML_TEST_CREDENTIALS}} |
| 82 | + - name: Install wheel package |
| 83 | + shell: bash |
| 84 | + run: pip install wheel |
| 85 | + - name: Create wheel from setup.py |
| 86 | + shell: bash |
| 87 | + run: python setup.py bdist_wheel |
| 88 | + - name: Extract branch name |
| 89 | + shell: bash |
| 90 | + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" |
| 91 | + id: extract_branch |
| 92 | + - name: Submit CPU tests to AzureML |
| 93 | + shell: bash |
| 94 | + if: contains(inputs.TEST_GROUP, 'cpu') |
| 95 | + run: >- |
| 96 | + python tests/ci/azureml_tests/submit_groupwise_azureml_pytest.py --clustername ${{inputs.CPU_CLUSTER_NAME}} |
| 97 | + --subid ${{inputs.AZUREML_TEST_SUBID}} --reponame "recommenders" --branch ${{ steps.extract_branch.outputs.branch }} |
| 98 | + --rg ${{inputs.RG}} --wsname ${{inputs.WS}} --expname ${{inputs.EXP_NAME}}_${{inputs.TEST_GROUP}} |
| 99 | + --testlogs ${{inputs.TEST_LOGS_PATH}} --testkind ${{inputs.TEST_KIND}} |
| 100 | + --conda_pkg_python ${{inputs.PYTHON_VERSION}} --testgroup ${{inputs.TEST_GROUP}} |
| 101 | + - name: Submit GPU tests to AzureML |
| 102 | + shell: bash |
| 103 | + if: contains(inputs.TEST_GROUP, 'gpu') |
| 104 | + run: >- |
| 105 | + python tests/ci/azureml_tests/submit_groupwise_azureml_pytest.py --clustername ${{inputs.GPU_CLUSTER_NAME}} |
| 106 | + --subid ${{inputs.AZUREML_TEST_SUBID}} --reponame "recommenders" --branch ${{ steps.extract_branch.outputs.branch }} |
| 107 | + --rg ${{inputs.RG}} --wsname ${{inputs.WS}} --expname ${{inputs.EXP_NAME}}_${{inputs.TEST_GROUP}} |
| 108 | + --testlogs ${{inputs.TEST_LOGS_PATH}} --add_gpu_dependencies --testkind ${{inputs.TEST_KIND}} |
| 109 | + --conda_pkg_python ${{inputs.PYTHON_VERSION}} --testgroup ${{inputs.TEST_GROUP}} |
| 110 | + - name: Submit PySpark tests to AzureML |
| 111 | + shell: bash |
| 112 | + if: contains(inputs.TEST_GROUP, 'spark') |
| 113 | + run: >- |
| 114 | + python tests/ci/azureml_tests/submit_groupwise_azureml_pytest.py --clustername ${{inputs.CPU_CLUSTER_NAME}} |
| 115 | + --subid ${{inputs.AZUREML_TEST_SUBID}} --reponame "recommenders" --branch ${{ steps.extract_branch.outputs.branch }} |
| 116 | + --rg ${{inputs.RG}} --wsname ${{inputs.WS}} --expname ${{inputs.EXP_NAME}}_${{inputs.TEST_GROUP}} |
| 117 | + --testlogs ${{inputs.TEST_LOGS_PATH}} --add_spark_dependencies --testkind ${{inputs.TEST_KIND}} |
| 118 | + --conda_pkg_python ${{inputs.PYTHON_VERSION}} --testgroup ${{inputs.TEST_GROUP}} |
| 119 | + - name: Print test logs |
| 120 | + shell: bash |
| 121 | + run: cat ${{inputs.TEST_LOGS_PATH}} |
| 122 | + - name: Get exit status |
| 123 | + shell: bash |
| 124 | + id: exit_status |
| 125 | + run: echo ::set-output name=code::$(cat ${{inputs.PYTEST_EXIT_CODE}}) |
| 126 | + - name: Check Success/Failure |
| 127 | + if: ${{ steps.execute_tests.outputs.code != 0 }} |
| 128 | + uses: actions/github-script@v3 |
| 129 | + with: |
| 130 | + script: | |
| 131 | + core.setFailed('All tests did not pass!') |
0 commit comments