This repository was archived by the owner on Jan 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
165 lines (148 loc) · 5.38 KB
/
action.yml
File metadata and controls
165 lines (148 loc) · 5.38 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: "CodeBeaver OSS Testing"
description: "Run AI-powered unit tests and E2E tests for your codebase"
author: "codebeaver-ai"
branding:
icon: "🦫"
color: "orange"
inputs:
action-type:
description: "Type of tests to run (unit, e2e, or both)"
required: false
default: "both"
open-pull-request:
description: "Whether to open a pull request with the changes"
required: false
default: "true"
github-token:
description: "GitHub token for authentication. If not provided, GITHUB_TOKEN will be used"
required: false
file-path:
description: "Path to the file to analyze for unit tests"
required: false
config-file:
description: "Path to the YAML configuration file"
required: false
template:
description: "Testing framework template to use (e.g., pytest, jest, vitest)"
required: false
max-files-to-test:
description: "Maximum number of files to generate unit tests for"
required: false
verbose:
description: "Enable verbose logging output"
required: false
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Install Chrome
shell: bash
if: inputs.action-type == 'e2e' || inputs.action-type == 'both'
run: |
if [ "$(uname)" == "Linux" ]; then
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update
sudo apt-get install -y google-chrome-stable
# Start Chrome in the background with remote debugging enabled
google-chrome --remote-debugging-port=9222 --no-sandbox --headless &
echo "CHROME_PATH=/usr/bin/google-chrome" >> $GITHUB_ENV
elif [ "$(uname)" == "Darwin" ]; then
# Start Chrome in the background with remote debugging enabled
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222 --headless &
echo "CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" >> $GITHUB_ENV
else
echo "Unsupported operating system"
exit 1
fi
# Wait for Chrome to start
sleep 5
- name: Install CodeBeaver
shell: bash
run: |
pip install codebeaver
- name: Install playwright
shell: bash
run: |
playwright install
- name: Run CodeBeaver - Both Tests
if: inputs.action-type == 'both'
shell: bash
run: |
VERBOSE_FLAG=""
if [ "${{ inputs.verbose }}" == "true" ]; then
VERBOSE_FLAG="--verbose"
fi
codebeaver $VERBOSE_FLAG
env:
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
CHROME_INSTANCE_PATH: ${{ env.CHROME_PATH }}
STARTING_URL: ${{ env.STARTING_URL }}
GITHUB_TOKEN: ${{ inputs.github-token || env.GITHUB_TOKEN }}
- name: Run CodeBeaver - Unit Tests
if: inputs.action-type == 'unit'
shell: bash
run: |
VERBOSE_FLAG=""
if [ "${{ inputs.verbose }}" == "true" ]; then
VERBOSE_FLAG="--verbose"
fi
CONFIG_OPTION=""
if [ -n "${{ inputs.config-file }}" ]; then
CONFIG_OPTION="--config ${{ inputs.config-file }}"
fi
MAX_FILES_OPTION=""
if [ -n "${{ inputs.max-files-to-test }}" ]; then
MAX_FILES_OPTION="--max-files-to-test ${{ inputs.max-files-to-test }}"
fi
FILE_OPTION=""
if [ -n "${{ inputs.file-path }}" ]; then
FILE_OPTION="--file ${{ inputs.file-path }}"
fi
codebeaver unit $VERBOSE_FLAG $CONFIG_OPTION $FILE_OPTION $MAX_FILES_OPTION
env:
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
CHROME_INSTANCE_PATH: ${{ env.CHROME_PATH }}
GITHUB_TOKEN: ${{ inputs.github-token || env.GITHUB_TOKEN }}
- name: Run CodeBeaver - E2E Tests
if: inputs.action-type == 'e2e'
shell: bash
run: |
VERBOSE_FLAG=""
if [ "${{ inputs.verbose }}" == "true" ]; then
VERBOSE_FLAG="--verbose"
fi
CONFIG_OPTION=""
if [ -n "${{ inputs.config-file }}" ]; then
CONFIG_OPTION="--config ${{ inputs.config-file }}"
fi
codebeaver e2e $VERBOSE_FLAG $CONFIG_OPTION
env:
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
CHROME_INSTANCE_PATH: ${{ env.CHROME_PATH }}
STARTING_URL: ${{ env.STARTING_URL }}
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
if: inputs.action-type == 'both' || inputs.action-type == 'unit'
with:
commit-message: "test: Update tests with CodeBeaver"
title: "🤖 CodeBeaver: Update Tests"
body: |
This PR was automatically created by CodeBeaver to update tests.
### Changes include:
- Generated/updated unit tests
Please review the changes and merge if everything looks good.
branch: ${{ github.head_ref || github.ref_name }}-codebeaver-tests
base: ${{ github.head_ref || github.ref_name }}
labels: |
automated-pr
tests
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}