Skip to content

Commit 0cedfcf

Browse files
authored
Merge branch 'main' into suvij/eng-6412-add-an-option-for-the-user-to-configure-the-number-of-cache
2 parents 5117ec2 + a078dd5 commit 0cedfcf

File tree

50 files changed

+274
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+274
-125
lines changed

.github/workflows/cli-binary-pr.yaml

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

.github/workflows/cli-ci.yaml

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Cli CI
1+
name: wgc CI
22
on:
33
pull_request:
44
paths:
5-
- "cli/**/*"
6-
- "connect/**/*"
7-
- ".github/workflows/cli-ci.yaml"
5+
- 'cli/**/*'
6+
- 'connect/**/*'
7+
- '.github/workflows/cli-ci.yaml'
88

99
concurrency:
1010
group: ${{github.workflow}}-${{github.head_ref}}
@@ -15,25 +15,105 @@ env:
1515
DO_NOT_TRACK: '1'
1616

1717
jobs:
18-
build_test:
18+
build_test_default:
1919
timeout-minutes: 10
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
2323

2424
- uses: ./.github/actions/node
25+
- uses: oven-sh/setup-bun@v2
2526

2627
- name: Install dependencies
27-
run: pnpm install --frozen-lockfile
28+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition install --frozen-lockfile
2829

2930
- name: Generate code
3031
run: pnpm buf generate --template buf.ts.gen.yaml
3132

3233
- name: Check if git is not dirty after generating files
3334
run: git diff --no-ext-diff --exit-code
3435

35-
- name: Build
36-
run: pnpm run --filter ./cli --filter ./connect --filter ./shared --filter ./composition build
36+
- name: Build Node.js NPM Package
37+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition run build
38+
39+
- name: 'Build wgc binary'
40+
working-directory: cli
41+
run: bun build --compile --minify --sourcemap src/index.ts --outfile wgc
42+
43+
- name: E2E test
44+
working-directory: cli
45+
run: bun test e2e
46+
47+
build_test_node_matrix:
48+
timeout-minutes: 10
49+
runs-on: ubuntu-latest
50+
51+
strategy:
52+
matrix:
53+
node-version: ['20.x', '22.x']
54+
55+
steps:
56+
- uses: actions/checkout@v4
3757

38-
- name: Test
58+
- uses: ./.github/actions/node
59+
with:
60+
node-version: ${{ matrix.node-version }}
61+
- uses: oven-sh/setup-bun@v2
62+
63+
- name: Install dependencies
64+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition install --frozen-lockfile
65+
66+
- name: Build Node.js NPM Package
67+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition run build
68+
69+
- name: Unit Test
3970
run: pnpm run --filter wgc test
71+
72+
- name: E2E test (node)
73+
working-directory: cli
74+
run: bun test e2e --test-name-pattern node
75+
76+
build_bun_matrix:
77+
runs-on: ubuntu-latest
78+
timeout-minutes: 30
79+
80+
strategy:
81+
matrix:
82+
target: [bun-linux-x64, bun-linux-arm64, bun-darwin-x64, bun-darwin-arm64, bun-windows-x64]
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
88+
- uses: oven-sh/setup-bun@v2
89+
90+
- uses: ./.github/actions/node
91+
92+
- name: Install dependencies
93+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition install --frozen-lockfile
94+
95+
- name: Build
96+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition run build
97+
98+
- name: 'Build wgc binary'
99+
working-directory: cli
100+
run: bun build --compile --minify --sourcemap --target ${{ matrix.target }} src/index.ts --outfile out/wgc-experimental-${{ github.sha }}-${{ matrix.target }}
101+
102+
- name: 'Upload builds as artifacts'
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: wgc-experimental-${{ github.sha }}-${{ matrix.target }}
106+
path: cli/out/wgc-experimental-${{ github.sha }}-${{ matrix.target }}*
107+
if-no-files-found: error
108+
109+
build_test:
110+
runs-on: ubuntu-latest
111+
needs: [build_test_default, build_test_node_matrix, build_bun_matrix]
112+
if: always()
113+
steps:
114+
- name: 'All tests passed'
115+
if: ${{ !(contains(needs.*.result, 'failure')) }}
116+
run: exit 0
117+
- name: 'Some tests failed'
118+
if: ${{ contains(needs.*.result, 'failure') }}
119+
run: exit 1

