Skip to content

Commit

Permalink
Add testing workflow (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
varun646 authored Aug 26, 2024
2 parents 77b52ca + 8ca74a1 commit 4a94aa5
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Standard"
run-name: ${{ github.run_number }} [${{ github.actor }}] on ${{ github.ref_name }}

on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
- cron: '0 0 * * *' # Once a day at 12am UTC
workflow_dispatch:

jobs:
# ----------------------------------------------------------------------
validate:
name: Validate
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
python_version:
- "3.12"
- "3.11"
- "3.10"

env:
COLUMNS: "200"
SIMULATE_TERMINAL_CAPABILITIES_SUPPORTS_COLORS: "1"
PYTHONIOENCODING: "UTF-8"

permissions: {}

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest pytest-cov
pytest tests/test_generation.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html --subset-percentage 0.05
27 changes: 27 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random


def pytest_addoption(parser):
parser.addoption(
"--subset-percentage",
action="store",
default=None,
help="Specify the percentage of tests to run as a subset (e.g., 0.3 for 30%)",
)


def pytest_collection_modifyitems(config, items):
subset_percentage = config.getoption("--subset-percentage")

# If the subset percentage is provided, apply it
if subset_percentage is not None:
subset_percentage = float(subset_percentage)

# Shuffle the test cases
random.shuffle(items)

# Calculate the number of tests to run based on percentage
subset_count = int(len(items) * subset_percentage)

# Select a subset of tests
items[:] = items[:subset_count]

0 comments on commit 4a94aa5

Please sign in to comment.