Skip to content

Commit

Permalink
Use multi-stage build to compile javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupstate committed Feb 1, 2024
1 parent 617ab76 commit 34b4b14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: test
on:
push:
branches: [dagger]
branches: [main]

jobs:
build:
name: build
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
24 changes: 22 additions & 2 deletions CI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,25 @@

async def test():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
source = client.host().directory(
source_code = client.host().directory(
".", exclude=[".git", "node_modules", ".venv", "__ci__.py"]
)

javascript = (
client.container()
.from_("node:16.15.0-slim")
.with_workdir("/src")
.with_file("/src/package.json", client.host().file("package.json"))
.with_file(
"/src/package-lock.json", client.host().file("package-lock.json")
)
.with_exec(["npm", "install"])
.with_directory("/src", source_code)
.with_exec(["npx", "webpack", "--mode", "production"])
)

await javascript.sync()

redis = client.container().from_("redis:7").with_exposed_port(6379).as_service()

python = (
Expand All @@ -32,7 +48,11 @@ async def test():
.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_directory("/src", source_code)
.with_directory(
"/src/example_app/static/bundles",
javascript.directory("/src/example_app/static/bundles"),
)
.with_exec(["poetry", "install", "--without", "playwright"])
.with_exec(["poetry", "run", "pytest"])
)
Expand Down

0 comments on commit 34b4b14

Please sign in to comment.