|
| 1 | +name: cloud-testing |
| 2 | + |
| 3 | +# Used to run the e2e tests on lightning.ai |
| 4 | + |
| 5 | +on: # Trigger the workflow on push or pull request, but only for the master branch |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "master" |
| 9 | + pull_request: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} |
| 13 | + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + # This is job should once only once per PR to detect file changes so run required jobs. |
| 17 | + # see .github/file-filters.yml to define file filters and run the jobs based on the output of each filter. |
| 18 | + # More info: https://github.com/marketplace/actions/paths-changes-filter |
| 19 | + |
| 20 | + changes: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + # Set job outputs to the values from filter step |
| 23 | + outputs: |
| 24 | + app_examples: ${{ steps.filter.outputs.app_examples }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + - name: Set up Python 3.8 |
| 28 | + uses: actions/setup-python@v2 |
| 29 | + with: |
| 30 | + python-version: "3.8" |
| 31 | + |
| 32 | + - uses: dorny/paths-filter@v2 |
| 33 | + id: filter |
| 34 | + with: |
| 35 | + filters: .github/file-filters.yml |
| 36 | + |
| 37 | + cloud-test: |
| 38 | + name: Cloud Test |
| 39 | + needs: changes |
| 40 | + if: ${{ needs.changes.outputs.app_examples == 'true' }} |
| 41 | + runs-on: ubuntu-20.04 |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + app_name: |
| 46 | + - v0_app |
| 47 | + - boring_app |
| 48 | +# - quick_start # TODO: fix this |
| 49 | + - template_streamlit_ui |
| 50 | + - template_react_ui |
| 51 | + - template_jupyterlab |
| 52 | + - idle_timeout |
| 53 | + - collect_failures |
| 54 | + - custom_work_dependencies |
| 55 | + - drive |
| 56 | + - payload |
| 57 | + timeout-minutes: 35 |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v2 |
| 60 | + - name: Set up Python 3.8 |
| 61 | + uses: actions/setup-python@v2 |
| 62 | + with: |
| 63 | + python-version: "3.8" |
| 64 | + |
| 65 | + - name: Get PR ID |
| 66 | + id: PR |
| 67 | + run: | |
| 68 | + if [ -z ${{github.event.number}} ]; then |
| 69 | + echo "::set-output name=ID::$(date +%s)" |
| 70 | + else |
| 71 | + echo "::set-output name=ID::${{github.event.number}}" |
| 72 | + fi |
| 73 | +
|
| 74 | +# TODO: Enable cache |
| 75 | +# - name: Cache virtualenv |
| 76 | +# id: cache-venv |
| 77 | +# uses: actions/cache@v2 |
| 78 | +# with: |
| 79 | +# path: ./.venv/ |
| 80 | +# key: ${{ runner.os }}-pip-${{ matrix.app_name }}-${{ hashFiles('requirements/app/base.txt', 'requirements/app/*.txt', 'src/lightning_app/__version__.py') }} |
| 81 | +# restore-keys: ${{ runner.os }}-venv-${{ matrix.app_name }}- |
| 82 | + |
| 83 | + - name: Install dependencies |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + pip --version |
| 87 | + python -m pip install -r requirements/app/devel.txt --no-cache --quiet --find-links https://download.pytorch.org/whl/cpu/torch_stable.html |
| 88 | +# if: steps.cache-venv.outputs.cache-hit != 'true' # TODO: Enable cache |
| 89 | + |
| 90 | + - name: Cache Playwright dependencies |
| 91 | + id: playwright-cache |
| 92 | + uses: actions/cache@v2 |
| 93 | + with: |
| 94 | + path: ~/.cache/ms-playwright |
| 95 | + key: ${{ runner.os }}-playwright-${{ matrix.app_name }}-${{ hashFiles('requirements/app/base.txt', 'requirements/app/*.txt', 'src/lightning_app/__version__.py') }} |
| 96 | + restore-keys: ${{ runner.os }}-playwright-${{ matrix.app_name }}- |
| 97 | + |
| 98 | + - name: Install Playwright system dependencies |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + python -m pip install playwright |
| 102 | + python -m playwright install --with-deps |
| 103 | +# if: steps.playwright-cache.outputs.cache-hit != 'true' # TODO: Enable cache |
| 104 | + |
| 105 | + - name: Install lightning |
| 106 | + run: | |
| 107 | + pip install -e . |
| 108 | + shell: bash |
| 109 | + |
| 110 | + - name: Lightning Install quick-start |
| 111 | + if: ${{ (matrix.app_name == 'quick_start') }} |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + python -m lightning install app lightning/quick-start -y |
| 115 | +
|
| 116 | + - name: Clone Template React UI Repo |
| 117 | + uses: actions/checkout@v3 |
| 118 | + with: |
| 119 | + repository: Lightning-AI/lightning-template-react |
| 120 | + token: ${{ secrets.PAT_GHOST }} |
| 121 | + ref: 'master' |
| 122 | + path: examples/app_template_react_ui |
| 123 | + |
| 124 | + - name: Clone Template Jupyter Lab Repo |
| 125 | + uses: actions/checkout@v3 |
| 126 | + with: |
| 127 | + repository: Lightning-AI/lightning-template-jupyterlab |
| 128 | + token: ${{ secrets.PAT_GHOST }} |
| 129 | + ref: 'master' |
| 130 | + path: examples/app_template_jupyterlab |
| 131 | + |
| 132 | + - name: Copy Template Jupyter Lab Repo tests |
| 133 | + shell: bash |
| 134 | + run: cp examples/app_template_jupyterlab/tests/test_template_jupyterlab.py tests/tests_app_examples/test_template_jupyterlab.py |
| 135 | + |
| 136 | + - name: List pip dependency |
| 137 | + shell: bash |
| 138 | + run: | |
| 139 | + pip list |
| 140 | +
|
| 141 | + - name: Run the tests |
| 142 | + env: |
| 143 | + LAI_USER: ${{ secrets.LAI_USER }} |
| 144 | + LAI_PASS: ${{ secrets.LAI_PASS }} |
| 145 | + LIGHTNING_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} |
| 146 | + LIGHTNING_API_KEY: ${{ secrets.LIGHTNING_API_KEY }} |
| 147 | + LIGHTNING_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} |
| 148 | + LIGHTNING_CLOUD_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} |
| 149 | + CLOUD: "1" |
| 150 | + VIDEO_LOCATION: ./artifacts/videos |
| 151 | + PR_NUMBER: ${{ steps.PR.outputs.ID }} |
| 152 | + TEST_APP_NAME: ${{ matrix.app_name }} |
| 153 | + HAR_LOCATION: ./artifacts/hars |
| 154 | + SLOW_MO: 50 |
| 155 | + shell: bash |
| 156 | + run: | |
| 157 | + mkdir -p ${VIDEO_LOCATION} |
| 158 | + HEADLESS=1 python -m pytest tests/tests_app_examples/test_${{ matrix.app_name }}.py::test_${{ matrix.app_name }}_example_cloud --timeout=900 --capture=no -v --color=yes |
| 159 | + # Delete the artifacts if successful |
| 160 | + rm -r ${VIDEO_LOCATION}/${{ matrix.app_name }} |
| 161 | +
|
| 162 | + - uses: actions/upload-artifact@v2 |
| 163 | + |
| 164 | + if: ${{ always() }} |
| 165 | + with: |
| 166 | + name: test-artifacts |
| 167 | + path: ./artifacts/videos |
| 168 | + |
| 169 | + - name: Clean Previous Apps |
| 170 | + if: ${{ always() }} |
| 171 | + env: |
| 172 | + LAI_USER: ${{ secrets.LAI_USER }} |
| 173 | + LAI_PASS: ${{ secrets.LAI_PASS }} |
| 174 | + LIGHTNING_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} |
| 175 | + LIGHTNING_API_KEY: ${{ secrets.LIGHTNING_API_KEY }} |
| 176 | + LIGHTNING_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} |
| 177 | + LIGHTNING_CLOUD_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} |
| 178 | + PR_NUMBER: ${{ steps.PR.outputs.ID }} |
| 179 | + TEST_APP_NAME: ${{ matrix.app_name }} |
| 180 | + GRID_USER_ID: ${{ secrets.LIGHTNING_USER_ID }} |
| 181 | + GRID_USER_KEY: ${{ secrets.LIGHTNING_API_KEY }} |
| 182 | + GRID_URL: ${{ secrets.LIGHTNING_CLOUD_URL }} |
| 183 | + _GRID_USERNAME: ${{ secrets.LIGHTNING_USERNAME }} |
| 184 | + shell: bash |
| 185 | + run: | |
| 186 | + time python -c "from lightning.app import testing; testing.delete_cloud_lightning_apps()" |
0 commit comments