Skip to content

Commit

Permalink
playwright github ci action
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Nov 9, 2024
1 parent db7cbd8 commit 8f46b27
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:

jobs:
build:
name: Build Scramjet
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
37 changes: 19 additions & 18 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
}

0 comments on commit 8f46b27

Please sign in to comment.