diff --git a/.github/workflows/docker_pr.yml b/.github/workflows/docker_pr.yml new file mode 100644 index 000000000..6f63e3098 --- /dev/null +++ b/.github/workflows/docker_pr.yml @@ -0,0 +1,105 @@ +name: Docker CI + +on: + push: + branches: + - main + paths-ignore: + - '**/*.md' + pull_request: + branches: + - main + +jobs: + build_browser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.13 + uses: actions/setup-python@v4 + with: + python-version: '3.13' + - name: Use Node.js + uses: actions/setup-node@v5 + with: + node-version: 24.x + cache: 'npm' + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install uv + uv pip install wheel --python 3.13 --system --verbose + uv pip install -r Browser/dev-requirements.txt --python 3.13 --system + uv pip install -r pyproject.toml --python 3.13 --system + inv deps + - name: Build proto + run: | + inv protobuf + - name: Build + run: | + inv build + - name: Build the wheel + run: | + inv create-package + - name: Upload Browser wheel + uses: actions/upload-artifact@v4 + with: + name: browser-wheel + path: dist/*.whl + - name: Create demo app + run: | + inv demo-app + - name: Pack demo app + uses: actions/upload-artifact@v4 + with: + name: demoapp + path: zip_results/demoapp + + docker-image: + runs-on: ubuntu-latest + needs: build_browser + permissions: write-all + steps: + - uses: actions/checkout@v5 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/marketsquare/robotframework-browser/rfbrowser-dev + - name: Download browser wheel + uses: actions/download-artifact@v5 + with: + name: browser-wheel + path: docker/dist + - name: Debug ls + run: | + ls -l docker/dist + echo =========================== + ls -l docker + echo =========================== + pwd + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Push to GitHub Packages + uses: docker/build-push-action@v6 + with: + context: . + file: docker/Dockerfile.dev_pr + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: false + - name: Download demo app + uses: actions/download-artifact@v5 + with: + name: demoapp + path: demoapp + - name: unzip demo app + run: | + rm -rf node + ls -l demoapp + unzip demoapp/demo-app*.zip -d . + ls -l node diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 2c5c718ea..46e527628 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -385,22 +385,22 @@ jobs: uses: actions/setup-node@v5 with: node-version: "22.x" - - name: Download rfbrowser-wheel for BrowserBatteries tests + - name: Download browser-wheel uses: actions/download-artifact@v5 with: name: rfbrowser-wheel-bb-test path: rfbrowser-wheel - - name: Download BrowserBatteries wheels + - name: Download BrowserBatteries wheel uses: actions/download-artifact@v5 with: name: browser-batteries-wheels-bb-test-${{ matrix.os }} path: browser-batteries-wheels - - name: Download demoapp wheels + - name: Download demoapp uses: actions/download-artifact@v5 with: name: demoapp--bb-test-${{ matrix.os }} path: demoapp - - name: Install Browser and BrowserBatteries on ${{ matrix.os }} + - name: Install Browser and BrowserBatteries run: | python -m pip install --upgrade pip pip install rfbrowser-wheel/robotframework_browser-*-py3-none-any.whl @@ -418,7 +418,7 @@ jobs: ls -l demoapp unzip demoapp/demo-app*.zip -d . - name: Run tests on Linux with packed demoapp - if : matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' run: | xvfb-run --auto-servernum invoke atest-robot --smoke - name: Run tests on MacOS with packed demoapp diff --git a/docker/Dockerfile.dev_pr b/docker/Dockerfile.dev_pr new file mode 100644 index 000000000..a99011242 --- /dev/null +++ b/docker/Dockerfile.dev_pr @@ -0,0 +1,41 @@ +FROM mcr.microsoft.com/playwright:v1.55.1-noble + +# Update apt-get +USER root +RUN apt-get update +RUN python3 --version +RUN apt install -y python3-pip python3.12-venv + +# Clean up +USER root +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set environment variables +ENV PATH="/home/pwuser/.local/bin:${PATH}" +ENV NODE_PATH=/usr/lib/node_modules + +# Cache operations +USER root +RUN mv /root/.cache/ /home/pwuser/.cache || true +RUN chmod a+rwx -R /home/pwuser/.cache || true + +# Switch to pwuser for the remaining operations +USER pwuser + +# Create venv and active it +RUN python3 -m venv /home/pwuser/.venv +ENV PATH="/home/pwuser/.venv/bin:$PATH" + +# Upgrade pip and wheel for the user +RUN pip3 install --no-cache-dir --upgrade pip wheel uv + +# Copy the dist files +COPY docker/dist/*.whl /home/pwuser/ +# Install RobotFramework and Browser library +RUN uv pip install --no-cache-dir --upgrade robotframework && \ + uv pip install --no-cache-dir /home/pwuser/robotframework_browser-*.whl && \ + rm /home/pwuser/*.whl + +# Initialize Browser library without browsers binaries +RUN python3 -m Browser.entry init --skip-browsers diff --git a/tasks.py b/tasks.py index 5373d3fb5..c2f339b4d 100644 --- a/tasks.py +++ b/tasks.py @@ -873,10 +873,8 @@ def package_nodejs(c: Context, architecture=None): print(f"Current os platform: {_os_platform}") _os_platform = _os_platform.replace("-", "_").replace(".", "_").replace(" ", "_") if _os_platform.startswith("macosx") and platform.machine().lower() == "x86_64": - _os_platform = _os_platform.replace( - "universal2", platform.machine().lower().lower() - ) - if sysconfig.get_platform().lower() == "linux-x86_64": + _os_platform = _os_platform.replace("universal2", platform.machine().lower()) + elif sysconfig.get_platform().lower() == "linux-x86_64": _os_platform = f"manylinux_2_17_{architecture}" elif sysconfig.get_platform().lower() == "linux-aarch64": _os_platform = "manylinux_2_17_aarch64.manylinux2014_aarch64"