Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress e2e initial infra #2548

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ node_modules
*.vsix
.pnpm-store
.Rproj.user

# Possible e2e tests deployment assets
test/e2e/content-workspace/**/.posit
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<!-- Copyright (C) 2024 by Posit Software, PBC. -->

<template>
<div v-if="home.initializingRequestComplete">
<div
v-if="home.initializingRequestComplete"
data-automation="publisher-deployment-section"
>
<div class="label">
<span class="text-sm text-sidebar-section-header">DEPLOYMENT</span>

Expand All @@ -20,7 +23,7 @@
:label="deploymentTitle"
:details="deploymentDetails"
:title="toolTipText"
:data-automation="`entrypoint-label`"
data-automation="entrypoint-label"
/>
<div
class="select-indicator codicon codicon-chevron-right"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<TreeSection
title="Credentials"
data-automation="credentials"
data-automation="publisher-credentials-section"
:actions="sectionActions"
:codicon="home.credential.active.isAlertActive ? `codicon-alert` : ``"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<TreeSection title="Help and Feedback">
<TreeSection
title="Help and Feedback"
data-automation="publisher-help-section"
>
<TreeItem
title="Get Started with Posit Publisher"
tooltip="Open Getting Started Documentation"
Expand Down
2 changes: 1 addition & 1 deletion scripts/get-platforms.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

CI="${CI:-false}"

platforms=("$(go env GOHOSTOS)/$(go env GOHOSTARCH)")
platforms="${USE_PLATFORM:-$(go env GOHOSTOS)/$(go env GOHOSTARCH)}"
if [ "$CI" = "true" ]; then
platforms=(
"darwin/amd64"
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,ts}": ["eslint --fix", "prettier --write"],
"!*.{js,ts}": "prettier --write --ignore-unknown"
}
61 changes: 61 additions & 0 deletions test/e2e/Dockerfile.connect
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Defines an image that installs connect-manager and a Connect DEB
# The Connect host to be used as the publishing target.

ARG IMAGE_OS=rstudio/connect:ubuntu22
FROM ubuntu:22.04 AS e2e-publisher-connect

ARG CONNECT_MANAGER_VERSION=0.5.1

# Install prerequisites
RUN apt-get update && apt-get install -y \
curl \
xz-utils

WORKDIR /opt/connect-manager

RUN curl -fsSL "https://cdn.rstudio.com/connect/connect-manager/${CONNECT_MANAGER_VERSION}/connect-manager-${CONNECT_MANAGER_VERSION}.tar.xz" | tar --strip-components=1 -xvJf -

RUN tar \
--strip-components=1 \
--exclude=PKG-INFO \
--exclude=README.md \
--exclude='*.egg-info' \
--exclude='setup.*' \
-xzvf connect-manager-*.tar.gz

RUN rm -f \
connect-manager-client-*.tar.gz \
connect_manager_client-*.whl

FROM ${IMAGE_OS}

# Install connect-manager
COPY --from=e2e-publisher-connect /opt/connect-manager /opt/connect-manager

# Pull Connect .deb
RUN curl -O https://cdn.posit.co/connect/2024.12/rstudio-connect_2024.12.0~ubuntu22_amd64.deb

RUN apt-get update \
&& apt-get install -y ./rstudio-connect_2024.12.0~ubuntu22_amd64.deb \
&& rm -rf rstudio-connect_2024.12.0~ubuntu22_amd64.deb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy Connect config
COPY test/e2e/config/connect.gcfg /etc/rstudio-connect/rstudio-connect.gcfg

# Copy Bootstrap Key
COPY test/e2e/bootstrap-secret.key /etc/rstudio-connect/bootstrap-secret.key

ENV CONNECT_LICENSE ${CONNECT_LICENSE}

