Skip to content

Commit fe566fd

Browse files
authored
Merge pull request #13 from thedadams/add-test-ci
chore: add test CI for merges and PRs
2 parents d0541eb + 5810c4e commit fe566fd

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

.github/workflows/test.yaml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- README.md
8+
pull_request_target:
9+
types:
10+
- labeled
11+
- unlabeled
12+
branches:
13+
- main
14+
paths-ignore:
15+
- README.md
16+
17+
jobs:
18+
check-perms:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Get User Permission
22+
id: checkAccess
23+
uses: actions-cool/check-user-permission@v2
24+
with:
25+
require: write
26+
username: ${{ github.triggering_actor }}
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Check User Permission
30+
if: steps.checkAccess.outputs.require-result == 'false'
31+
run: |
32+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
33+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
34+
echo "Job originally triggered by ${{ github.actor }}"
35+
exit 1
36+
37+
test-linux:
38+
needs: check-perms
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 1
44+
ref: ${{ github.event.pull_request.head.sha }}
45+
- uses: actions/setup-python@v5
46+
with:
47+
python-version: "3.10"
48+
- name: Install gptscript
49+
run: |
50+
curl https://get.gptscript.ai/releases/default_linux_amd64_v1/gptscript -o gptscriptexe
51+
chmod +x ./gptscriptexe
52+
- name: Install deps
53+
run: |
54+
pip install -r requirements.txt
55+
- name: Run Tests
56+
env:
57+
GPTSCRIPT_BIN: ../gptscriptexe
58+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
59+
run: ./scripts/test
60+
61+
test-windows:
62+
needs: check-perms
63+
runs-on: windows-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 1
68+
ref: ${{ github.event.pull_request.head.sha }}
69+
- uses: actions/setup-python@v5
70+
with:
71+
python-version: "3.10"
72+
- name: Install gptscript
73+
run: |
74+
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
75+
- name: Install deps
76+
run: |
77+
pip install -r requirements.txt
78+
- name: Run Tests
79+
env:
80+
GPTSCRIPT_BIN: ..\gptscript.exe
81+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
82+
run: ./scripts/test

scripts/package

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ suffixes = {
3434
"windows": "zip",
3535
}
3636

37+
3738
def wheel_platform_tag(platform, arch):
3839
py_arch= {
3940
"universal": "universal2",
@@ -126,6 +127,7 @@ def build_wheel_for_platform(output_dir):
126127
# Cleanup environment variables
127128
del os.environ["PLAT"]
128129

130+
129131
def file_hash_and_size(file_path):
130132
"""Compute the SHA256 hash and size of a file."""
131133
sha256 = hashlib.sha256()
@@ -139,6 +141,7 @@ def file_hash_and_size(file_path):
139141
size += len(data)
140142
return sha256.hexdigest(), f"{size}"
141143

144+
142145
def modify_and_repackage_wheel(wheel_path, binary_dir, platform, arch):
143146
with TemporaryDirectory() as temp_dir:
144147
temp_dir_path = Path(temp_dir)

tests/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ envlist = py3
44
[testenv]
55
deps = pytest
66
-e ../
7-
passenv = OPENAI_API_KEY
7+
passenv = OPENAI_API_KEY, GPTSCRIPT_BIN
88
commands =
99
install_gptscript
1010
pytest

0 commit comments

Comments
 (0)