Skip to content

Commit 872acc1

Browse files
committed
chore: go a little bold, create reusable workflow for tests to avoid getting too complicated with conditional logic
Signed-off-by: Taylor Price <[email protected]>
1 parent 2836f66 commit 872acc1

File tree

4 files changed

+116
-83
lines changed

4 files changed

+116
-83
lines changed

.github/workflows/pull_request.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Pull Request
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
- synchronize
7+
- reopened
8+
- labeled
9+
branches:
10+
- main
11+
paths-ignore:
12+
- README.md
13+
14+
jobs:
15+
check-perms:
16+
if: ${{ !github.event.pull_request.merged }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Get User Permission
20+
id: checkAccess
21+
uses: actions-cool/check-user-permission@v2
22+
with:
23+
require: write
24+
username: ${{ github.triggering_actor }}
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Check User Permission
28+
if: steps.checkAccess.outputs.require-result == 'false'
29+
run: |
30+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
31+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
32+
echo "Job originally triggered by ${{ github.actor }}"
33+
exit 1
34+
run-tests:
35+
uses: gptscript-ai/go-gptscript/.github/workflows/run_tests.yaml@main
36+
needs: check-perms
37+
with:
38+
git_ref: ${{ github.event.pull_request.head.sha }}
39+
secrets:
40+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+

.github/workflows/push_main.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Push Main
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- README.md
8+
9+
jobs:
10+
run-tests:
11+
uses: gptscript-ai/go-gptscript/.github/workflows/run_tests.yaml@main
12+
with:
13+
git_ref: ''
14+
secrets:
15+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+

.github/workflows/run_tests.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
git_ref:
7+
required: true
8+
type: string
9+
secrets:
10+
OPENAI_API_KEY:
11+
required: true
12+
GITHUB_TOKEN:
13+
required: true
14+
15+
jobs:
16+
test-linux:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
ref: ${{ inputs.git_ref }}
23+
- uses: actions/setup-go@v5
24+
with:
25+
cache: false
26+
go-version: "1.22"
27+
- name: Validate
28+
run: make validate
29+
- name: Install gptscript
30+
run: |
31+
curl https://get.gptscript.ai/releases/default_linux_amd64_v1/gptscript -o ./gptscriptexe
32+
chmod +x ./gptscriptexe
33+
- name: Run Tests
34+
env:
35+
GPTSCRIPT_BIN: ./gptscriptexe
36+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
37+
run: make test
38+
39+
test-windows:
40+
runs-on: windows-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 1
45+
ref: ${{ inputs.git_ref }}
46+
- uses: actions/setup-go@v5
47+
with:
48+
cache: false
49+
go-version: "1.22"
50+
- name: Install gptscript
51+
run: |
52+
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
53+
- name: Run Tests
54+
env:
55+
GPTSCRIPT_BIN: .\gptscript.exe
56+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
57+
run: make test

.github/workflows/test.yaml

-83
This file was deleted.

0 commit comments

Comments
 (0)