diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f17e54e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,105 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 45 + defaults: + run: + working-directory: robotframework-electron-vscode + steps: + - name: Check out the repository + uses: actions/checkout@v7 + with: + path: robotframework-electron-vscode + + # Until the adoptContext hook is in a Browser release, the workspace takes + # robotframework-browser from a clone next to the repository. + - name: Check out the Browser library with the adoptContext hook + uses: actions/checkout@v7 + with: + repository: d-biehl/robotframework-browser + ref: adopt-context-hook + path: robotframework-browser + + - uses: actions/setup-node@v7 + with: + node-version: 24 + + - uses: astral-sh/setup-uv@v10.3.0 + + - name: Install Xvfb and Openbox + run: sudo apt-get update && sudo apt-get install -y xvfb openbox + + # Ubuntu restricts unprivileged user namespaces, which the Chromium sandbox + # of Electron and VS Code needs. + - name: Allow the Chromium sandbox + run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 + + - name: Build the Browser library + working-directory: robotframework-browser + run: | + uv venv .venv + uv pip install --python .venv/bin/python pip -r Browser/dev-requirements.txt + . .venv/bin/activate + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 inv build + PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install --with-deps chromium + + # Not --locked: the lock file records the Browser clone's dependencies, + # which change with the branch. + - name: Install the workspace + run: uv sync + + - name: Unit tests + run: uv run pytest + + - name: Static analysis + run: uv run robotcode -r . analyze code + + - name: Acceptance tests + run: uv run robotcode -r . -p xvfb robot + + # Without the caches of the VS Code instances, but with their logs and settings. + - name: Upload the test results + if: always() + uses: actions/upload-artifact@v7 + with: + name: test-results + path: | + robotframework-electron-vscode/results/ + !robotframework-electron-vscode/results/vscode/*/user-data/Cached*/** + !robotframework-electron-vscode/results/vscode/*/user-data/*Cache/** + !robotframework-electron-vscode/results/vscode/*/user-data/Dictionaries/** + if-no-files-found: ignore + + build: + needs: test + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v7 + + - uses: astral-sh/setup-uv@v10.3.0 + + - name: Build the packages + run: uv build --all-packages -o dist + + - name: Upload the packages + uses: actions/upload-artifact@v7 + with: + name: packages + path: dist/ + if-no-files-found: error diff --git a/packages/vscode/atest/install_extension.robot b/packages/vscode/atest/install_extension.robot index 7fcd118..499c28f 100644 --- a/packages/vscode/atest/install_extension.robot +++ b/packages/vscode/atest/install_extension.robot @@ -30,12 +30,3 @@ Only The Given Instance Gets The Extension ${installed} = List Directories In Directory ${second_instance}/extensions robot.test-extension-* Length Should Be ${installed} 0 - -*** Keywords *** -Run Command From A Fresh Palette - [Arguments] ${title} - Keyboard Key press Escape - Keyboard Key press F1 - Keyboard Input type ${title} - Wait For Elements State .quick-input-list .monaco-list-row[aria-label*="${title}"] visible timeout=2s - Keyboard Key press Enter diff --git a/packages/vscode/atest/open_vs_code.robot b/packages/vscode/atest/open_vs_code.robot index 1762aa3..b1c711f 100644 --- a/packages/vscode/atest/open_vs_code.robot +++ b/packages/vscode/atest/open_vs_code.robot @@ -19,10 +19,8 @@ Local Installation Development Extension Is Active Open Test VS Code extension_development_path=${TEST_EXTENSION} - Keyboard Key press F1 - Keyboard Input type Robot Test: Say Hello - Get Text .quick-input-list .monaco-list-row[aria-label*="Robot Test: Say Hello"] *= Say Hello - Keyboard Key press Enter + # VS Code registers the commands of the development extension shortly after the start, and an open palette does not refresh. + Wait Until Keyword Succeeds 30s 1s Run Command From A Fresh Palette Robot Test: Say Hello Get Text .notifications-toasts .notification-list-item-message == Hello Robot Folder @@ -34,10 +32,8 @@ Video Of The Workbench ... extension_development_path=${TEST_EXTENSION} record_video=${{ {"size": {"width": 1280, "height": 800}} }} Should Start With ${page}[video_path] ${OUTPUT_DIR}${/}browser${/}video${/} Set Viewport Size 1280 800 - Keyboard Key press F1 - Keyboard Input type Robot Test: Say Hello - Wait For Elements State .quick-input-list .monaco-list-row[aria-label*="Robot Test: Say Hello"] visible - Keyboard Key press Enter + # VS Code registers the commands of the development extension shortly after the start, and an open palette does not refresh. + Wait Until Keyword Succeeds 30s 1s Run Command From A Fresh Palette Robot Test: Say Hello Get Text .notifications-toasts .notification-list-item-message == Hello Robot Close VS Code File Should Not Be Empty ${page}[video_path] diff --git a/packages/vscode/atest/resources/vscode.resource b/packages/vscode/atest/resources/vscode.resource index 592192a..eba32b6 100644 --- a/packages/vscode/atest/resources/vscode.resource +++ b/packages/vscode/atest/resources/vscode.resource @@ -25,3 +25,11 @@ VS Code Instance Has Exited [Arguments] ${instance} ${processes} = Count Processes With --user-data-dir=${instance}/user-data Should Be Equal As Integers ${processes} 0 + +Run Command From A Fresh Palette + [Arguments] ${title} + Keyboard Key press Escape + Keyboard Key press F1 + Keyboard Input type ${title} + Wait For Elements State .quick-input-list .monaco-list-row[aria-label*="${title}"] visible timeout=2s + Keyboard Key press Enter