Skip to content
Merged
Changes from all commits
Commits
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: 36 additions & 9 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
name: Unit Tests for CAIS Core Functions

permissions:
contents: read

on:
push:
branches: [main]
pull_request_target:
pull_request:
types: [opened, ready_for_review, reopened, synchronize]
repository_dispatch:
types: [create-pull-request]
workflow_dispatch:

jobs:
test:
name: pytest
fork-tests:
name: pytest without external API access
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
environment:
name: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork && 'causal-agent' || '' }}
deployment: false
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
ref: ${{ github.event.pull_request.head.sha }} # checks out the fork's code
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage pytest
pip install -r requirements.txt

- name: Test with pytest
run: coverage run -m pytest -v -s

- name: Generate Coverage Report
run: coverage report -m

trusted-tests:
name: pytest with external API access
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
environment: causal-agent
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -41,4 +68,4 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

- name: Generate Coverage Report
run: coverage report -m
run: coverage report -m
Loading