playwright github ci action

This commit is contained in:
Percs 2024-11-09 16:03:17 -06:00
parent db7cbd8982
commit 8f46b276c0
3 changed files with 57 additions and 21 deletions

View file

@ -13,6 +13,7 @@ permissions:
jobs:
build:
name: Build Scramjet
runs-on: ubuntu-latest
steps:
@ -59,11 +60,45 @@ jobs:
path: |
dist/*.js
dist/*.js.map
tests:
name: Run Scramjet Tests
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Get artifacts
uses: actions/download-artifact@v4
with:
name: scramjet
path: dist
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Install dependencies
run: pnpm test
upload:
name: Upload Release
runs-on: ubuntu-latest
needs: build
needs: [build, tests]
permissions: write-all
if: github.ref == 'refs/heads/main'
@ -94,7 +129,7 @@ jobs:
pages:
name: Upload to Github Pages
runs-on: ubuntu-latest
needs: build
needs: [build, tests]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code

View file

@ -8,7 +8,7 @@ export default defineConfig({
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: 2,
reporter: "html",
reporter: process.env.CI ? "github" : "html",
timeout: 20000,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {

View file

@ -85,24 +85,25 @@ fastify.listen({
host: "0.0.0.0",
});
console.log(`Listening on port ${PORT}`);
if (!process.env.CI) {
try {
writeFileSync(
".git/hooks/pre-commit",
"pnpm prettier . -w\ngit update-index --again"
);
chmodSync(".git/hooks/pre-commit", 0o755);
} catch {}
try {
writeFileSync(
".git/hooks/pre-commit",
"pnpm prettier . -w\ngit update-index --again"
);
chmodSync(".git/hooks/pre-commit", 0o755);
} catch {}
const watch = spawn("pnpm", ["rspack", "-w"], {
detached: true,
cwd: process.cwd(),
});
const watch = spawn("pnpm", ["rspack", "-w"], {
detached: true,
cwd: process.cwd(),
});
watch.stdout.on("data", (data) => {
console.log(`${data}`);
});
watch.stdout.on("data", (data) => {
console.log(`${data}`);
});
watch.stderr.on("data", (data) => {
console.log(`${data}`);
});
watch.stderr.on("data", (data) => {
console.log(`${data}`);
});
}