CMD [ "/opt/connect-manager/connect-manager", \
"--start-connect", \
"--connect-binary", "/opt/rstudio-connect/bin/connect", \
"--connect-user", "rstudio-connect", \
"--license-manager-binary", "/opt/rstudio-connect/bin/license-manager", \
"--connect-log", "/var/log/rstudio/rstudio-connect/rstudio-connect.log", \
"--manager-log", "/var/log/rstudio/rstudio-connect/connect-manager.log", \
"--connect-config-prefix", "/etc/rstudio-connect", \
"--connect-config", "rstudio-connect.gcfg", \
"--manager-port", "4723" ]
13 changes: 13 additions & 0 deletions test/e2e/Dockerfile.cypress
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM cypress/browsers:node-18.20.3-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1

RUN mkdir /app
WORKDIR /app

COPY package*.json ./
RUN npm ci

ENV PATH /app/node_modules/.bin:$PATH

WORKDIR /app/e2e

CMD ["cypress", "run"]
7 changes: 7 additions & 0 deletions test/e2e/Dockerfile.vscode
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Defines an image that installs code-server and the Publisher extension to it

FROM codercom/code-server:39 AS code-server

WORKDIR /home/coder/workspace

ENTRYPOINT ["/home/coder/entrypoint.sh"]
1 change: 1 addition & 0 deletions test/e2e/bootstrap-secret.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bz/Y5QqRA8s1wn5hk86eSyFoQoovxmt1PwF3/E5P6wo=
25 changes: 25 additions & 0 deletions test/e2e/code-server-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu

# Get the latest linux-amd64 build
VSIX_FILENAME=$(ls -Art /home/coder/vsix | grep linux-amd64 | tail -n 1)

# Install the Publisher extension
code-server --install-extension "/home/coder/vsix/${VSIX_FILENAME}"

# Custom vscode User settings, avoid setup wizards
# echo > /home/coder/.local/share/code-server/User/settings.json
cat <<EOF > /home/coder/.local/share/code-server/User/settings.json

{
"remote.autoForwardPortsSource": "hybrid",
"workbench.settings.applyToAllProfiles": [],
"workbench.startupEditor": "none",
"window.restoreWindows": "none",
"files.hotExit": "off"
}

EOF

# Run the original code server entrypoint that starts the service
/usr/bin/entrypoint.sh --disable-workspace-trust --auth none --bind-addr 0.0.0.0:8080 .
40 changes: 40 additions & 0 deletions test/e2e/config/connect.gcfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
; Posit test/e2e configuration

[Server]
Address = http://localhost:3939/
SenderEmail = [email protected]
EmailProvider = print
DataDir = /var/lib/rstudio-connect
AllowConfirmedUsers = true
JumpStartEnabled = false

[Bootstrap]
Enabled = true
SecretKeyFile = /etc/rstudio-connect/bootstrap-secret.key

[SQLite]
Backup = false
ForeignKeyConstraints = true

[HTTP]
Listen = :3939
NoWarning = true

[Authentication]
Provider = password
InsecureDefaultUserAPIKey = true
APIKeyBcryptCost = 4

[Python]
Enabled = true
Executable = /opt/python/3.11.3/bin/python3
EnvironmentManagement = false

[Metrics]
Enabled = false

[RPackageRepository "CRAN"]
URL = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"

[R]
EnvironmentManagement = false
9 changes: 9 additions & 0 deletions test/e2e/config/waiton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This is a config file for the `wait-on` package.
// Used by the `startConnect` Cypress command.
module.exports = {
// Connect will respond with a 402 status code when the license is invalid.
// We want to allow Connect to load in that case.
validateStatus: function (status) {
return (status >= 200 && status < 300) || status == 402;
},
};
1 change: 1 addition & 0 deletions test/e2e/content-workspace/rmd-site/.Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
Empty file.
3 changes: 3 additions & 0 deletions test/e2e/content-workspace/rmd-site/another.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Another

Here is another page. It links to [index](index.html) and [article](article.html).
3 changes: 3 additions & 0 deletions test/e2e/content-workspace/rmd-site/article.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Article

This is an article. It has a link to [index](index.html) and [another](another.html).
3 changes: 3 additions & 0 deletions test/e2e/content-workspace/rmd-site/index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# R Markdown site

This is the index page. It has a link to [article](article.html) and [another](another.html).
Loading