Skip to content

Commit

Permalink
add playwright 1.31.1 with node and chromiom browser (python 3.11.1) (#…
Browse files Browse the repository at this point in the history
…47)

---------

Co-authored-by: Рахимов Рустам (Rakhimov_RR) <[email protected]>
  • Loading branch information
rustrar and Рахимов Рустам (Rakhimov_RR) authored Mar 3, 2023
1 parent 816ccb5 commit 3e53255
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: playwright

on: [pull_request, workflow_dispatch]

jobs:
prejob:
uses: ./.github/workflows/set-output-workflow.yml
with:
workflow: ${{ github.workflow }}
secrets:
_WORKFLOW: ${{ secrets._CURRENT_TOOL }}

ubuntu-gnu:
needs: prejob
if: ${{ needs.prejob.outputs.workflow == github.workflow }}
uses: ./.github/workflows/build-ubuntu.yml
with:
workflow: ${{ github.workflow }}
toolset: gnu

windows-msvc:
needs: prejob
if: ${{ needs.prejob.outputs.workflow == github.workflow }}
uses: ./.github/workflows/build-windows.yml
with:
workflow: ${{ github.workflow }}
toolset: msvc

test-ubuntu:
needs: ubuntu-gnu
uses: ./.github/workflows/test-ubuntu.yml
with:
workflow: ${{ github.workflow }}
artifact: build-gnu

test-windows-msvc:
needs: windows-msvc
uses: ./.github/workflows/test-windows.yml
with:
workflow: ${{ github.workflow }}
artifact: build-msvc

release:
needs: [test-windows-msvc, test-ubuntu]
uses: ./.github/workflows/release.yml
with:
workflow: ${{ github.workflow }}
tool_version: '1.31.1'
prepare_body: |
bsdtar -Oxf ./build-gnu/build-gnu.tar.gz build-gnu.md >> body.md
bsdtar -Oxf ./build-msvc/build-msvc.tar.gz build-msvc.md >> body.md
artifacts: ./build-msvc/build-msvc.tar.gz, ./build-gnu/build-gnu.tar.gz
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions playwright/build_gnu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
set -e

tool_name="playwright"
tool_version="1.31.1"
self_name="python-3.11.1"
echo "::set-output name=tool_name::$tool_name"

apt update
apt install -y wget

release_version_dirpath="$dp0/release/$tool_name-$tool_version"
mkdir -p "$release_version_dirpath" && cd "$dp0/release"

echo "download python install script ..."
python_bin_download_url="https://github.com/hemnstill/StandaloneTools/releases/download/$self_name/build-gnu.tar.gz"
python_download_zip="$dp0/release/$self_name.tar.gz"
[[ ! -f "$python_download_zip" ]] && wget "$python_bin_download_url" -O "$python_download_zip"

echo "download bsdtar ..."
bsdtar_version=3.6.2
bsdtar_download_url="https://github.com/hemnstill/StandaloneTools/releases/download/bsdtar-$bsdtar_version/build-musl.tar.gz"
bsdtar_tar_gz="bsdtar-$bsdtar_version-build-musl.tar.gz"
[[ ! -f "$bsdtar_tar_gz" ]] && wget "$bsdtar_download_url" -O "$bsdtar_tar_gz"
tar -xf "$bsdtar_tar_gz"

bsdtar="$dp0/release/bsdtar"

cpython_bin="$release_version_dirpath/Scripts/bin/python3"
[[ ! -f "$cpython_bin" ]] && tar -xf "$python_download_zip" -C "$release_version_dirpath"

"$cpython_bin" -m pip install "$tool_name==$tool_version"

cp -f "$dp0/release/playwright.sh" "$release_version_dirpath/"
cp -f "$dp0/release/__main__playwright.py" "$release_version_dirpath/"

export PLAYWRIGHT_BROWSERS_PATH="$release_version_dirpath/ms-playwright"
echo "download browsers to '$PLAYWRIGHT_BROWSERS_PATH' ..."
cd "$release_version_dirpath"
./"$tool_name.sh" install chromium

