diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..709be8f --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,82 @@ +name: test +on: + push: + branches: + - main + paths-ignore: + - README.md + pull_request_target: + types: + - labeled + - unlabeled + branches: + - main + paths-ignore: + - README.md + +jobs: + check-perms: + runs-on: ubuntu-latest + steps: + - name: Get User Permission + id: checkAccess + uses: actions-cool/check-user-permission@v2 + with: + require: write + username: ${{ github.triggering_actor }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check User Permission + if: steps.checkAccess.outputs.require-result == 'false' + run: | + echo "${{ github.triggering_actor }} does not have permissions on this repo." + echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" + echo "Job originally triggered by ${{ github.actor }}" + exit 1 + + test-linux: + needs: check-perms + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-node@v4 + with: + node-version: 21 + - name: Install gptscript + run: | + curl https://get.gptscript.ai/releases/default_linux_amd64_v1/gptscript -o ./gptscriptexe + chmod +x ./gptscriptexe + - name: Install dependencies + run: npm install + - name: Run Tests + env: + GPTSCRIPT_BIN: ./gptscriptexe + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + NODE_GPTSCRIPT_SKIP_INSTALL_BINARY: true + run: npm test + + test-windows: + needs: check-perms + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-node@v4 + with: + node-version: 21 + - name: Install gptscript + run: | + curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe + - name: Install dependencies + run: npm install + - name: Run Tests + env: + GPTSCRIPT_BIN: .\gptscript.exe + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + NODE_GPTSCRIPT_SKIP_INSTALL_BINARY: true + run: npm test