cli/e2e/smoke.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { existsSync } from 'node:fs';
2+
import { expect, test, describe } from 'bun:test';
3+
import { $ } from 'bun';
4+
5+
import packageJSON from '../package.json' with { type: 'json' };
6+
7+
$.nothrow();
8+
9+
describe('Bun CLI', () => {
10+
const binPath = './wgc';
11+
12+
test('bun cli should exist', () => {
13+
expect(existsSync(binPath)).toBe(true);
14+
});
15+
16+
test('bun cli should output the correct version', async () => {
17+
const { stdout, stderr, exitCode } = await $`${binPath} -V`.quiet();
18+
19+
expect(exitCode, `exited with non-zero:\nstdout:\n${stdout.toString()}\n\nstderr:\n${stderr.toString()}`).toBe(0);
20+
21+
expect(stdout.toString()).toBe(packageJSON.version + '\n');
22+
});
23+
});
24+
25+
describe('Node CLI', () => {
26+
const binPath = packageJSON.bin;
27+
28+
test('node cli should exist', () => {
29+
expect(existsSync(binPath)).toBe(true);
30+
});
31+
32+
test('node cli should output the correct version', async () => {
33+
const { stdout, stderr, exitCode } = await $`node ${binPath} -V`.quiet();
34+
35+
expect(exitCode, `exited with non-zero:\nstdout:\n${stdout.toString()}\n\nstderr:\n${stderr.toString()}`).toBe(0);
36+
37+
expect(stdout.toString()).toBe(packageJSON.version + '\n');
38+
});
39+
});

cli/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
"build": "del dist && tsc",
2323
"build:bun": "bun build --compile src/index.ts --outfile wgc",
2424
"wgc": "tsx --env-file .env src/index.ts",
25-
"test": "pnpm lint && vitest run",
25+
"test": "pnpm lint && vitest run test/",
2626
"coverage": "vitest run --coverage",
2727
"lint": "eslint --cache --ext .ts,.mjs,.cjs . && prettier -c src",
28-
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && prettier --write -c src"
28+
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && prettier --write -c src",
29+
"e2e": "bun test e2e/"
2930
},
3031
"keywords": [
3132
"wundergraph",
@@ -67,6 +68,7 @@
6768
"undici": "^6.19.8"
6869
},
6970
"devDependencies": {
71+
"@types/bun": "^1.2.3",
7072
"@types/cli-progress": "^3.11.5",
7173
"@types/cli-table": "^0.3.1",
7274
"@types/decompress": "^4.2.7",

cli/src/commands/contract/commands/create.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ export default (opts: BaseCommandOptions) => {
134134
if (resp.response?.details) {
135135
console.error(pc.red(pc.bold(resp.response?.details)));
136136
}
137-
process.exit(1);
137+
process.exitCode = 1;
138+
return;
138139
}
139140
}
140141

cli/src/commands/contract/commands/update.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ export default (opts: BaseCommandOptions) => {
131131
if (resp.response?.details) {
132132
console.error(pc.red(pc.bold(resp.response?.details)));
133133
}
134-
process.exit(1);
134+
process.exitCode = 1;
135+
return;
135136
}
136137
}
137138

cli/src/commands/feature-flag/commands/create.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export default (opts: BaseCommandOptions) => {
7676
suppressWarnings: options.suppressWarnings,
7777
});
7878
} catch {
79-
process.exit(1);
79+
process.exitCode = 1;
80+
// eslint-disable-next-line no-useless-return
81+
return;
8082
}
8183
});
8284

cli/src/commands/feature-flag/commands/delete.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default (opts: BaseCommandOptions) => {
2323
message: `Are you sure you want to delete the feature flag "${name}"?`,
2424
});
2525
if (!deletionConfirmed.confirmDeletion) {
26-
process.exit(1);
26+
process.exitCode = 1;
27+
return;
2728
}
2829
}
2930

@@ -61,7 +62,9 @@ export default (opts: BaseCommandOptions) => {
6162
suppressWarnings: options.suppressWarnings,
6263
});
6364
} catch {
64-
process.exit(1);
65+
process.exitCode = 1;
66+
// eslint-disable-next-line no-useless-return
67+
return;
6568
}
6669
});
6770

cli/src/commands/feature-flag/commands/disable.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export default (opts: BaseCommandOptions) => {
5353
suppressWarnings: options.suppressWarnings,
5454
});
5555
} catch {
56-
process.exit(1);
56+
process.exitCode = 1;
57+
// eslint-disable-next-line no-useless-return
58+
return;
5759
}
5860
});
5961

cli/src/commands/feature-flag/commands/enable.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export default (opts: BaseCommandOptions) => {
5353
suppressWarnings: options.suppressWarnings,
5454
});
5555
} catch {
56-
process.exit(1);
56+
process.exitCode = 1;
57+
// eslint-disable-next-line no-useless-return
58+
return;
5759
}
5860
});
5961

0 commit comments

Comments
 (0)