diff --git a/docs/fork-pr-testing.md b/docs/fork-pr-testing.md new file mode 100644 index 0000000..90448ba --- /dev/null +++ b/docs/fork-pr-testing.md @@ -0,0 +1,32 @@ +# Fork PR Testing Guide + +This document explains how testing works for external pull requests from forks. + +## Overview + +The testing system consists of two main workflows: + +1. **E2E Tests** (`test-e2e.yml`) - Runs automatically for internal PRs, need manual trigger on external PRs. +2. **Ok To Test** (`ok-to-test.yml`) - Dispatches `repository_dispatch` event when maintainer puts the `/ok-to-test sha=` comment in the forked PR thread. + +## How It Works + +### 1. PR is created by maintainer: + +For the PR created by maintainer `E2E Test` workflow starts automatically. The PR check will reflect the status of the job. + +### 2. PR is created by external contributor: + +For the PR created by external contributor `E2E Test` workflow **won't** start automatically. +Maintainer should make a sanity check of the changes and run it manually by: +1. Putting a comment `/ok-to-test sha=` in the PR thread. +2. `E2E Test` workflow starts. +3. After `E2E Test` workflow finishes, a comment with a link to the workflow, along with its status will be posted in the PR. +4. Maintainer can merge PR or request the changes based on the `E2E Test` results. + + +## Notes + +- Only users with **write** permissions can trigger the `/ok-to-test` command. +- External PRs are automatically detected and prevented from running e2e tests automatically. +- Running e2e test on the external PR is optional. Maintainer can merge PR without running it. Maintainer decides whether it's needed to run an E2E test. diff --git a/docs/local-testing.md b/docs/local-testing.md new file mode 100644 index 0000000..21f76df --- /dev/null +++ b/docs/local-testing.md @@ -0,0 +1,46 @@ +# Local Testing Guide + +This document explains how to run e2e tests locally using `act`. + +## Prerequisites + +1. **Docker** installed and running +2. **act** installed ([install guide](https://github.com/nektos/act#installation)) + ```bash + brew install act # macOS + ``` +3. **1Password credentials** (see [Required Secrets](#required-secrets)) +4. Build action + +## Required env variables + +| Secret | Description | +| -------------------------- | --------------------- | +| `OP_SERVICE_ACCOUNT_TOKEN` | Service Account token | +| `VAULT` | Vault name or UUID | + +## Building Before Testing + +If you've modified TypeScript code, rebuild before running E2E tests: + +```bash +npm run build +``` + +## Testing + +### Run E2E tests using Service Account + +```bash +act push -W .github/workflows/e2e-tests.yml \ + -s OP_SERVICE_ACCOUNT_TOKEN="$OP_SERVICE_ACCOUNT_TOKEN" \ + -s VAULT="$VAULT" \ + -j test-service-account \ + --matrix os:ubuntu-latest +``` + +## Run unit tests + +```bash +npm test +```