|
| 1 | +# Python package |
| 2 | +# Create and test a Python package on multiple Python versions. |
| 3 | +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: |
| 4 | +# https://docs.microsoft.com/azure/devops/pipelines/languages/python |
| 5 | + |
| 6 | +trigger: |
| 7 | + tags: |
| 8 | + include: |
| 9 | + - '*' |
| 10 | + branches: |
| 11 | + include: |
| 12 | + - "master" |
| 13 | + - "release/*" |
| 14 | + - "refs/tags/*" |
| 15 | + paths: |
| 16 | + include: |
| 17 | + - ".azure/app-cloud-e2e.yml" |
| 18 | + - "requirements/app/**" |
| 19 | + - "src/lightning_app/**" |
| 20 | + - "examples/app_*" |
| 21 | + |
| 22 | +pr: |
| 23 | + branches: |
| 24 | + include: |
| 25 | + - "master" |
| 26 | + - "release/*" |
| 27 | + paths: |
| 28 | + include: |
| 29 | + - ".azure/app-cloud-e2e.yml" |
| 30 | + - "requirements/app/**" |
| 31 | + - "src/lightning_app/**" |
| 32 | + - "examples/app_*" |
| 33 | + |
| 34 | +# variables are automatically exported as environment variables so this will override pip's default cache dir |
| 35 | +variables: |
| 36 | + - name: pip_cache_dir |
| 37 | + value: $(Pipeline.Workspace)/.pip |
| 38 | + - name: local_id |
| 39 | + value: $(Build.BuildId) |
| 40 | + |
| 41 | +jobs: |
| 42 | + - job: App_cloud_e2e_testing |
| 43 | + pool: azure-cpus |
| 44 | + container: |
| 45 | + image: mcr.microsoft.com/playwright/python:v1.25.2-focal |
| 46 | + options: "--shm-size=2g" |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + 'App: v0_app': |
| 50 | + name: "v0_app" |
| 51 | + 'App: boring_app': |
| 52 | + name: "boring_app" |
| 53 | + 'App: template_streamlit_ui': |
| 54 | + name: "template_streamlit_ui" |
| 55 | + 'App: template_react_ui': |
| 56 | + name: "template_react_ui" |
| 57 | + 'App: template_jupyterlab': # TODO: clarify where these files lives |
| 58 | + name: "template_jupyterlab" |
| 59 | + 'App: idle_timeout': |
| 60 | + name: "idle_timeout" |
| 61 | + 'App: collect_failures': |
| 62 | + name: "collect_failures" |
| 63 | + 'App: custom_work_dependencies': |
| 64 | + name: "custom_work_dependencies" |
| 65 | + 'App: drive': |
| 66 | + name: "drive" |
| 67 | + 'App: payload': |
| 68 | + name: "payload" |
| 69 | + 'App: commands_and_api': |
| 70 | + name: "commands_and_api" |
| 71 | + timeoutInMinutes: "30" |
| 72 | + cancelTimeoutInMinutes: "2" |
| 73 | + # values: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace |
| 74 | + workspace: |
| 75 | + clean: all |
| 76 | + steps: |
| 77 | + |
| 78 | + - script: echo '##vso[task.setvariable variable=local_id]$(System.PullRequest.PullRequestNumber)' |
| 79 | + displayName: "Set id for this PR" |
| 80 | + condition: eq(variables['Build.Reason'], 'PullRequest') |
| 81 | + |
| 82 | + - bash: | |
| 83 | + whoami |
| 84 | + printf "local id: $(local_id)\n" |
| 85 | + python --version |
| 86 | + pip --version |
| 87 | + displayName: 'Info' |
| 88 | +
|
| 89 | + - task: Cache@2 |
| 90 | + inputs: |
| 91 | + key: 'pip | "$(name)" | requirements/app/base.txt' |
| 92 | + restoreKeys: | |
| 93 | + pip | "$(Agent.OS)" |
| 94 | + path: $(pip_cache_dir) |
| 95 | + displayName: Cache pip |
| 96 | + |
| 97 | + - bash: python -m pip install -r requirements/app/devel.txt --quiet --find-links ${TORCH_URL} |
| 98 | + env: |
| 99 | + TORCH_URL: https://download.pytorch.org/whl/cpu/torch_stable.html |
| 100 | + displayName: 'Install dependencies' |
| 101 | + |
| 102 | + - bash: | |
| 103 | + python -m pip install playwright |
| 104 | + python -m playwright install # --with-deps |
| 105 | + displayName: 'Install Playwright system dependencies' |
| 106 | +
|
| 107 | + - bash: pip install -e . --find-links https://download.pytorch.org/whl/cpu/torch_stable.html |
| 108 | + displayName: 'Install lightning' |
| 109 | + |
| 110 | + - bash: | |
| 111 | + git clone https://github.com/Lightning-AI/LAI-lightning-template-jupyterlab-App examples/app_template_jupyterlab |
| 112 | + cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_app_examples/test_template_jupyterlab.py |
| 113 | + condition: eq(variables['name'], 'template_jupyterlab') |
| 114 | + displayName: 'Clone Template Jupyter Lab Repo' |
| 115 | +
|
| 116 | + - bash: git clone https://github.com/Lightning-AI/lightning-template-react examples/app_template_react_ui |
| 117 | + condition: eq(variables['name'], 'template_react_ui') |
| 118 | + displayName: 'Clone Template React UI Repo' |
| 119 | + |
| 120 | + - bash: | |
| 121 | + mkdir -p ${VIDEO_LOCATION} |
| 122 | + ls -l examples/${TEST_APP_NAME} |
| 123 | + ls -l tests/tests_app_examples |
| 124 | + python -m pytest tests/tests_app_examples/test_${TEST_APP_NAME}.py::test_${TEST_APP_NAME}_example_cloud --timeout=900 --capture=no -v --color=yes |
| 125 | + env: |
| 126 | + HEADLESS: '1' |
| 127 | + PACKAGE_LIGHTNING: '1' |
| 128 | + CLOUD: '1' |
| 129 | + VIDEO_LOCATION: '$(Build.ArtifactStagingDirectory)/videos' |
| 130 | + PR_NUMBER: $(local_id) |
| 131 | + TEST_APP_NAME: $(name) |
| 132 | + HAR_LOCATION: './artifacts/hars' |
| 133 | + SLOW_MO: '50' |
| 134 | + # LAI_USER: $(LAI_USER) |
| 135 | + # LAI_PASS: $(LAI_PASS) |
| 136 | + LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) |
| 137 | + LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) |
| 138 | + LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) |
| 139 | + LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) |
| 140 | + displayName: 'Run the tests' |
| 141 | +
|
| 142 | + - publish: '$(Build.ArtifactStagingDirectory)/videos' |
| 143 | + condition: failed() |
| 144 | + displayName: 'Publish videos' |
| 145 | + artifact: $(name) |
| 146 | + |
| 147 | + - bash: | |
| 148 | + time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()" |
| 149 | + condition: always() |
| 150 | + env: |
| 151 | + # LAI_USER: $(LAI_USER) |
| 152 | + # LAI_PASS: $(LAI_PASS) |
| 153 | + LIGHTNING_USER_ID: $(LIGHTNING_USER_ID_PROD) |
| 154 | + LIGHTNING_API_KEY: $(LIGHTNING_API_KEY_PROD) |
| 155 | + LIGHTNING_USERNAME: $(LIGHTNING_USERNAME) |
| 156 | + LIGHTNING_CLOUD_URL: $(LIGHTNING_CLOUD_URL_PROD) |
| 157 | + PR_NUMBER: $(local_id) |
| 158 | + TEST_APP_NAME: $(name) |
| 159 | + # GRID_USER_ID: $(LIGHTNING_USER_ID) # TODO: clarify the meaning |
| 160 | + # GRID_USER_KEY: $(LIGHTNING_API_KEY) # TODO: clarify the meaning |
| 161 | + # GRID_URL: $(LIGHTNING_CLOUD_URL) |
| 162 | + # _GRID_USERNAME: $(LIGHTNING_USERNAME) |
| 163 | + displayName: 'Clean Previous Apps' |
0 commit comments