Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ CI / CD - run tests on every commit #690

Merged
merged 31 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
517731f
after docker image is built by github pr, set env vars & run tests
ElishaKay Jul 19, 2024
c5245d7
tests
ElishaKay Jul 23, 2024
81e2bfa
fix
ElishaKay Jul 23, 2024
498b83f
requirements.txt install test libs
ElishaKay Jul 24, 2024
dfd7b8e
pass secrets
ElishaKay Jul 24, 2024
53a6f3a
run tests with docker-compose
ElishaKay Jul 24, 2024
4b67c82
compose
ElishaKay Jul 24, 2024
7c038ee
cr
ElishaKay Jul 24, 2024
173bdbc
compose
ElishaKay Jul 24, 2024
7b07d8c
type definitions for nextjs
ElishaKay Aug 16, 2024
1eb7d3e
docker-compose fix
ElishaKay Aug 16, 2024
3a8b066
automated tests should only run: (a) When the PR is created (b) When …
ElishaKay Aug 16, 2024
61cf2a3
are keys on main repo?
ElishaKay Aug 16, 2024
5ea880f
pytest & pytest-asyncio moved out of requirements.txt into the docker…
ElishaKay Aug 16, 2024
c5155e1
ensure we're using the Python interpreter in automated tests to run p…
ElishaKay Aug 16, 2024
471e3c2
3-report-types.py
ElishaKay Aug 16, 2024
e1957fd
tests env
ElishaKay Aug 18, 2024
5c51a8d
env tests
ElishaKay Aug 18, 2024
46bc71a
ci fixes
ElishaKay Aug 18, 2024
822b68a
remove custom-report test for now
ElishaKay Aug 18, 2024
f538e04
1 test
ElishaKay Aug 18, 2024
6591184
tests
ElishaKay Aug 18, 2024
2735dda
verify test runs
ElishaKay Aug 19, 2024
0f561a1
replicate working tests
ElishaKay Aug 19, 2024
d4cca6e
edit tests
ElishaKay Aug 19, 2024
492f9f0
pytest install via docker - not requirements.txt
ElishaKay Aug 19, 2024
f0745c6
verify permissions
ElishaKay Aug 19, 2024
5b6cce6
conditionally run tests only if env vars are set in github repo
ElishaKay Aug 19, 2024
e6da357
cleanup
ElishaKay Aug 19, 2024
9d5b08f
enable manual triggering of GPTR tests flow
ElishaKay Aug 19, 2024
ff93806
removed nextjs folder change in docker (handled in separate PR)
ElishaKay Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: GPTR tests
run-name: ${{ github.actor }} ran the GPTR tests flow
permissions:
contents: read
pull-requests: write
on:
workflow_dispatch: # Add this line to enable manual triggering
# pull_request:
# types: [opened, synchronize]

jobs:
docker:
runs-on: ubuntu-latest
environment: tests # Specify the environment to use for this job
env:
# Ensure these environment variables are set for the entire job
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
LANGCHAIN_API_KEY: ${{ secrets.LANGCHAIN_API_KEY }}
steps:
- name: Git checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker

# - name: Build Docker images
# uses: docker/build-push-action@v4
# with:
# push: false
# tags: gptresearcher/gpt-researcher:latest
# file: Dockerfile

- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Run tests with Docker Compose
run: |
docker-compose run --rm gpt-researcher-tests
24 changes: 0 additions & 24 deletions .github/workflows/docker-bulid.yml

This file was deleted.

6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ RUN pip install -r multi_agents/requirements.txt

FROM gpt-researcher-install AS gpt-researcher

ARG OPENAI_API_KEY
ARG TAVILY_API_KEY

ENV OPENAI_API_KEY=${OPENAI_API_KEY}
ENV TAVILY_API_KEY=${TAVILY_API_KEY}

RUN useradd -ms /bin/bash gpt-researcher \
&& chown -R gpt-researcher:gpt-researcher /usr/src/app

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

The agent can produce detailed, factual and unbiased research reports, with customization options for focusing on relevant resources and outlines. Inspired by the recent [Plan-and-Solve](https://arxiv.org/abs/2305.04091) and [RAG](https://arxiv.org/abs/2005.11401) papers, GPT Researcher addresses issues of misinformation, speed, determinism and reliability, offering a more stable performance and increased speed through parallelized agent work, as opposed to synchronous operations.

**Our mission is to empower individuals and organizations with accurate, unbiased, and factual information by leveraging the power of AI.**
**Our mission is to empower individuals and organizations with accurate, unbiased, and factual information by leveraging the power of AI.**

## Why GPT Researcher?

Expand Down
5 changes: 5 additions & 0 deletions application/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ services:
restart: always
ports:
- 3000:3000

gpt-researcher-tests:
image: gptresearcher/gpt-researcher
build: ./
environment:
OPENAI_API_KEY: ${OPENAI_API_KEY}
TAVILY_API_KEY: ${TAVILY_API_KEY}
LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY}
command: >
/bin/sh -c "
pip install pytest pytest-asyncio &&
python -m pytest tests/report-types.py
"
10 changes: 3 additions & 7 deletions tests/all-6-report-types.py → tests/report-types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
# Define the report types to test
report_types = [
"research_report",
"custom_report",
"subtopic_report",
"summary_report",
"detailed_report",
"quick_report"
"subtopic_report"
]

# Define a common query and sources for testing
query = "What are the latest advancements in AI?"
sources = ["https://en.wikipedia.org/wiki/Artificial_intelligence", "https://www.ibm.com/watson/ai"]
# sources = ["https://en.wikipedia.org/wiki/Artificial_intelligence", "https://www.ibm.com/watson/ai"]

# Define the output directory
output_dir = "./outputs"
Expand All @@ -28,7 +24,7 @@ async def test_gpt_researcher(report_type):
os.makedirs(output_dir)

# Create an instance of GPTResearcher
researcher = GPTResearcher(query=query, report_type=report_type, source_urls=sources)
researcher = GPTResearcher(query=query, report_type=report_type)

# Conduct research and write the report
await researcher.conduct_research()
Expand Down