@@ -36,81 +36,107 @@ jobs:
3636 LANGFUSE_BASE_URL : " http://localhost:3000"
3737 LANGFUSE_SECRET_KEY : " sk-lf-1234567890"
3838 LANGFUSE_PUBLIC_KEY : " pk-lf-1234567890"
39+ LANGFUSE_INIT_ORG_ID : " 0c6c96f4-0ca0-4f16-92a8-6dd7d7c6a501"
40+ LANGFUSE_INIT_ORG_NAME : " SDK Test Org"
41+ LANGFUSE_INIT_PROJECT_ID : " 7a88fb47-b4e2-43b8-a06c-a5ce950dc53a"
42+ LANGFUSE_INIT_PROJECT_NAME : " SDK Test Project"
43+ LANGFUSE_INIT_PROJECT_PUBLIC_KEY : " pk-lf-1234567890"
44+ LANGFUSE_INIT_PROJECT_SECRET_KEY : " sk-lf-1234567890"
45+ LANGFUSE_INIT_USER_EMAIL : " sdk-tests@langfuse.local"
46+ LANGFUSE_INIT_USER_NAME : " SDK Tests"
47+ LANGFUSE_INIT_USER_PASSWORD : " langfuse-ci-password"
3948 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
4049
4150 steps :
4251 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
4352 - uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
44-
45- - name : Clone langfuse server
46- run : |
47- git clone https://github.com/langfuse/langfuse.git ./langfuse-server
48-
49- - name : Cache langfuse server dependencies
50- uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
51- with :
52- path : ./langfuse-server/node_modules
53- key : |
54- langfuse-server-${{ hashFiles('./langfuse-server/package-lock.json') }}
55- langfuse-server-
56-
5753 - uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
5854 with :
59- node-version : 24 # https://github.com/langfuse/langfuse/blob/main/package.json#L8
55+ node-version : 20
56+
57+ - name : Prepare langfuse server compose
58+ run : |
59+ mkdir -p ./langfuse-server
60+ LANGFUSE_SERVER_SHA="$(git ls-remote https://github.com/langfuse/langfuse.git HEAD | cut -f1)"
61+ curl -fsSL "https://raw.githubusercontent.com/langfuse/langfuse/${LANGFUSE_SERVER_SHA}/docker-compose.yml" \
62+ -o ./langfuse-server/docker-compose.yml
63+ echo "${LANGFUSE_SERVER_SHA}"
6064
6165 - name : Run langfuse server
6266 run : |
6367 cd ./langfuse-server
6468
65- echo "::group::Run langfuse server"
66- TELEMETRY_ENABLED=false docker compose up -d postgres
67- echo "::endgroup::"
68-
69- echo "::group::Logs from langfuse server"
70- TELEMETRY_ENABLED=false docker compose logs
71- echo "::endgroup::"
72-
73- echo "::group::Install dependencies (necessary to run seeder)"
74- pnpm i
75- echo "::endgroup::"
76-
77- echo "::group::Seed db"
78- cp .env.dev.example .env
79- pnpm run db:migrate
80- pnpm run db:seed
81- rm -rf node_modules
82- rm -rf .env
83-
84- echo "::group::Run server"
69+ echo "::group::Start langfuse server"
8570 TELEMETRY_ENABLED=false \
71+ NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=true \
8672 LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT=http://localhost:9090 \
8773 LANGFUSE_INGESTION_QUEUE_DELAY_MS=10 \
8874 LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=10 \
75+ LANGFUSE_EXPERIMENT_INSERT_INTO_EVENTS_TABLE=true \
76+ QUEUE_CONSUMER_EVENT_PROPAGATION_QUEUE_IS_ENABLED=true \
77+ LANGFUSE_ENABLE_EVENTS_TABLE_V2_APIS=true \
78+ LANGFUSE_ENABLE_EVENTS_TABLE_OBSERVATIONS=true \
8979 docker compose up -d
90-
9180 echo "::endgroup::"
9281
93- # Add this step to check the health of the container
82+ - run : pnpm install
83+
9484 - name : Health check for langfuse server
9585 run : |
9686 echo "Checking if the langfuse server is up..."
9787 retry_count=0
98- max_retries=10
99- until curl --output /dev/null --silent --head --fail http://localhost:3000/api/public/health
88+ max_retries=20
89+ until curl --output /dev/null --silent --head --fail http://localhost:3000/api/public/health && \
90+ node - <<'NODE'
91+ const auth = Buffer.from(
92+ `${process.env.LANGFUSE_PUBLIC_KEY}:${process.env.LANGFUSE_SECRET_KEY}`,
93+ ).toString("base64");
94+
95+ fetch(`${process.env.LANGFUSE_BASE_URL}/api/public/projects`, {
96+ headers: {
97+ Authorization: `Basic ${auth}`,
98+ },
99+ })
100+ .then(async (response) => {
101+ if (!response.ok) {
102+ throw new Error(`Request failed with status ${response.status}`);
103+ }
104+
105+ return response.json();
106+ })
107+ .then((body) => {
108+ const project = body.data?.find(
109+ (candidate) =>
110+ candidate.id === process.env.LANGFUSE_INIT_PROJECT_ID,
111+ );
112+
113+ if (!project) {
114+ throw new Error(
115+ `Expected initialized project ${process.env.LANGFUSE_INIT_PROJECT_ID}`,
116+ );
117+ }
118+
119+ console.log(project.id);
120+ })
121+ .catch((error) => {
122+ console.error(error);
123+ process.exit(1);
124+ });
125+ NODE
100126 do
101127 retry_count=`expr $retry_count + 1`
102128 echo "Attempt $retry_count of $max_retries..."
103129 if [ $retry_count -ge $max_retries ]; then
104130 echo "Langfuse server did not respond in time. Printing logs..."
105- docker logs langfuse-server-langfuse-web-1
131+ (cd ./langfuse-server && docker compose ps)
132+ (cd ./langfuse-server && docker compose logs langfuse-web langfuse-worker)
106133 echo "Failing the step..."
107134 exit 1
108135 fi
109136 sleep 5
110137 done
111138 echo "Langfuse server is up and running!"
112139
113- - run : pnpm install
114140 - run : pnpm test:e2e
115141
116142 lint :
0 commit comments