Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit a82d687

Browse files
authored
wasm bug fixes, and added smoke tests and ci workflow (#389)
1 parent d5d39ad commit a82d687

37 files changed

+3076
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: cargo install -q worker-build && worker-build
3131

3232
- name: test
33-
run: cargo test -- --nocapture
33+
run: cargo test --workspace --exclude smoke_tests -- --nocapture
3434
env:
3535
RUST_BACKTRACE: full
3636

@@ -47,6 +47,74 @@ jobs:
4747
working-directory: libs/napi
4848
run: yarn build
4949

50+
smoke-test:
51+
name: smoke test
52+
needs:
53+
- build
54+
runs-on: ubuntu-22.04
55+
steps:
56+
- name: checkout
57+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
58+
59+
- name: setup environment
60+
uses: ./.github/actions/setup
61+
62+
- name: run containers
63+
working-directory: libs/smoke_tests/
64+
run: docker compose -f docker-compose.yaml up -d
65+
66+
- uses: JarvusInnovations/background-action@v1
67+
name: run test server in background
68+
with:
69+
run: cargo run
70+
working-directory: tests/test-server
71+
wait-on: http-get://127.0.0.1:4000
72+
tail: true
73+
wait-for: 10m
74+
log-output-if: failure
75+
log-output: true
76+
77+
- uses: JarvusInnovations/background-action@v1
78+
name: run gateway in background (binary)
79+
with:
80+
run: cargo run --bin conductor -- ./libs/smoke_tests/test_gw.yaml
81+
wait-on: http-get://127.0.0.1:9000/graphql
82+
tail: true
83+
wait-for: 15m
84+
log-output-if: failure
85+
log-output: true
86+
87+
- name: run tests (binary)
88+
working-directory: libs/smoke_tests/
89+
run: cargo test --features binary -- --nocapture
90+
env:
91+
CONDUCTOR_URL: http://127.0.0.1:9000
92+
93+
- uses: the-guild-org/shared-config/setup@main
94+
name: setup env (wasm)
95+
with:
96+
nodeVersion: 20
97+
packageManager: pnpm
98+
workingDirectory: bin/cloudflare_worker
99+
packageManagerVersion: 8
100+
101+
- uses: JarvusInnovations/background-action@v1
102+
name: run gateway in background (wasm)
103+
with:
104+
working-directory: bin/cloudflare_worker
105+
run: pnpm start:smoke
106+
wait-on: http-get://127.0.0.1:8787/graphql
107+
tail: true
108+
wait-for: 15m
109+
log-output-if: failure
110+
log-output: true
111+
112+
- name: run tests (wasm)
113+
working-directory: libs/smoke_tests/
114+
run: cargo test --features wasm -- --nocapture
115+
env:
116+
CONDUCTOR_URL: http://127.0.0.1:8787
117+
50118
graphql-over-http:
51119
runs-on: ubuntu-22.04
52120
steps:
@@ -151,7 +219,7 @@ jobs:
151219
- name: run panic free analyzer
152220
run: cargo panic-analyzer > ./panic-audit.md
153221
env:
154-
IGNORED_CRATES: e2e_tests,benches,server
222+
IGNORED_CRATES: smoke_tests,e2e_tests,benches,server
155223
IGNORED_FILES: ./plugins/jwt_auth/src/test.rs
156224

157225
- name: comment on pull request

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[workspace]
22
resolver = "2"
33
members = ["bin/*", "libs/*", "plugins/*"]
4-
exclude = ["bin/npm", "tests/test-server", "tools/panic_free_analyzer"]
4+
exclude = ["bin/npm", "tests/test-server"]
55

66
[workspace.dependencies]
77
tokio = "1.35.1"

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> [!IMPORTANT]
88
> Conductor gateway is still under development, and currently available as alpha.
99
>
10-
> Please use it with caution. Feedback and Contributions are always welcome!
10+
> Please use it with caution. Feedback and Contributions are always welcome!
1111
1212
# Conductor: MIT open-source GraphQL Gateway
1313

@@ -53,6 +53,12 @@ Conductor's configuration can be defined in both YAML and JSON formats. The conf
5353
### Configuration File Example
5454

5555
```yaml
56+
server:
57+
port: 9000
58+
59+
logger:
60+
filter: error
61+
5662
sources:
5763
- type: graphql
5864
id: my-source
@@ -63,12 +69,10 @@ endpoints:
6369
- path: /graphql
6470
from: my-source
6571
plugins:
72+
- type: cors
73+
config:
74+
allowed_origin: "*"
6675
- type: graphiql
67-
68-
plugins:
69-
- type: cors
70-
config:
71-
allowed_origin: "*"
7276
```
7377
7478
## Running Conductor
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[target.wasm32-unknown-unknown]
2+
rustflags = [
3+
"-C", "link-args=-z stack-size=3000000",
4+
]

bin/cloudflare_worker/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"scripts": {
66
"deploy": "wrangler deploy",
7-
"dev": "wrangler dev --var \"CONDUCTOR_CONFIG:$(cat ../../test_config/worker.yaml)\""
7+
"dev": "wrangler dev --var \"CONDUCTOR_CONFIG:$(cat ../../test_config/worker.yaml)\"",
8+
"start:smoke": "wrangler dev --var \"ENABLE_WASM_FEATURES:false\" --var \"CONDUCTOR_CONFIG:$(cat ../../libs/smoke_tests/test_gw.yaml)\""
89
},
910
"devDependencies": {
1011
"wrangler": "3.25.0"

bin/conductor/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ COPY plugins plugins
99
COPY bin bin
1010
RUN rm -rf lib/benches
1111
RUN rm -rf lib/e2e_tests
12+
RUN rm -rf lib/smoke_tests
1213
RUN echo 'fn main() { println!(""); }' > ./bin/conductor/src/main.rs
1314
RUN echo 'fn main() { println!(""); }' > ./bin/conductor/src/lib.rs
1415
# We are only building the dependencies here, with a dummy file, this compiles all dependencies code only.

libs/common/src/graphql.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ impl Display for GraphQLRequest {
6464

6565
#[derive(thiserror::Error, Debug)]
6666
pub enum ExtractGraphQLOperationError {
67+
#[error("invalid url query parameter")]
68+
InvalidQueryParameterEncoding,
6769
#[error("missing query parameter")]
6870
MissingQueryParameter,
6971
#[error("invalid content-type header")]

libs/config/conductor.schema.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"type": {
163163
"type": "string",
164164
"enum": [
165-
"mocl"
165+
"mock"
166166
]
167167
},
168168
"id": {
@@ -1706,14 +1706,7 @@
17061706
"cache_duration": {
17071707
"description": "Duration after which the cached JWKS should be expired. If not specified, the default value will be used.",
17081708
"default": "10m",
1709-
"anyOf": [
1710-
{
1711-
"$ref": "#/definitions/Duration"
1712-
},
1713-
{
1714-
"type": "null"
1715-
}
1716-
]
1709+
"type": "string"
17171710
},
17181711
"prefetch": {
17191712
"description": "If set to `true`, the JWKS will be fetched on startup and cached. In case of invalid JWKS, the error will be ignored and the plugin will try to fetch again when server receives the first request. If set to `false`, the JWKS will be fetched on-demand, when the first request comes in.",

libs/config/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub enum SourceDefinition {
403403
/// The configuration for the GraphQL source.
404404
config: GraphQLSourceConfig,
405405
},
406-
#[serde(rename = "mocl")]
406+
#[serde(rename = "mock")]
407407
/// A simple, single GraphQL endpoint
408408
Mock {
409409
/// The identifier of the source. This is used to reference the source in the `from` field of an endpoint definition.
@@ -601,7 +601,7 @@ pub fn parse_config_contents(
601601
}
602602
Err(errors) => {
603603
for error in errors {
604-
println!("error: {}", error);
604+
println!("error: {:?}", error);
605605
}
606606

607607
// @expected: 👇

0 commit comments

Comments
 (0)