-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-tests.yml
More file actions
57 lines (52 loc) · 1.98 KB
/
generate-tests.yml
File metadata and controls
57 lines (52 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Generate Missing Tests — Prompt2PR Example Workflow
#
# Scans source files for untested functions and generates unit tests.
# The LLM reads both source and test files to understand existing patterns,
# then creates new tests that follow the same style.
#
# Important: The LLM cannot execute the generated tests. The PR should be
# treated as a starting point — review the tests, run your test suite,
# and fix any issues before merging. Tests may need adjustments for
# mocking, fixtures, or edge cases the LLM couldn't infer.
#
# Setup:
# 1. Copy this file to .github/workflows/generate-tests.yml
# 2. Add OPENAI_API_KEY as a GitHub Secret
# 3. Adjust the paths and test framework references for your project
name: Generate Missing Tests
on:
schedule:
# Run every Thursday at 7:00 UTC
- cron: '0 7 * * 4'
workflow_dispatch:
inputs:
prompt:
description: 'Custom prompt (optional — overrides default)'
required: false
default: ''
permissions:
contents: write
pull-requests: write
jobs:
generate-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: davd-gzl/Prompt2PR@v1
with:
prompt: >-
${{ github.event.inputs.prompt || 'Analyze the source files and
their corresponding test files. Identify exported functions or
classes that have no test coverage. For each untested export, create
test cases in the appropriate test file following the existing test
patterns (describe/it structure, naming conventions, assertion
style). Use Jest with TypeScript. Focus on happy-path and basic
error cases. Only create tests — do not modify source files.' }}
provider: 'openai'
paths: 'src/**,__tests__/**'
max_files: 5
max_changes: 200
label: 'prompt2pr,tests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}