diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a253269..e954176 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -40,7 +40,7 @@ jobs: echo "Host: $FRONTEND_URL" npx wait-on "$FRONTEND_URL/service/control/health" kubectl wait --timeout 5m --for=condition=ready pod -l role=worker - ROOT_TEST_URL=$FRONTEND_URL npm run test + ROOT_TEST_URL=$FRONTEND_URL npm run test -- --forbid-only --retries 2 - name: Setup tmate session if: ${{ failure() }} uses: mxschmitt/action-tmate@v3 diff --git a/e2e/package.json b/e2e/package.json index f1d5dec..1db24c5 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -2,7 +2,7 @@ "name": "try-playwright", "version": "1.0.0", "scripts": { - "test": "folio -j 1 --retries 2 --reporter list" + "test": "folio -j 1 --reporter list" }, "repository": { "type": "git", diff --git a/e2e/tests/api.spec.ts b/e2e/tests/api.spec.ts index 053d604..0c04d55 100644 --- a/e2e/tests/api.spec.ts +++ b/e2e/tests/api.spec.ts @@ -15,6 +15,10 @@ function executeCode(code: string, language: string): Promise { }) } +function expectValidVersion(payload: any) { + expect(payload.version).toMatch(/^\d+.\d+.\d+$/) +} + describe("JavaScript", () => { it("can execute basic code", async () => { const code = `console.log(1 + 1)` @@ -23,7 +27,7 @@ describe("JavaScript", () => { const body = await resp.json() expect(body).toHaveProperty('success', true) expect(body).toHaveProperty('error', '') - expect(body).toHaveProperty('version', '') // TODO: add version + expectValidVersion(body) expect(body).toHaveProperty('files', []) expect(body).toHaveProperty('output', '2') }) @@ -36,7 +40,7 @@ describe("Python", () => { const body = await resp.json() expect(body).toHaveProperty('success', true) expect(body).toHaveProperty('error', '') - expect(body).toHaveProperty('version', '') // TODO: add version + expectValidVersion(body) expect(body).toHaveProperty('files', []) expect(body).toHaveProperty('output', '2') }) @@ -58,7 +62,7 @@ public class Example { const body = await resp.json() expect(body).toHaveProperty('success', true) expect(body).toHaveProperty('error', '') - expect(body).toHaveProperty('version', '') // TODO: add version + expectValidVersion(body) expect(body).toHaveProperty('files', []) expect(body).toHaveProperty('output', '2') }) @@ -84,7 +88,7 @@ namespace e2e const body = await resp.json() expect(body).toHaveProperty('success', true) expect(body).toHaveProperty('error', '') - expect(body).toHaveProperty('version', '') // TODO: add version + expectValidVersion(body) expect(body).toHaveProperty('files', []) expect(body).toHaveProperty('output', '2') }) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 49d8d8f..da9a989 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -107,7 +107,7 @@ func (w *Worker) consumeMessage(incomingMessages <-chan amqp.Delivery) error { if err := json.Unmarshal(incomingMessage.Body, &incomingMessageParsed); err != nil { return fmt.Errorf("could not parse incoming amqp message: %w", err) } - outgoingMessage := &workertypes.WorkerResponsePayload{} + outgoingMessage := &workertypes.WorkerResponsePayload{Version: os.Getenv("PLAYWRIGHT_VERSION")} if err := w.options.Handler(w, incomingMessageParsed.Code); err != nil { outgoingMessage.Success = false outgoingMessage.Error = err.Error() diff --git a/worker-csharp/Dockerfile b/worker-csharp/Dockerfile index c588f69..98a9110 100644 --- a/worker-csharp/Dockerfile +++ b/worker-csharp/Dockerfile @@ -1,3 +1,4 @@ +ARG PLAYWRIGHT_VERSION=1.9.2 FROM golang:1.16-buster as builder WORKDIR /root COPY go.mod /root/ @@ -8,7 +9,10 @@ COPY worker-csharp/main.go /root/ COPY internal/ /root/internal/ RUN CGO_ENABLED=0 GOOS=linux go build -o /app -FROM mcr.microsoft.com/playwright:v1.10.0-focal +FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-focal + +ARG PLAYWRIGHT_VERSION +ENV PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION RUN curl -o packages-microsoft-prod.deb https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && \ dpkg -i packages-microsoft-prod.deb && \ @@ -27,7 +31,7 @@ USER pwuser RUN mkdir /home/pwuser/project/ && \ cd /home/pwuser/project/ && \ dotnet new console && \ - dotnet add package PlaywrightSharp && \ + dotnet add package PlaywrightSharp --version ${PLAYWRIGHT_VERSION} && \ dotnet build && \ bin/Debug/net5.0/.playwright/unix/native/playwright.sh install && \ rm Program.cs diff --git a/worker-java/Dockerfile b/worker-java/Dockerfile index 33a5bba..53f3ac4 100644 --- a/worker-java/Dockerfile +++ b/worker-java/Dockerfile @@ -1,3 +1,4 @@ +ARG PLAYWRIGHT_VERSION=1.10.0 FROM golang:1.16-buster as builder WORKDIR /root COPY go.mod /root/ @@ -8,13 +9,17 @@ COPY worker-java/main.go /root/ COPY internal/ /root/internal/ RUN CGO_ENABLED=0 GOOS=linux go build -o /app -FROM mcr.microsoft.com/playwright/java:focal +FROM mcr.microsoft.com/playwright/java:focal-v$PLAYWRIGHT_VERSION RUN apt-get remove -y openjdk-11-jdk && \ apt-get install -y openjdk-14-jdk -ENV JAVA_HOME=/usr/lib/jvm/java-14-openjdk-amd64 +RUN apt-get remove -y python3.8 python3-pip git ssh xvfb curl nodejs && \ + apt-get autoremove -y +ENV JAVA_HOME=/usr/lib/jvm/java-14-openjdk-amd64 +ARG PLAYWRIGHT_VERSION +ENV PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION RUN adduser pwuser USER pwuser diff --git a/worker-java/pom.xml b/worker-java/pom.xml index a71af6b..fc0f693 100644 --- a/worker-java/pom.xml +++ b/worker-java/pom.xml @@ -14,7 +14,7 @@ com.microsoft.playwright playwright - 1.10.0 + ${env.PLAYWRIGHT_VERSION} diff --git a/worker-javascript/Dockerfile b/worker-javascript/Dockerfile index 7265f83..44373a6 100644 --- a/worker-javascript/Dockerfile +++ b/worker-javascript/Dockerfile @@ -1,3 +1,4 @@ +ARG PLAYWRIGHT_VERSION=1.10.0 FROM golang:1.16-buster as builder WORKDIR /root COPY go.mod /root/ @@ -8,14 +9,17 @@ COPY worker-javascript/main.go /root/ COPY internal/ /root/internal/ RUN CGO_ENABLED=0 GOOS=linux go build -o /app -FROM mcr.microsoft.com/playwright:v1.10.0-focal +FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-focal + +ARG PLAYWRIGHT_VERSION +ENV PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION RUN apt-get remove -y python3.8 python3-pip git ssh xvfb curl && \ apt-get autoremove -y WORKDIR /home/pwuser/ -RUN npm install -g playwright@1.10 +RUN npm install -g playwright@${PLAYWRIGHT_VERSION} USER pwuser diff --git a/worker-python/Dockerfile b/worker-python/Dockerfile index 9e20c59..bfa8e10 100644 --- a/worker-python/Dockerfile +++ b/worker-python/Dockerfile @@ -1,3 +1,4 @@ +ARG PLAYWRIGHT_VERSION=1.10.0 FROM golang:1.16-buster as builder WORKDIR /root COPY go.mod /root/ @@ -8,14 +9,17 @@ COPY worker-python/main.go /root/ COPY internal/ /root/internal/ RUN CGO_ENABLED=0 GOOS=linux go build -o /app -FROM mcr.microsoft.com/playwright:v1.10.0-focal +FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-focal + +ARG PLAYWRIGHT_VERSION +ENV PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION RUN apt-get remove -y git ssh xvfb curl && \ apt-get autoremove -y WORKDIR /home/pwuser/ -RUN pip install playwright==1.10.0 +RUN pip install playwright==${PLAYWRIGHT_VERSION} USER pwuser