Skip to content

Commit 926f14c

Browse files
committed
Integrate build and test into workflows
1 parent 2364f1d commit 926f14c

File tree

10 files changed

+44
-83
lines changed

10 files changed

+44
-83
lines changed

.github/workflows/cli-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# note you'll typically need to create a personal access token
4848
# with permissions to create releases in the other repo
4949
token: ${{ secrets.FRONTSIDEJACK_GITHUB_TOKEN }}
50-
files: build/cli/*
50+
files: cli/build/*
5151
fail_on_unmatched_files: true
5252
env:
5353
GITHUB_REPOSITORY: thefrontside/graphgen

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
run: deno lint
3939

4040
- name: test
41-
run: deno test
41+
run: deno task test

cli/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/bundled-assets.js
22
node_modules
3+
build
34
graphgen
5+
example/package-lock.json

cli/deno.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
{
22
"tasks": {
3-
"build": "deno run -A --unstable npm:vite build",
3+
"test": "deno task build && deno task compile && deno task npm:install:example && deno test --unstable -A",
4+
"npm:install": "npm install && cd example && npm install",
5+
"npm:install:example": "npm install && cd example && npm install",
6+
"build": "npm install && deno run -A --unstable npm:vite build && deno task bundle-assets",
47
"dev": "deno run -A ./main.ts --watch ./src -f ./example/factory.ts --app-path=./dist",
58
"bundle-assets": "deno run -A tasks/bundle-assets.ts dist",
9+
"build:cli": "deno task build && deno task build:cli:windows && deno task build:cli:linux && deno task build:cli:macos-m1 && deno task build:cli:macos-intel",
10+
"build:cli:windows": "deno compile --no-check -o build/graphgen-x86_64-pc-windows-msvc.exe --target x86_64-pc-windows-msvc --allow-read --allow-net --allow-env main.ts",
11+
"build:cli:linux": "deno compile --no-check -o build/graphgen-x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu --allow-read --allow-net --allow-env main.ts",
12+
"build:cli:macos-m1": "deno compile --no-check -o build/graphgen-aarch64-apple-darwin --target aarch64-apple-darwin --allow-read --allow-net --allow-env main.ts",
13+
"build:cli:macos-intel": "deno compile --no-check -o build/graphgen-x86_64-apple-darwin --target x86_64-apple-darwin --allow-read --allow-net --allow-env main.ts",
614
"compile": "deno compile --no-check --allow-read --allow-net --allow-env -o graphgen ./main.ts"
715
},
816
"lint": {
917
"rules": {
1018
"exclude": ["prefer-const", "require-yield", "no-inner-declarations"]
19+
},
20+
"files": {
21+
"exclude": ["dist", "example", "bundled-assets.js", "node_modules"]
1122
}
1223
},
1324
"fmt": {
1425
"files": {
15-
"exclude": ["README.md", "build/"]
26+
"exclude": ["README.md", "build/", "node_modules", "example", "bundled-assets.js", "dist"]
1627
}
1728
},
1829
"test": {
1930
"files": {
20-
"exclude": ["build", "node_modules"]
31+
"exclude": ["build", "node_modules", "example"]
2132
}
2233
},
2334
"compilerOptions": {

cli/example/factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { createGraphGen, weighted } = require("@frontside/graphgen");
22
const { fakergen } = require("./fakerGen.ts");
3-
const fs = require('fs');
4-
const path = require('path');
3+
const fs = require("fs");
4+
const path = require("path");
55

66
const lifecycles = weighted([["deprecated", .15], ["experimental", .5], [
77
"production",
@@ -16,7 +16,7 @@ const gen = (info) => {
1616
}
1717
};
1818

19-
const source = String(fs.readFileSync(path.join(__dirname, 'world.graphql')));
19+
const source = String(fs.readFileSync(path.join(__dirname, "world.graphql")));
2020

2121
module.exports = createGraphGen({
2222
seed: "factory",

cli/example/package-lock.json

Lines changed: 0 additions & 57 deletions
This file was deleted.

cli/example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"private": true,
44
"dependencies": {
55
"@faker-js/faker": "7.5.0",
6-
"@frontside/graphgen": "../../build/npm"
6+
"@frontside/graphgen": "1.6.0"
77
}
88
}

cli/tasks/bundle-assets.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const readdir = async (k: string, v: string) => {
2525

2626
await readdir(Deno.args[0], Deno.args[0]);
2727

28-
const f = await Deno.create(Deno.args.length > 1 ? Deno.args[1] : "bundled-assets.js");
28+
const f = await Deno.create(
29+
Deno.args.length > 1 ? Deno.args[1] : "bundled-assets.js",
30+
);
2931
await f.write(new TextEncoder().encode(`var m = {};\n`));
3032
const l = Object.keys(m);
3133
for (let i = 0; i < l.length; i++) {

cli/test/smoke.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { describe, expect, it, beforeEach, afterEach } from "./suite.ts";
1+
import { afterEach, beforeEach, describe, expect, it } from "./suite.ts";
22

33
describe("CLI smoke test", () => {
44
let process: Deno.Process;
55

66
beforeEach(() => {
77
process = Deno.run({
8-
cmd: ["./graphgen", "--port", "8900", "--factory", "example/factory.ts"]
9-
})
8+
cmd: ["./graphgen", "--port", "8900", "--factory", "example/factory.ts"],
9+
});
1010
});
1111

1212
afterEach(async () => {
@@ -15,15 +15,18 @@ describe("CLI smoke test", () => {
1515

1616
it("can start up and we can fetch HTML from it", async () => {
1717
await eventually(async () => {
18-
let response = await fetch('http://localhost:8900');
18+
let response = await fetch("http://localhost:8900");
1919
expect(response.ok).toEqual(true);
2020
let body = await response.text();
2121
expect(body).toMatch(/div id="main"/);
2222
}, 10000);
23-
})
23+
});
2424
});
2525

26-
async function eventually(assertion: () => Promise<void>, timeout: number): Promise<void> {
26+
async function eventually(
27+
assertion: () => Promise<void>,
28+
timeout: number,
29+
): Promise<void> {
2730
let lastError: Error | null = null;
2831
let done = false;
2932
let timeoutId = null;
@@ -36,11 +39,14 @@ async function eventually(assertion: () => Promise<void>, timeout: number): Prom
3639
}
3740
}
3841
}
39-
42+
4043
try {
4144
return await Promise.race([
4245
new Promise<void>((_, reject) => {
43-
timeoutId = setTimeout(() => reject(lastError ?? new Error('timeout')), timeout);
46+
timeoutId = setTimeout(
47+
() => reject(lastError ?? new Error("timeout")),
48+
timeout,
49+
);
4450
}),
4551
runAssertion(),
4652
]);

deno.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
{
22
"tasks": {
3+
"test": "deno test && cd cli && deno task test",
34
"build:npm": "deno run -A tasks/build-npm.ts",
4-
"build:cli:windows": "deno compile -o build/cli/graphgen-x86_64-pc-windows-msvc.exe --target x86_64-pc-windows-msvc --allow-read --allow-net cli/main.ts",
5-
"build:cli:linux": "deno compile -o build/cli/graphgen-x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu --allow-read --allow-net cli/main.ts",
6-
"build:cli:macos-m1": "deno compile -o build/cli/graphgen-aarch64-apple-darwin --target aarch64-apple-darwin --allow-read --allow-net cli/main.ts",
7-
"build:cli:macos-intel": "deno compile -o build/cli/graphgen-x86_64-apple-darwin --target x86_64-apple-darwin --allow-read --allow-net cli/main.ts",
8-
"build:cli": "deno task build:cli:windows && deno task build:cli:linux && deno task build:cli:macos-m1 && deno task build:cli:macos-intel"
5+
"build:cli": "cd cli && deno task build:cli"
96
},
107
"lint": {
118
"rules": {
129
"exclude": ["prefer-const", "require-yield", "no-inner-declarations"]
1310
},
1411
"files": {
15-
"exclude": ["build"]
12+
"exclude": ["build", "cli"]
1613
}
1714
},
1815
"fmt": {
1916
"files": {
20-
"exclude": ["README.md", "build/"]
17+
"exclude": ["README.md", "build/", "cli"]
2118
}
2219
},
2320
"test": {
2421
"files": {
25-
"exclude": ["build"]
22+
"exclude": ["build", "cli"]
2623
}
2724
}
2825
}

0 commit comments

Comments
 (0)