From 18bf37e335f511d919fc79ec7ef4b11b9b90ca79 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Wed, 7 Aug 2024 16:23:17 +0200 Subject: [PATCH 1/9] feat: add Dockerfie for running tauri e2e tests ono mac --- Dockerfile | 20 ++++++++++++++++++++ apps/desktop/wdio.conf.ts | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..04ffdc2707 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM ivangabriele/tauri:debian-bullseye-18 AS build + +ENV DOCKER 1 +WORKDIR /build + +COPY .nvmrc /build +COPY package.json /build + +# Ensure our defined version of node is installed +RUN curl -sfLS "https://install-node.vercel.app/$(cat .nvmrc)" | bash -s -- --force + +# Ensure our defined version of pnpm is installed and used +RUN corepack enable pnpm && corepack install + +WORKDIR /app + +# COPY ./target/release/git-butler-dev /bin/git-butler-dev + +# CMD xvfb-run pnpm test:e2e +CMD /bin/bash diff --git a/apps/desktop/wdio.conf.ts b/apps/desktop/wdio.conf.ts index 53c31dd8db..26559cb1c2 100644 --- a/apps/desktop/wdio.conf.ts +++ b/apps/desktop/wdio.conf.ts @@ -6,6 +6,10 @@ import type { Options } from '@wdio/types'; let tauriDriver: ChildProcess; +const appBinaryPath = process.env.DOCKER + ? '/bin/git-butler-dev' + : '../../target/release/git-butler-dev'; + export const config: Options.WebdriverIO = { hostname: '127.0.0.1', port: 4444, @@ -15,7 +19,7 @@ export const config: Options.WebdriverIO = { { // @ts-expect-error custom tauri capabilities 'tauri:options': { - application: '../../target/release/git-butler-dev' + application: appBinaryPath } } ], @@ -38,10 +42,14 @@ export const config: Options.WebdriverIO = { connectionRetryCount: 3, // ensure we are running `tauri-driver` before the session starts so that we can proxy the webdriver requests - beforeSession: () => - (tauriDriver = spawn(path.resolve(os.homedir(), '.cargo', 'bin', 'tauri-driver'), [], { + beforeSession: () => { + const tauriDriverPath = process.env.DOCKER + ? 'tauri-driver' + : path.resolve(os.homedir(), '.cargo', 'bin', 'tauri-driver'); + tauriDriver = spawn(tauriDriverPath, [], { stdio: [null, process.stdout, process.stderr] - })), + }); + }, afterTest: function ({ error }: { error: Error }) { if (error) { From 1ee70d22b762701fd9a1436a2f288990cc351e23 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Wed, 7 Aug 2024 17:12:16 +0200 Subject: [PATCH 2/9] feat: add Dockerfile and minor wdio adjustments --- Dockerfile | 18 ++++++++++++++++-- apps/desktop/wdio.conf.ts | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 04ffdc2707..f9412ef023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1.7-labs + FROM ivangabriele/tauri:debian-bullseye-18 AS build ENV DOCKER 1 @@ -6,14 +8,26 @@ WORKDIR /build COPY .nvmrc /build COPY package.json /build -# Ensure our defined version of node is installed RUN curl -sfLS "https://install-node.vercel.app/$(cat .nvmrc)" | bash -s -- --force -# Ensure our defined version of pnpm is installed and used RUN corepack enable pnpm && corepack install +RUN --mount=type=bind,source=.,target=/build,rw \ + pnpm build:test + +FROM scratch + +LABEL version="0.0.1" +LABEL description="GitButler Darwin E2E Test Environment" + WORKDIR /app +COPY --from=build /build/target/release/git-butler-dev /app/git-butler-dev + +# Debug niceties +RUN apt install -y vim && \ + echo "alias ll='ls -lah' >> ~/.bashrc" + # COPY ./target/release/git-butler-dev /bin/git-butler-dev # CMD xvfb-run pnpm test:e2e diff --git a/apps/desktop/wdio.conf.ts b/apps/desktop/wdio.conf.ts index 26559cb1c2..314219de86 100644 --- a/apps/desktop/wdio.conf.ts +++ b/apps/desktop/wdio.conf.ts @@ -7,7 +7,7 @@ import type { Options } from '@wdio/types'; let tauriDriver: ChildProcess; const appBinaryPath = process.env.DOCKER - ? '/bin/git-butler-dev' + ? '/app/git-butler-dev' : '../../target/release/git-butler-dev'; export const config: Options.WebdriverIO = { From d6c18baaa418014001dd74ec6288dfab20d4ab26 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Wed, 7 Aug 2024 17:18:47 +0200 Subject: [PATCH 3/9] fix: cleanup Dockerfile and add comments --- Dockerfile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9412ef023..ec835adfd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,35 @@ -# syntax=docker/dockerfile:1.7-labs - -FROM ivangabriele/tauri:debian-bullseye-18 AS build +FROM ivangabriele/tauri:debian-bullseye-18 ENV DOCKER 1 WORKDIR /build +# Copy required files for installing node and pnpm COPY .nvmrc /build COPY package.json /build +# Install node from our .nvmrc RUN curl -sfLS "https://install-node.vercel.app/$(cat .nvmrc)" | bash -s -- --force +# Enable and use our defined `packageManager` version of pnpm RUN corepack enable pnpm && corepack install +# Mount the source code into the container and build a test binary of GitButler +# tauri-driver requires a binary to instrument and execute, against which +# the tests will eventually run +# TODO: It would be great to be able to avoid building this here, but we need: +# - a binary based on the current state of the source code on the persons machine +# - a binary built for their current arch (i.e. amd64/aarch64) RUN --mount=type=bind,source=.,target=/build,rw \ pnpm build:test -FROM scratch - -LABEL version="0.0.1" -LABEL description="GitButler Darwin E2E Test Environment" - WORKDIR /app -COPY --from=build /build/target/release/git-butler-dev /app/git-butler-dev +# Currently borked :thinking: +# COPY /build/target/release/git-butler-dev /app/git-butler-dev -# Debug niceties +# TODO: Remove debug helpers RUN apt install -y vim && \ echo "alias ll='ls -lah' >> ~/.bashrc" -# COPY ./target/release/git-butler-dev /bin/git-butler-dev - # CMD xvfb-run pnpm test:e2e CMD /bin/bash From f9f17b58ba82541ff96347fb835b58d1c946309b Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 10:13:56 +0200 Subject: [PATCH 4/9] fix: add dockerignore --- .dockerignore | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..eb5a316cbd --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target diff --git a/Dockerfile b/Dockerfile index ec835adfd0..42b4cb0af1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN corepack enable pnpm && corepack install # the tests will eventually run # TODO: It would be great to be able to avoid building this here, but we need: # - a binary based on the current state of the source code on the persons machine -# - a binary built for their current arch (i.e. amd64/aarch64) +# - a binary built for their current arch (i.e. amd64/aarch64) (? Maybe docker + rosetta makes this a non-issue) RUN --mount=type=bind,source=.,target=/build,rw \ pnpm build:test From f8d3cfd31ef916800ff69d76aa03dba4fb12f0b4 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 11:42:34 +0200 Subject: [PATCH 5/9] fix: simplify Dockerfile to only run mounted in binary --- Dockerfile | 11 ++--------- apps/desktop/wdio.conf.ts | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 42b4cb0af1..d84ddef26c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,17 +19,10 @@ RUN corepack enable pnpm && corepack install # TODO: It would be great to be able to avoid building this here, but we need: # - a binary based on the current state of the source code on the persons machine # - a binary built for their current arch (i.e. amd64/aarch64) (? Maybe docker + rosetta makes this a non-issue) -RUN --mount=type=bind,source=.,target=/build,rw \ - pnpm build:test +# RUN --mount=type=bind,source=.,target=/build,rw \ +# pnpm build:test WORKDIR /app -# Currently borked :thinking: -# COPY /build/target/release/git-butler-dev /app/git-butler-dev - -# TODO: Remove debug helpers -RUN apt install -y vim && \ - echo "alias ll='ls -lah' >> ~/.bashrc" - # CMD xvfb-run pnpm test:e2e CMD /bin/bash diff --git a/apps/desktop/wdio.conf.ts b/apps/desktop/wdio.conf.ts index 314219de86..68fb6d876d 100644 --- a/apps/desktop/wdio.conf.ts +++ b/apps/desktop/wdio.conf.ts @@ -7,7 +7,7 @@ import type { Options } from '@wdio/types'; let tauriDriver: ChildProcess; const appBinaryPath = process.env.DOCKER - ? '/app/git-butler-dev' + ? '/app/target/release/git-butler-dev' : '../../target/release/git-butler-dev'; export const config: Options.WebdriverIO = { From 768e0cdad6762b7848f09ba22e8c5f0c484a5367 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 13:46:37 +0200 Subject: [PATCH 6/9] fix: ignore e2e screenshots/video artifacts --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ba04df6dbf..7931417144 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ generated-do-not-edit/ .sentryclirc .DS_Store +**/e2e/screenshots +**/e2e/videos .env .env.* From 77d2441b1b272d3a214bcebc735ae7aa610adb2e Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 13:48:55 +0200 Subject: [PATCH 7/9] fix: Dockerfile install and build deps in container --- Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d84ddef26c..bc536ef57f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,14 +4,17 @@ ENV DOCKER 1 WORKDIR /build # Copy required files for installing node and pnpm -COPY .nvmrc /build -COPY package.json /build +# COPY .nvmrc /build +# COPY package.json /build +COPY . /build -# Install node from our .nvmrc +# Install specific node version from our .nvmrc RUN curl -sfLS "https://install-node.vercel.app/$(cat .nvmrc)" | bash -s -- --force # Enable and use our defined `packageManager` version of pnpm -RUN corepack enable pnpm && corepack install +RUN corepack enable pnpm \ + && corepack install \ + && pnpm install # Mount the source code into the container and build a test binary of GitButler # tauri-driver requires a binary to instrument and execute, against which @@ -20,9 +23,9 @@ RUN corepack enable pnpm && corepack install # - a binary based on the current state of the source code on the persons machine # - a binary built for their current arch (i.e. amd64/aarch64) (? Maybe docker + rosetta makes this a non-issue) # RUN --mount=type=bind,source=.,target=/build,rw \ -# pnpm build:test +RUN pnpm build:test -WORKDIR /app +# WORKDIR /app # CMD xvfb-run pnpm test:e2e CMD /bin/bash From 6ef1e2507aa8246163453c8b1db640e6a03a4e18 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 14:00:40 +0200 Subject: [PATCH 8/9] fix: wdio conf binary target path in container --- apps/desktop/wdio.conf.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/wdio.conf.ts b/apps/desktop/wdio.conf.ts index 68fb6d876d..bbbaa13d9b 100644 --- a/apps/desktop/wdio.conf.ts +++ b/apps/desktop/wdio.conf.ts @@ -7,7 +7,7 @@ import type { Options } from '@wdio/types'; let tauriDriver: ChildProcess; const appBinaryPath = process.env.DOCKER - ? '/app/target/release/git-butler-dev' + ? '/build/target/release/git-butler-dev' : '../../target/release/git-butler-dev'; export const config: Options.WebdriverIO = { From 9d5c3845d5d0450601e4dfca4ab91f248fca9e22 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 8 Aug 2024 14:16:48 +0200 Subject: [PATCH 9/9] fix: cleanup Dockerfile and add dockerignore node_modules --- .dockerignore | 1 + Dockerfile | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.dockerignore b/.dockerignore index eb5a316cbd..aec67d3817 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ target +node_modules diff --git a/Dockerfile b/Dockerfile index bc536ef57f..72e8e2a099 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,7 @@ FROM ivangabriele/tauri:debian-bullseye-18 ENV DOCKER 1 WORKDIR /build -# Copy required files for installing node and pnpm -# COPY .nvmrc /build -# COPY package.json /build +# Copy source code into container COPY . /build # Install specific node version from our .nvmrc @@ -16,16 +14,8 @@ RUN corepack enable pnpm \ && corepack install \ && pnpm install -# Mount the source code into the container and build a test binary of GitButler -# tauri-driver requires a binary to instrument and execute, against which -# the tests will eventually run -# TODO: It would be great to be able to avoid building this here, but we need: -# - a binary based on the current state of the source code on the persons machine -# - a binary built for their current arch (i.e. amd64/aarch64) (? Maybe docker + rosetta makes this a non-issue) -# RUN --mount=type=bind,source=.,target=/build,rw \ +# Build a binary of the application RUN pnpm build:test -# WORKDIR /app - # CMD xvfb-run pnpm test:e2e CMD /bin/bash