Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Initial release of smoke/integration tests + testing framework #993

Merged
merged 14 commits into from
Dec 12, 2024
55 changes: 55 additions & 0 deletions .github/workflows/integrationTests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: integration-test
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
smoke-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 9.4.0

- uses: actions/setup-node@v4
with:
node-version: "23"
cache: "pnpm"

- name: Run smoke tests
run: pnpm run smokeTests
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 9.4.0

- uses: actions/setup-node@v4
with:
node-version: "23"
cache: "pnpm"

- name: Install dependencies
run: pnpm install -r

- name: Build packages
run: pnpm build

- name: Run integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub does not allow this secret to be accessible for github action runs from forked repos.

See: pull_request_target:

as well as github's blog post: https://github.blog/news-insights/product-news/github-actions-improvements-for-fork-and-pull-request-workflows/

there are some security concerns with allowing secrets to be added to runtime envs of github actions triggered by pull requests: https://nathandavison.com/blog/github-actions-and-the-threat-of-malicious-pull-requests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub does not allow this secret to be accessible for github action runs from forked repos.

Yes, that's expected and also desired - normally you would not want people who clone your repository to get access to your secrets. This means that each repository / fork owner is responsible for setting up their own secrets.

there are some security concerns with allowing secrets to be added to runtime envs of github actions triggered by pull requests: https://nathandavison.com/blog/github-actions-and-the-threat-of-malicious-pull-requests

Yes, this was also mentioned in the "risks" above. A malicious PR (or even branch) might be set up to reveal the secret, and there is no way around it. This means that probably (a) untrusted contributors should not be able to run workflows (already implemented), (b) every PR should be reviewed before running workflows (common sense anyway), and (c) there should be some limitations on API keys such as quota and regular rotation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub does not allow this secret to be accessible for github action runs from forked repos.

Yes, that's expected and also desired - normally you would not want people who clone your repository to get access to your secrets. This means that each repository / fork owner is responsible for setting up their own secrets.

there are some security concerns with allowing secrets to be added to runtime envs of github actions triggered by pull requests: https://nathandavison.com/blog/github-actions-and-the-threat-of-malicious-pull-requests

Yes, this was also mentioned in the "risks" above. A malicious PR (or even branch) might be set up to reveal the secret, and there is no way around it. This means that probably (a) untrusted contributors should not be able to run workflows (already implemented), (b) every PR should be reviewed before running workflows (common sense anyway), and (c) there should be some limitations on API keys such as quota and regular rotation.

I don't see an easy way to reveal the secret that will be added specifically for ai16z workflow runs. Github CI hides it with *** when you echo it. Other than that, @jzvikart made valid concerns.

run: |
if [ -z "$OPENAI_API_KEY" ]; then
echo "Skipping integration tests due to missing required API keys"
exit 1
else
pnpm run integrationTests
fi
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"docker:bash": "bash ./scripts/docker.sh bash",
"docker:start": "bash ./scripts/docker.sh start",
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash",
"test": "bash ./scripts/test.sh"
"test": "bash ./scripts/test.sh",
"smokeTests": "bash ./scripts/smokeTests.sh",
"integrationTests": "bash ./scripts/integrationTests.sh"
},
"devDependencies": {
"@commitlint/cli": "18.6.1",
Expand All @@ -38,7 +40,8 @@
"typedoc": "0.26.11",
"typescript": "5.6.3",
"vite": "5.4.11",
"vitest": "2.1.5"
"vitest": "2.1.5",
"zx": "^8.2.4"
},
"pnpm": {
"overrides": {
Expand Down
Loading
Loading