Skip to content

Commit

Permalink
ci: run npm build in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ycmjason committed Oct 14, 2024
1 parent d71885d commit 6e0ca43
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 11 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/npm-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Node: Build + Integration"

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x # Run with latest stable Deno.

- name: Start Pebble and pebble-challtestsrv
run: deno task pebble:start --detach

- name: Wait for Pebble to be ready
run: |
echo "⏳ Waiting for Pebble... 🪨"
# Loop until the port 14000 is open
until nc -zv localhost 14000 2>/dev/null; do
sleep 1
done
echo "✅ Pebble is running!"
- name: Wait for pebble-challtestsrv to be ready
run: |
echo "⏳ Waiting for pebble-challtestsrv... 🪨"
until nc -zv localhost 8055 2>/dev/null; do
sleep 1
done
echo "✅ pebble-challtestsrv is running!"
- run: deno task build:npm:integration

- name: Stop Pebble
run: deno task pebble:stop
8 changes: 5 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Publish
on:
push:
branches:
- main
workflow_run:
workflows: ["CI", "E2E", "Integration", "Node: Build + Integration"]
branches: [main]
types:
- completed

jobs:
publish-jsr:
Expand Down
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"test:integration": "deno test --unsafely-ignore-certificate-errors=localhost -A integration",
"pebble:start": "docker compose -f integration/docker-compose.yaml up",
"pebble:stop": "docker compose -f integration/docker-compose.yaml down",
"build:npm": "deno run -A scripts/build-npm.ts"
"build:npm": "deno run -A scripts/build-npm.ts",
"build:npm:integration": "deno run -A scripts/build-npm-integration.ts"
},
"compilerOptions": {
"strict": true,
Expand Down
10 changes: 10 additions & 0 deletions scripts/build-npm-integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { build, type BuildOptions } from "jsr:@deno/dnt";
import { dntConfig } from "./build-npm.ts";

const config: BuildOptions = {
...dntConfig,
testPattern: "integration/**/*.test.ts",
test: true,
};

await build(config);
16 changes: 9 additions & 7 deletions scripts/build-npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { build, emptyDir } from "jsr:@deno/dnt";
import { build, type BuildOptions, emptyDir } from "jsr:@deno/dnt";
import { join } from "jsr:@std/path";
import DENO_JSON from "../deno.json" with { type: "json" };

Expand All @@ -14,19 +14,16 @@ const OUT_DIR = join(
"./dist-npm",
);

await emptyDir(OUT_DIR);

const GITHUB_REPO = "https://github.com/fishballapp/acme";

await build({
testPattern: "integration/**/*.test.ts",
export const dntConfig: BuildOptions = {
entryPoints: Object.entries(DENO_JSON.exports).map(([name, path]) => ({
kind: "export",
name,
path: join(PROJECT_ROOT, path),
})),
outDir: OUT_DIR,
test: true,
test: false,
shims: {
deno: "dev",
undici: "dev",
Expand Down Expand Up @@ -67,4 +64,9 @@ await build({
);
}
},
});
};

if (import.meta.main) {
await emptyDir(OUT_DIR);
await build(dntConfig);
}

0 comments on commit 6e0ca43

Please sign in to comment.