diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 8a8ec9e2024..10d2cbcae15 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -37,6 +37,7 @@ dotglob drep dreps earthfile +Edgedriver encryptor fetchval fmtchk @@ -47,6 +48,7 @@ Formz fuzzer gapless gcloud +geckodriver genhtml gethostname gmtime @@ -72,6 +74,7 @@ mgrybyk mithril mitigations moderations +msedgedriver multidex myproject nanos diff --git a/.github/workflows/flutter-web-integration-test.yml b/.github/workflows/flutter-web-integration-test.yml deleted file mode 100644 index cc274b48d3d..00000000000 --- a/.github/workflows/flutter-web-integration-test.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: 🧪 Flutter Web Integration Tests - -permissions: - contents: read - id-token: write - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref }} - cancel-in-progress: true - -on: - pull_request: - types: - - opened - - reopened - - synchronize - branches: - - "main" - paths-ignore: - - "**.md" - - "docs/**" - - ".vscode/" - -jobs: - integration-tests: - name: Web - Integration Tests - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: ⬇️ Checkout repository - uses: actions/checkout@v4 - - - name: ⚙️ Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - cache: true - - - name: ⚙️ Setup Melos - uses: bluefireteam/melos-action@v3 - - - name: ⚙️ Install dependencies for all packages - run: melos build:pub_get:all - - - name: 🤖 Run Integration Tests - run: ./scripts/flutter_web_integration_test.sh diff --git a/catalyst_voices/Earthfile b/catalyst_voices/Earthfile index 79dd1e1a60b..d8319153a42 100644 --- a/catalyst_voices/Earthfile +++ b/catalyst_voices/Earthfile @@ -1,16 +1,17 @@ -VERSION --try --global-cache 0.7 +VERSION --try --global-cache --arg-scope-and-set 0.7 deps: - FROM debian:stable-slim + FROM debian:bookworm-slim RUN apt-get update - RUN apt-get install -y curl git unzip bash - WORKDIR /frontend + RUN apt-get install -y git curl unzip bzip2 bash jq gpg + COPY --dir test_driver/scripts . + RUN chmod +x scripts/install-chrome-linux64.sh && ./scripts/install-chrome-linux64.sh + RUN chmod +x scripts/install-edge-linux64.sh && ./scripts/install-edge-linux64.sh + RUN chmod +x scripts/install-firefox-linux64.sh && ./scripts/install-firefox-linux64.sh -# Download and set-up flutter -flutter: - FROM +deps + WORKDIR /frontend - RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter + GIT CLONE https://github.com/flutter/flutter.git /usr/local/flutter ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}" RUN flutter channel stable @@ -19,11 +20,13 @@ flutter: RUN flutter doctor -v RUN flutter config --enable-web +src: + FROM +deps + COPY --dir pubspec.yaml lib packages web test test_driver integration_test . + # Build web version of Catalyst Voices build: - FROM +flutter - - COPY --dir pubspec.yaml lib packages web test test_driver integration_test . + FROM +src RUN flutter clean RUN flutter pub get @@ -32,18 +35,11 @@ build: WORKDIR /frontend/build SAVE ARTIFACT web /web AS LOCAL web -docker: - FROM +deps - FROM nginx:stable-alpine3.17 - +package: + FROM nginx:alpine3.18 + ARG tag='latest' COPY +build/web /app COPY ./nginx.conf /etc/nginx/nginx.conf - EXPOSE 80 -package: - FROM +docker - - ARG tag='latest' - SAVE IMAGE catalyst-voices-app:$tag \ No newline at end of file diff --git a/catalyst_voices/test_driver/Earthfile b/catalyst_voices/test_driver/Earthfile new file mode 100644 index 00000000000..65f6bec0a26 --- /dev/null +++ b/catalyst_voices/test_driver/Earthfile @@ -0,0 +1,40 @@ +VERSION --try --global-cache --arg-scope-and-set 0.7 + +integration-test-web: + FROM ../+build + ARG browser + LET driver_port = 4444 + + IF [ $browser = "chrome" ] + LET driver = "chromedriver" + END + + IF [ $browser = "firefox" ] + LET driver = "geckodriver" + END + # Commenting out Edge tests as they are failing due to: + # https://github.com/flutter/flutter/issues/76213 + # https://github.com/flutter/flutter/issues/142021 + #IF [ $browser = "edge" ] + # LET driver = "msedgedriver" + #END + RUN ($driver --port=$driver_port > $driver.log &) && \ + flutter drive --driver=test_driver/integration_test.dart \ + --target=integration_test/main.dart \ + --flavor development -d web-server --profile \ + --browser-name=$browser --driver-port=$driver_port || echo fail > fail + # Using WAIT instead of TRY because TRY/CATCH/FINALLY does not (currently) support expanding args for SAVE ARTIFACT paths + WAIT + SAVE ARTIFACT $driver.log AS LOCAL $driver.log + END + IF [ -f fail ] + RUN echo ""$browser" integration test failed" && \ + echo "Printing "$driver" logs..." && \ + cat $driver.log && \ + exit 1 + END + +test-web-all: + BUILD +integration-test-web \ + --browser=chrome \ + --browser=firefox diff --git a/catalyst_voices/test_driver/scripts/install-chrome-linux64.sh b/catalyst_voices/test_driver/scripts/install-chrome-linux64.sh new file mode 100644 index 00000000000..af4aca22d57 --- /dev/null +++ b/catalyst_voices/test_driver/scripts/install-chrome-linux64.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# This script installs Chrome for testing and Chromedriver +PLATFORM=linux64 +DISTR="Debian 12 (Bookworm)" + +# Installing dependencies for Chrome. Workaround for: +# https://github.com/GoogleChromeLabs/chrome-for-testing/issues/55 +echo "Installing Google Chrome dependencies" +chrome_deps=$(curl -s https://raw.githubusercontent.com/chromium/chromium/main/chrome/installer/linux/debian/dist_package_versions.json) +deps=$(echo "$chrome_deps" | jq -r ".\"$DISTR\" | keys[]") +apt-get update +for dep in $deps; do + apt-get install -y $dep +done + +# Get latest chrome for testing version +json_chrome=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json) + +# Install chrome +echo "Installing Google Chrome..." +latest_chrome=$(echo "$json_chrome" | jq -r ".channels.Stable.downloads.chrome[].url | select(contains(\"$PLATFORM\"))") +curl -s --create-dirs -o chrome.zip --output-dir /opt/chrome "$latest_chrome" +unzip -d /opt/chrome -j /opt/chrome/chrome.zip && rm /opt/chrome/chrome.zip +ln -s /opt/chrome/chrome /usr/local/bin/google-chrome +chmod +x /opt/chrome/chrome +google-chrome --version + +# Install chromedriver +echo "Installing Chromedriver..." +latest_chromedriver=$(echo "$json_chrome" | jq -r ".channels.Stable.downloads.chromedriver[].url | select(contains(\"$PLATFORM\"))") +curl -s --create-dirs -o chromedriver.zip --output-dir /opt/chromedriver "$latest_chromedriver" +unzip -d /opt/chromedriver -j /opt/chromedriver/chromedriver.zip && rm /opt/chromedriver/chromedriver.zip +ln -s /opt/chromedriver/chromedriver /usr/local/bin/chromedriver +chmod +x /opt/chromedriver/chromedriver +chromedriver --version diff --git a/catalyst_voices/test_driver/scripts/install-edge-linux64.sh b/catalyst_voices/test_driver/scripts/install-edge-linux64.sh new file mode 100644 index 00000000000..3b2729aa4cf --- /dev/null +++ b/catalyst_voices/test_driver/scripts/install-edge-linux64.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# This script installs Edge and Edgedriver. +PLATFORM=linux64 + +echo "Installing Edge..." +install -d -m 0755 /etc/apt/keyrings +curl -fSsL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/keyrings/microsoft-edge.gpg > /dev/null +echo 'deb [signed-by=/etc/apt/keyrings/microsoft-edge.gpg] https://packages.microsoft.com/repos/edge stable main' | tee /etc/apt/sources.list.d/microsoft-edge.list +apt-get update && apt-get install -y microsoft-edge-stable +microsoft-edge-stable --version + +echo "Installing Edgedriver..." +edge_version=$(microsoft-edge-stable --version | grep -Eo '[0-9]+.+' | tr -d ' ') +curl -s --create-dirs -o msedgedriver.zip --output-dir /opt/msedgedriver "https://msedgedriver.azureedge.net/$edge_version/edgedriver_$PLATFORM.zip" +unzip -d /opt/msedgedriver -j /opt/msedgedriver/msedgedriver.zip && rm /opt/msedgedriver/msedgedriver.zip +ln -s /opt/msedgedriver/msedgedriver /usr/local/bin/msedgedriver +chmod +x /opt/msedgedriver/msedgedriver +msedgedriver --version \ No newline at end of file diff --git a/catalyst_voices/test_driver/scripts/install-firefox-linux64.sh b/catalyst_voices/test_driver/scripts/install-firefox-linux64.sh new file mode 100644 index 00000000000..1b2011c251b --- /dev/null +++ b/catalyst_voices/test_driver/scripts/install-firefox-linux64.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# This script installs Firefox and Geckodriver. Geckodriver supported versions: +# https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html +PLATFORM=linux64 + +echo "Installing Firefox..." +install -d -m 0755 /etc/apt/keyrings +curl -fSsL https://packages.mozilla.org/apt/repo-signing-key.gpg | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null +echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null +echo ' +Package: * +Pin: origin packages.mozilla.org +Pin-Priority: 1000 +' | tee /etc/apt/preferences.d/mozilla +apt-get update && apt-get install -y firefox +firefox --version + +echo "Installing Geckodriver..." +json_geckodriver=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest) +latest_geckodriver=$(echo "$json_geckodriver" | jq -r ".assets[].browser_download_url | select(contains(\"$PLATFORM\") and endswith(\"gz\"))") +curl -sL --create-dirs -o geckodriver.tar.gz --output-dir /opt/geckodriver "$latest_geckodriver" +tar -xzf /opt/geckodriver/geckodriver.tar.gz -C /opt/geckodriver/ && rm /opt/geckodriver/geckodriver.tar.gz +ln -s /opt/geckodriver/geckodriver /usr/local/bin/geckodriver +chmod +x /opt/geckodriver/geckodriver +geckodriver --version \ No newline at end of file