Skip to content

Add conda env for pytest in aml-benchmark #15

Add conda env for pytest in aml-benchmark

Add conda env for pytest in aml-benchmark #15

name: aml-benchmark-test
on:
pull_request:
branches:
- main
paths:
- assets/aml-benchmark/**
- .github/workflows/aml-benchmark-test.yaml
workflow_dispatch:
env:
scripts_setup_dir: scripts/setup
conda_env_prefix: /opt/conda/envs/aml_benchmark
aml_benchmark_conda_yaml: assets/aml-benchmark/dev_conda_env.yaml
working_dir: assets/aml-benchmark/components/src
pytest_report_folder: pytest-reports
pytest_report_file: test-result.xml
jobs:
check-execution-context:
uses: Azure/azureml-assets/.github/workflows/check-execution-context.yaml@main
run-tests:
name: Run AML Benchmark Tests
runs-on: ubuntu-latest
needs: check-execution-context
environment: Testing
permissions:
# Required to clone repo
contents: read
# Required for OIDC login to Azure
id-token: write
# Required for EnricoMi/publish-unit-test-result-action
checks: write
issues: read
pull-requests: write
steps:
- name: Clone branch
uses: Azure/azureml-assets/.github/actions/clone-repo@main
with:
forked-pr: ${{ needs.check-execution-context.outputs.forked_pr }}
- name: Use Python 3.8
uses: actions/setup-python@v4
with:
python-version: '==3.8'
- name: Create conda env
run: |
set -ex
apt-get update && apt-get upgrade && apt-get install -y build-essential
echo ${{ env.conda_env_prefix }}
conda env create -p ${{ env.conda_env_prefix }} -f ${{ env.aml_benchmark_conda_yaml }} -q
echo "conda env successfully created at ${{ env.conda_env_prefix }}"
conda list -p ${{ env.conda_env_prefix }}
- name: Log in to Azure and create resources
uses: ./.github/actions/create-azure-resources
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
scripts-setup-dir: ${{ env.scripts_setup_dir }}
- name: Execute tests
run: |
cd ${{ env.working_dir }}
pwd
conda run -p ${{ env.conda_env_prefix }} python -m pytest ../../tests --junitxml=${{ env.pytest_report_folder }}/${{ env.pytest_report_file }} --tb=native -o log_level=DEBUG -n 8
env:
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
RESOURCE_GROUP: ${{ env.resource_group }}
WORKSPACE_NAME: ${{ env.workspace }}
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Test Results for ${{ github.workflow }}
junit_files: ${{ env.working_dir }}/${{ env.pytest_report_folder }}/**/*.xml