| 1 | name: "Run VS Code E2E Test" |
| 2 | description: "Run a single VS Code E2E test with all required setup" |
| 3 | inputs: |
| 4 | test_file: |
| 5 | description: "E2E test file to run" |
| 6 | required: true |
| 7 | command: |
| 8 | description: "Command to run (e2e:ci:run or e2e:ci:run-yaml)" |
| 9 | required: true |
| 10 | ssh_key: |
| 11 | description: "SSH private key for testing" |
| 12 | required: false |
| 13 | ssh_host: |
| 14 | description: "SSH host for testing" |
| 15 | required: false |
| 16 | is_fork: |
| 17 | description: "Whether this is a fork (affects SSH tests)" |
| 18 | required: false |
| 19 | default: "false" |
| 20 | |
| 21 | runs: |
| 22 | using: "composite" |
| 23 | steps: |
| 24 | - uses: actions/setup-node@v4 |
| 25 | with: |
| 26 | node-version-file: ".nvmrc" |
| 27 | |
| 28 | - uses: actions/cache@v4 |
| 29 | id: vscode-node-modules-cache |
| 30 | with: |
| 31 | path: extensions/vscode/node_modules |
| 32 | key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} |
| 33 | |
| 34 | # We don't want to cache the Continue extension, so it is deleted at the end of the job |
| 35 | - uses: actions/cache@v4 |
| 36 | id: test-extensions-cache |
| 37 | with: |
| 38 | path: extensions/vscode/e2e/.test-extensions |
| 39 | key: CONSTANT |
| 40 | |
| 41 | - uses: actions/cache@v4 |
| 42 | id: storage-cache |
| 43 | with: |
| 44 | path: extensions/vscode/e2e/storage |
| 45 | key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }} |
| 46 | |
| 47 | - name: Download build artifact |
| 48 | uses: actions/download-artifact@v4 |
| 49 | with: |
| 50 | name: vscode-extension-build-Linux |
| 51 | path: extensions/vscode/build |
| 52 | |
| 53 | - name: Build packages and download e2e dependencies |
| 54 | shell: bash |
| 55 | run: | |
| 56 | node ./scripts/build-packages.js |
| 57 | if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then |
| 58 | cd core |
| 59 | npm ci |
| 60 | cd ../extensions/vscode |
| 61 | npm ci |
| 62 | npm run e2e:ci:download |
| 63 | else |
| 64 | cd core |
| 65 | npm ci |
| 66 | fi |
| 67 | |
| 68 | - name: Fix VSCode binary permissions |
| 69 | shell: bash |
| 70 | run: | |
| 71 | chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code |
| 72 | chmod +x extensions/vscode/e2e/storage/chromedriver-linux64/chromedriver |
| 73 | |
| 74 | - name: Set up SSH |
| 75 | if: ${{ inputs.ssh_key != '' && inputs.ssh_host != '' && inputs.is_fork == 'false' }} |
| 76 | shell: bash |
| 77 | env: |
| 78 | SSH_KEY: ${{ inputs.ssh_key }} |
| 79 | SSH_HOST: ${{ inputs.ssh_host }} |
| 80 | run: | |
| 81 | mkdir -p ~/.ssh |
| 82 | echo "$SSH_KEY" > ~/.ssh/id_rsa |
| 83 | chmod 600 ~/.ssh/id_rsa |
| 84 | ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts |
| 85 | echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config |
| 86 | |
| 87 | - name: Set up Xvfb |
| 88 | shell: bash |
| 89 | run: | |
| 90 | Xvfb :99 & |
| 91 | export DISPLAY=:99 |
| 92 | |
| 93 | - name: Run e2e tests |
| 94 | shell: bash |
| 95 | run: | |
| 96 | cd extensions/vscode |
| 97 | IGNORE_SSH_TESTS="${{ inputs.is_fork }}" TEST_FILE="${{ inputs.test_file }}" npm run ${{ inputs.command }} |
| 98 | env: |
| 99 | DISPLAY: :99 |
| 100 | |
| 101 | - name: Delete continue from test extensions |
| 102 | shell: bash |
| 103 | run: | |
| 104 | cd extensions/vscode |
| 105 | rm -rf e2e/.test-extensions/continue* |
| 106 | |
| 107 | - name: Sanitize test file name |
| 108 | id: sanitize_filename |
| 109 | if: always() |
| 110 | shell: bash |
| 111 | run: | |
| 112 | FILENAME="${{ inputs.test_file }}" |
| 113 | SANITIZED_FILENAME="${FILENAME//\//-}" # Replace / with - using bash parameter expansion |
| 114 | echo "sanitized_test_file=${SANITIZED_FILENAME}" >> $GITHUB_OUTPUT |
| 115 | |
| 116 | - name: Upload e2e test screenshots |
| 117 | if: failure() |
| 118 | uses: actions/upload-artifact@v4 |
| 119 | with: |
| 120 | name: e2e-failure-screenshots-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ inputs.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }} |
| 121 | path: extensions/vscode/e2e/storage/screenshots |
| 122 | |
| 123 | - name: Find e2e log file |
| 124 | if: always() |
| 125 | shell: bash |
| 126 | run: | |
| 127 | echo "Searching for e2e.log file..." |
| 128 | find $GITHUB_WORKSPACE -name "e2e.log" -type f |
| 129 | |
| 130 | - name: Upload e2e logs |
| 131 | if: always() |
| 132 | uses: actions/upload-artifact@v4 |
| 133 | with: |
| 134 | name: e2e-logs-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ inputs.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }} |
| 135 | path: extensions/vscode/e2e.log |