Skip to content
Open
Show file tree
Hide file tree
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
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-

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

- name: Run unit tests
run: |
pytest tests/unittest/ -v --cov=pr_agent --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort

- name: Run flake8
run: flake8 pr_agent/ --count --select=E9,F63,F7,F82 --show-source --statistics

- name: Check code formatting with black
run: black --check pr_agent/

- name: Check import sorting with isort
run: isort --check-only --diff pr_agent/
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Tusk Test Runner - httpsgithubcomXoRohanpragenttreemainpragent pytest unit tests

# Required for Tusk
on:
workflow_dispatch:
inputs:
runId:
description: "Tusk Run ID"
required: true
tuskUrl:
description: "Tusk server URL"
required: true
commitSha:
description: "Commit SHA to checkout"
required: true

jobs:
test-action:
name: Tusk Test Runner
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commitSha }} # Required for Tusk to access files for the commit being tested

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-

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

- name: Start runner
id: test-action
uses: Use-Tusk/test-runner@v1
# See https://github.com/Use-Tusk/test-runner for full details and examples.
with:
# Required for the test runner, do not remove this input
runId: ${{ github.event.inputs.runId }}

# Required for the test runner, do not remove this input
tuskUrl: ${{ github.event.inputs.tuskUrl }}

# Required for the test runner, do not remove this input
commitSha: ${{ github.event.inputs.commitSha }}

# Your Tusk auth token. It is recommended to add it to your repo's secrets.
# Please adapt the secret name accordingly if you have named it differently.
authToken: ${{ secrets.TUSK_AUTH_TOKEN }}

# The directory containing your service code. If you have a monorepo containing multiple
# services, create a separate workflow for each service with a different (and non-overlapping) appDir.
# appDir should be relative to the root of the repo.
# Remove this input if this doesn't apply to your repo (i.e., it is a single-service repo).
appDir: "https://github.com/XoRohan/pr-agent/tree/main/pr_agent"

# You may specify the test framework if it is a different one
testFramework: "pytest"

# Test file regex to match all test files in the service
# This is relative to the root of the repo (i.e., the appDir should be included in it, if applicable).
testFileRegex: ''^https://github.com/XoRohan/pr-agent/tree/main/pr_agent/.*(test_.*|.*_test).py'

# The script to run to lint the code (adapt accordingly).
# This should be a command that fixes lint errors, not just checking for them.
# {{file}} placeholder is required and will be replaced by Tusk with the file being linted.
# If you don't have a lint command, you can remove this input.
# Example (Python w/ black): "black {{file}}"
# Example (TypeScript w/ prettier + eslint): "npx prettier --write {{file}} && npx eslint --fix {{file}}"
# If you need to run a compilation check (e.g. tsc), contact support@usetusk.ai to ensure it is set up correctly.
lintScript: '<your lint command for {{file}}>'

# The script to run to test the code (adapt accordingly). Required for the test runner.
# {{file}} placeholder is required and will be replaced by Tusk with the file being tested.
# Example (pytest): "pytest {{file}}"
# If your test output is known to contain a lot of console logs, we recommend suppressing these logs (e.g., use --silent / --quiet flags or equivalent).
testScript: '<your test command for {{file}}>'

# The runner may run tests in parallel.
# Set this value to 1 if you know that your tests should not be run concurrently.
# maxConcurrency: 1
'

# The script to run to lint the code (adapt accordingly).
# This should be a command that fixes lint errors, not just checking for them.
# {{file}} placeholder is required and will be replaced by Tusk with the file being linted.
# If you don't have a lint command, you can remove this input.
# Example (Python w/ black): "black {{file}}"
# Example (TypeScript w/ prettier + eslint): "npx prettier --write {{file}} && npx eslint --fix {{file}}"
# If you need to run a compilation check (e.g. tsc), contact support@usetusk.ai to ensure it is set up correctly.
<lintRecord>

# The script to run to test the code (adapt accordingly). Required for the test runner.
# {{file}} placeholder is required and will be replaced by Tusk with the file being tested.
# Example (pytest): "pytest {{file}}"
# If your test output is known to contain a lot of console logs, we recommend suppressing these logs (e.g., use --silent / --quiet flags or equivalent).
testScript: <testScript>

# The runner may run tests in parallel.
# Set this value to 1 if you know that your tests should not be run concurrently.
# maxConcurrency: 1
Loading