Running and Testing GitHub Actions Locally and in CI
Question: Run github actions locally
You can run GitHub Actions locally using the act
tool. This helps test workflows before pushing to GitHub.
Steps:
- Install act:
brew install act
- Run your actions:
act
- Simulate different events:
act push act pull_request
Tips:
- Docker is required.
- Use
--platform
if needed.
Question: Set github actions with bun
Bun can be used as the runtime in your GitHub Actions workflow by configuring the action to use a setup step like:
- uses: oven-sh/setup-bun@v1
with:
bun-version: "latest"
Tips:
- Replace
node
scripts withbun
commands for compatibility.
Question: Whats the best way to run e2e test of a webapp in github actions
Use a headless browser like Chrome and a test runner like Puppeteer or Playwright.
Sample GitHub Action step:
- name: Run e2e tests
run: bun test:e2e
Tips:
- Install dependencies before testing.
- Ensure the server is running or mocked.
Question: Give me for puppeteer
To run Puppeteer tests:
-
Install Puppeteer:
bun add puppeteer
-
Create a test:
const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto("http://localhost:3000");
-
Run in CI with
xvfb
or headless mode.
Tips:
- Set
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
to speed up CI builds.