echo "creating archive ..."

{ printf '### build-gnu.tar.gz
Playwright %s
Python %s
' "$(./"$tool_name.sh" --version)" "$("$cpython_bin" -c "import sys; print(sys.version)")"
} > build-gnu.md

cat build-gnu.md

"$bsdtar" \
--exclude="__pycache__" \
--exclude="Scripts/Scripts" \
--exclude="*.whl" \
-czvf ../build-gnu.tar.gz .
56 changes: 56 additions & 0 deletions playwright/build_msvc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
set -e

tool_name="playwright"
tool_version="1.31.1"
self_name="python-3.11.1"
echo "::set-output name=tool_name::$tool_name"

release_version_dirpath="$dp0/release/$tool_name-$tool_version"
mkdir -p "$release_version_dirpath" && cd "$dp0/release"

echo "download python install script ..."
python_bin_download_url="https://github.com/hemnstill/StandaloneTools/releases/download/$self_name/build-msvc.tar.gz"
python_download_zip="$dp0/release/$self_name.tar.gz"
[[ ! -f "$python_download_zip" ]] && wget "$python_bin_download_url" -O "$python_download_zip"

echo "download bsdtar ..."
bsdtar_version=3.6.2
bsdtar_download_url="https://github.com/hemnstill/StandaloneTools/releases/download/bsdtar-$bsdtar_version/build-mingw.tar.gz"
bsdtar_tar_gz="bsdtar-$bsdtar_version-build-mingw.tar.gz"
[[ ! -f "$bsdtar_tar_gz" ]] && wget "$bsdtar_download_url" -O "$bsdtar_tar_gz"
tar -xf "$bsdtar_tar_gz"

bsdtar="$dp0/release/bsdtar.exe"

cpython_bin="$release_version_dirpath/Scripts/python.exe"
[[ ! -f "$cpython_bin" ]] && tar -xf "$python_download_zip" -C "$release_version_dirpath"

"$cpython_bin" -m pip install "$tool_name==$tool_version"

cp -f "$dp0/release/playwright.bat" "$release_version_dirpath/"
cp -f "$dp0/release/__main__playwright.py" "$release_version_dirpath/"


export PLAYWRIGHT_BROWSERS_PATH="$release_version_dirpath/ms-playwright"
echo "download browsers to '$PLAYWRIGHT_BROWSERS_PATH' ..."
cd "$release_version_dirpath"
./"$tool_name.bat" install chromium

echo "creating archive ..."

{ printf '### build-msvc.tar.gz
Playwright %s
Python %s
' "$(./"$tool_name.bat" --version)" "$("$cpython_bin" -c "import sys; print(sys.version)")"
} > build-msvc.md

cat build-msvc.md

"$bsdtar" \
--exclude="__pycache__" \
--exclude="Scripts/Scripts" \
--exclude="*.whl" \
-czvf ../build-msvc.tar.gz .
7 changes: 7 additions & 0 deletions playwright/release/__main__playwright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
import re
import sys
from playwright.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
4 changes: 4 additions & 0 deletions playwright/release/playwright.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
set PLAYWRIGHT_BROWSERS_PATH=%~dp0ms-playwright
"%~dp0Scripts\python.exe" "%~dp0__main__playwright.py" %*
exit /b %errorlevel%
5 changes: 5 additions & 0 deletions playwright/release/playwright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
export PLAYWRIGHT_BROWSERS_PATH="$dp0/ms-playwright"
"$dp0/Scripts/bin/python3" "$dp0/__main__playwright.py" "$@"

8 changes: 8 additions & 0 deletions playwright/test_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

test_version() {
assertEquals "Version 1.31.1" "$(../bin/playwright.sh --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"
8 changes: 8 additions & 0 deletions playwright/test_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

test_version() {
assertEquals "Version 1.31.1" "$(../bin/playwright.bat --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"

0 comments on commit 3e53255

Please sign in to comment.