Skip to content

Commit

Permalink
Add dagger machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupstate committed Feb 1, 2024
1 parent 4a0b18f commit 617ab76
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 163 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: test
on:
push:
branches: [dagger]

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install Dagger CLI
run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
- name: Install Dagger SDK
run: pip install dagger-io
- name: Run Dagger pipeline
run: dagger run python CI.py
46 changes: 46 additions & 0 deletions CI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import sys

import anyio
import dagger


async def test():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
source = client.host().directory(
".", exclude=[".git", "node_modules", ".venv", "__ci__.py"]
)
redis = client.container().from_("redis:7").with_exposed_port(6379).as_service()

python = (
client.container()
.from_("python:3.12-slim")
.with_mounted_cache(
"/root/.cache", client.cache_volume("pycrdt-example-app-cache")
)
.with_service_binding("redis", redis)
.with_exec(
[
"/bin/sh",
"-c",
"apt-get update && apt-get install --no-install-recommends -y build-essential",
]
)
.with_exec(["pip", "install", "poetry"])
.with_workdir("/src")
.with_file("/src/poetry.lock", client.host().file("poetry.lock"))
.with_file("/src/pyproject.toml", client.host().file("pyproject.toml"))
.with_exec(["poetry", "install", "--only", "playwright"])
.with_exec(["poetry", "run", "playwright", "install-deps"])
.with_exec(["poetry", "run", "playwright", "install", "chromium"])
.with_directory("/src", source)
.with_exec(["poetry", "install", "--without", "playwright"])
.with_exec(["poetry", "run", "pytest"])
)

# execute
await python.sync()

print("Tests succeeded!")


anyio.run(test)
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

An example app illustrating how to use Litestar, yjs, and pycrdt together for collaborative editing.

Give it a whirl by running:
Assuming you have Docker installed, give it a whirl by running:

$ docker-compose up

Then open two different tabs and navigate to [http://127.0.0.1:8000](http://127.0.0.1:8000).

Or run the tests that use [testcontainers](https://testcontainers-python.readthedocs.io/en/latest/README.html) and [Playwright](https://playwright.dev/python/docs/intro):
Or run the tests using [Dagger](https://docs.dagger.io) and [Playwright](https://playwright.dev/python/docs/intro).

$ poetry install
$ poetry run playwright install-deps
$ poetry run playwright install
$ npm install
$ npx webpack --mode=development
$ poetry run pytest
$ pip install dagger-io
$ dagger run python CI.py
Loading

0 comments on commit 617ab76

Please sign in to comment.