From c5d66272b67944394a589c3e04e6c03ed3dc272d Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Fri, 19 Apr 2024 10:16:20 -0300 Subject: [PATCH] second attempt at getting interception working in CI in browser --- .github/workflows/test-browser.yml | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-browser.yml b/.github/workflows/test-browser.yml index c434c2e582..f6bc41cca5 100644 --- a/.github/workflows/test-browser.yml +++ b/.github/workflows/test-browser.yml @@ -25,11 +25,53 @@ jobs: with: node-version: 20.x - run: npm ci + + # Set up Python (for pipx) + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + # Install pipx (for mitmproxy) + # See https://pipx.pypa.io/stable/installation/ + - name: Install pipx + run: | + python3 -m pip install --user pipx + sudo pipx --global ensurepath + + # https://docs.mitmproxy.org/stable/overview-installation/#installation-from-the-python-package-index-pypi + - name: Install mitmproxy + run: | + pipx install mitmproxy + # We use this library in our addon + pipx inject mitmproxy websockets + + # This user comes from when originally following the mitmproxy documentation (i.e. intercepting _all_ traffic except that from this user). We no longer do this, but I guess there’s no harm in having a separate user instead of running as root. + - name: Create a user to run mitmproxy + run: sudo useradd --create-home mitmproxyuser + + # This runs the proxy as the mitmproxyuser user created above (see start-interception-proxy script). + - name: Start interception proxy server + run: ./start-interception-proxy + - name: Install Playwright browsers and dependencies run: npx playwright install --with-deps - - env: + + - name: Run the tests + env: PLAYWRIGHT_BROWSER: ${{ matrix.browser }} run: npm run test:playwright + + - name: Save interception proxy server logs + if: always() + run: sudo journalctl -u ably-sdk-test-proxy.service > interception-proxy-logs.txt + + - name: Upload interception proxy server logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: interception-proxy-logs-${{ matrix.browser }} + path: interception-proxy-logs.txt + - name: Upload test results if: always() uses: ably/test-observability-action@v1