Skip to content

Commit c20a961

Browse files
authored
Merge pull request #620 from apollographql/AMS-238
ci: run e2e tests in CI
2 parents a540f46 + a1c08c7 commit c20a961

File tree

6 files changed

+43
-12
lines changed

6 files changed

+43
-12
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@ jobs:
7070
token: ${{ secrets.CODECOV_TOKEN }}
7171
files: codecov.json
7272
fail_ci_if_error: true
73+
74+
e2e:
75+
name: End-to-End Tests
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v6
79+
80+
- uses: actions-rust-lang/setup-rust-toolchain@v1
81+
82+
- uses: actions/setup-node@v4
83+
with:
84+
node-version: '20'
85+
86+
- name: Build release binary
87+
run: cargo build --release
88+
89+
- name: Run e2e tests (local-operations)
90+
run: ./e2e/mcp-server-tester/run_tests.sh local-operations
91+
92+
- name: Run e2e tests (pq-manifest)
93+
run: ./e2e/mcp-server-tester/run_tests.sh pq-manifest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ target/
2222
# and can be added to the global gitignore or merged into this file. For a more nuclear
2323
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2424
#.idea/
25+
26+
# Generated e2e test configs
27+
e2e/**/config.generated.yaml

e2e/mcp-server-tester/local-operations/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ transport:
44
operations:
55
source: local
66
paths:
7-
- ./local-operations/operations
7+
- <test-dir>/operations
88
schema:
99
source: local
10-
path: ./local-operations/api.graphql
10+
path: <test-dir>/api.graphql
1111
overrides:
1212
mutation_mode: all
1313
introspection:

e2e/mcp-server-tester/pq-manifest/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ transport:
33
type: stdio
44
operations:
55
source: manifest
6-
path: ./pq-manifest/apollo.json
6+
path: <test-dir>/apollo.json
77
schema:
88
source: local
9-
path: ./pq-manifest/api.graphql
9+
path: <test-dir>/api.graphql
1010
overrides:
1111
mutation_mode: all
1212
introspection:

e2e/mcp-server-tester/run_tests.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ else
3030
TEST_DIR="$(cd -P -- "$SCRIPT_DIR/$RAW_DIR_ARG" && pwd)"
3131
fi
3232

33-
TEST_DIR="${1%/}" # strip trailing slash if present
3433
TESTS="$TEST_DIR/tool-tests.yaml"
3534
MCP_CONFIG="$TEST_DIR/config.yaml"
3635

@@ -62,13 +61,21 @@ cleanup() { rm -rf "$TMP_DIR"; }
6261
trap cleanup EXIT INT TERM # cleanup before exiting
6362
GEN_CONFIG="$TMP_DIR/server-config.generated.json"
6463

65-
# Safe replacement for <test-dir> with absolute path (handles /, &, and |)
64+
# Safe replacement for paths with absolute path (handles /, &, and |)
6665
safe_dir="${TEST_DIR//\\/\\\\}"
6766
safe_dir="${safe_dir//&/\\&}"
6867
safe_dir="${safe_dir//|/\\|}"
6968

70-
# Replace the literal token "<test-dir>" everywhere
71-
sed "s|<test-dir>|$safe_dir|g" "$TEMPLATE_PATH" > "$GEN_CONFIG"
69+
safe_bin="${BIN_PATH//\\/\\\\}"
70+
safe_bin="${safe_bin//&/\\&}"
71+
safe_bin="${safe_bin//|/\\|}"
7272

73-
# Run the command
74-
npx -y mcp-server-tester@1.4.0 tools "$TESTS" --server-config "$GEN_CONFIG"
73+
# Generate MCP config.yaml with absolute paths
74+
GEN_MCP_CONFIG="$TEST_DIR/config.generated.yaml"
75+
sed -e "s|<test-dir>|$safe_dir|g" "$MCP_CONFIG" > "$GEN_MCP_CONFIG"
76+
77+
# Replace the literal tokens "<test-dir>" and "<bin-path>" in server config
78+
sed -e "s|<test-dir>|$safe_dir|g" -e "s|<bin-path>|$safe_bin|g" "$TEMPLATE_PATH" > "$GEN_CONFIG"
79+
80+
# Run the command (ignore-scripts needed due to mcp-server-tester's postinstall requiring patch-package)
81+
npm_config_ignore_scripts=true npx -y mcp-server-tester@1.4.1 tools "$TESTS" --server-config "$GEN_CONFIG"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"mcpServers": {
33
"mcp-server": {
4-
"command": "../../target/release/apollo-mcp-server",
5-
"args": ["./<test-dir>/config.yaml"]
4+
"command": "<bin-path>",
5+
"args": ["<test-dir>/config.generated.yaml"]
66
}
77
}
88
}

0 commit comments

Comments
 (0)