kopia lustrzana https://github.com/simonw/datasette
rodzic
943aa2e1f7
commit
847d6b1aac
|
@ -0,0 +1,28 @@
|
|||
name: Test in Pyodide with shot-scraper
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10"
|
||||
cache: 'pip'
|
||||
cache-dependency-path: '**/setup.py'
|
||||
- name: Cache Playwright browsers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/ms-playwright/
|
||||
key: ${{ runner.os }}-browsers
|
||||
- name: Install Playwright dependencies
|
||||
run: |
|
||||
pip install shot-scraper
|
||||
shot-scraper install
|
||||
- name: Run test
|
||||
run: |
|
||||
./test-in-pyodide-with-shot-scraper.sh
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Build the wheel
|
||||
python3 -m build
|
||||
|
||||
# Find name of wheel
|
||||
wheel=$(basename $(ls dist/*.whl))
|
||||
# strip off the dist/
|
||||
|
||||
|
||||
# Create a blank index page
|
||||
echo '
|
||||
<script src="https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"></script>
|
||||
' > dist/index.html
|
||||
|
||||
# Run a server for that dist/ folder
|
||||
cd dist
|
||||
python3 -m http.server 8529 &
|
||||
cd ..
|
||||
|
||||
shot-scraper javascript http://localhost:8529/ "
|
||||
async () => {
|
||||
let pyodide = await loadPyodide();
|
||||
await pyodide.loadPackage(['micropip', 'ssl', 'setuptools']);
|
||||
let output = await pyodide.runPythonAsync(\`
|
||||
import micropip
|
||||
await micropip.install('h11==0.12.0')
|
||||
await micropip.install('http://localhost:8529/$wheel')
|
||||
import ssl
|
||||
import setuptools
|
||||
from datasette.app import Datasette
|
||||
ds = Datasette(memory=True, settings={'num_sql_threads': 0})
|
||||
(await ds.client.get('/_memory.json?sql=select+55+as+itworks&_shape=array')).text
|
||||
\`);
|
||||
if (JSON.parse(output)[0].itworks != 55) {
|
||||
throw 'Got ' + output + ', expected itworks: 55';
|
||||
}
|
||||
return 'Test passed!';
|
||||
}
|
||||
"
|
||||
|
||||
# Shut down the server
|
||||
pkill -f 'http.server 8529'
|
Ładowanie…
Reference in New Issue