-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (136 loc) · 6.26 KB
/
test.yml
File metadata and controls
162 lines (136 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: MCP Tests
on:
pull_request:
jobs:
###########################################################################
# 1 - Local integration tests (always run)
###########################################################################
local:
runs-on: ubuntu-latest
# Dummy key lets the clients authenticate against the local servers.
env:
API_KEY: ci-test-key
steps:
- uses: actions/checkout@v4
- name: Read Python version from .python-version
id: python-version
run: |
PY_VERSION=$(cat .python-version)
echo "version=$PY_VERSION" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with:
python-version: ${{ steps.python-version.outputs.version }}
- name: Read Node.js version from package.json
id: node-version
run: |
NODE_VERSION=$(jq -r '.engines.node' package.json)
echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.node-version.outputs.version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pytest (local transports)
run: pytest -q
###########################################################################
# 2 - Deploy this PR to a temp Heroku app and run tests against deployed app (in addition to 'local')
###########################################################################
# # These e2d deployment tests are super useful, but require you to add a HEROKU_API_KEY to your repo's actions secrets.
# # --> Uncomment after adding HEROKU_API_KEY to your forked repo's github action secrets.
# remote:
# runs-on: ubuntu-latest
# env:
# HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
# API_KEY: ci-test-key
# # also note that github CI doesn't have access to your app's config vars, so here we're setting the remote
# # server type to streamable HTTP. Folks using SSE would need to change this line for their e2e remote integration
# # tests to test SSE instead of streamable HTTP.
# REMOTE_SERVER_TRANSPORT_MODULE: streamable_http_server
# # $APP_NAME is set below because we need to shorten the repo owner's name, as a precaution
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # <-- disables shallow clone, which heroku is upset by when running git push heroku later on
# # Setting a short $APP_NAME that will be unique even if folks choose to fork this repo --> avoids clashes.
# # Needs to be shortened if the github repo owner has a long name (max 30 char app name heroku limit).
# - name: Generate short APP_NAME
# id: appname
# run: |
# OWNER_SHORT=${GITHUB_REPOSITORY_OWNER:0:5}
# REPO_NAME=$(basename "$GITHUB_REPOSITORY")
# PR_NUMBER=$(jq .number "$GITHUB_EVENT_PATH")
# APP_NAME="${OWNER_SHORT}-${REPO_NAME}-${PR_NUMBER}"
# echo "APP_NAME=$APP_NAME"
# echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV
# - name: Read Python version from .python-version
# id: python-version
# run: |
# PY_VERSION=$(cat .python-version)
# echo "version=$PY_VERSION" >> $GITHUB_OUTPUT
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ steps.python-version.outputs.version }}
# - name: Read Node.js version from package.json
# id: node-version
# run: |
# NODE_VERSION=$(jq -r '.engines.node' package.json)
# echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ steps.node-version.outputs.version }}
# - name: Install Heroku CLI
# run: |
# curl https://cli-assets.heroku.com/install.sh | sh
# - name: Log in to Heroku
# run: |
# echo "$HEROKU_API_KEY" | heroku auth:token
# - name: Pre-cleanup (destroy app if it exists)
# continue-on-error: true
# run: |
# heroku apps:destroy --app $APP_NAME --confirm $APP_NAME
# # github CI can't use our app.json, so the config etc bits must be set manually.
# # note WEB_CONCURRENCY is important! You get non-deterministic errors w/out it.
# - name: Create temp Heroku app for this PR
# run: |
# heroku create $APP_NAME
# heroku buildpacks:add --index 1 heroku/nodejs -a $APP_NAME
# heroku buildpacks:add --index 2 heroku/python -a $APP_NAME
# heroku config:set API_KEY=$API_KEY --app $APP_NAME
# heroku config:set STDIO_MODE_ONLY=false
# heroku config:set REMOTE_SERVER_TRANSPORT_MODULE=$REMOTE_SERVER_TRANSPORT_MODULE --app $APP_NAME
# heroku config:set WEB_CONCURRENCY=1 --app $APP_NAME
# - name: Deploy this branch to Heroku
# run: |
# git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$APP_NAME.git HEAD:refs/heads/main --force
# - uses: actions/cache@v4
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
# - name: Install test dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# - name: Get Heroku env vars
# id: heroku_env
# run: |
# url=$(heroku info -s -a $APP_NAME | grep web_url | cut -d= -f2 | tr -d '\n')
# echo "url=$url" >> "$GITHUB_OUTPUT"
# - name: Run pytest against deployed app
# env:
# MCP_SERVER_URL: ${{ steps.heroku_env.outputs.url }}
# run: |
# echo "APP_NAME = $APP_NAME"
# echo "MCP_SERVER_URL = $MCP_SERVER_URL"
# echo "REMOTE_SERVER_TRANSPORT_MODULE = $REMOTE_SERVER_TRANSPORT_MODULE"
# echo "API_KEY is ${API_KEY:+set}" # won't print the key, just confirms it's non-empty
# pytest -q
# - name: Destroy Heroku app after test
# if: always()
# run: |
# heroku apps:destroy --app $APP_NAME --confirm $APP_NAME