Skip to content

Commit

Permalink
chore: set up smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbifulco committed May 26, 2024
1 parent a04b71d commit f4e7102
Show file tree
Hide file tree
Showing 9 changed files with 5,343 additions and 3,938 deletions.
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SITE_URL=https://mikebifulco.com

# Find this at https://cloudinary.com/console/settings/account
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=mikebifulco-com

CONVERTKIT_API_SECRET=abc123

# fathom analytics
NEXT_PUBLIC_FATHOM_ID=PAVJGIYJ

# posthog
NEXT_PUBLIC_POSTHOG_KEY=test

# transistor
TRANSISTOR_API_KEY=test

RESEND_API_KEY=test
RESEND_NEWSLETTER_AUDIENCE_ID=test
17 changes: 0 additions & 17 deletions .github/workflows/auto-approve.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/build-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build & Lint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
changes:
name: Determine deployable changes
runs-on: ubuntu-latest
outputs:
DEPLOYABLE: ${{steps.changes.outputs.DEPLOYABLE}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: '50'

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Determine deployable changes
id: changes
run: >-
echo ::set-output name=DEPLOYABLE::$(node ./other/is-deployable.js ${{
github.sha }})
- name: Deployable
run: >-
echo "DEPLOYABLE: ${{steps.changes.outputs.DEPLOYABLE}}"
lint:
name: ESLint
needs: [changes]
if: needs.changes.outputs.DEPLOYABLE == 'true'
runs-on: ubuntu-latest
steps:
- name: ⬇Checkout repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Download deps
uses: bahmutov/npm-install@v1

- name: Lint
run: pnpm run lint

typecheck:
name: TypeScript
needs: [changes]
if: needs.changes.outputs.DEPLOYABLE == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Download deps
uses: bahmutov/npm-install@v1

- name: Type check
run: pnpm run typecheck

playwright:
name: Playwright
needs: [changes]
if: needs.changes.outputs.DEPLOYABLE == 'true'
runs-on: ubuntu-latest
timeout-minutes: 60
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: pnpm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,7 @@ $RECYCLE.BIN/

# turborepo
.turbo
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dev": "NODE_OPTIONS='--inspect' next dev --turbo",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "next start",
"test": "pnpm exec playwright test",
"lint": "next lint",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check"
},
Expand Down Expand Up @@ -65,7 +66,9 @@
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
"@next/eslint-plugin-next": "^14.2.2",
"@playwright/test": "^1.44.1",
"@types/eslint": "^8.56.10",
"@types/node": "^20.12.12",
"@types/pluralize": "^0.0.33",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.7.1",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 7'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm build && pnpm start',
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI,
},
});
Loading

0 comments on commit f4e7102

Please sign in to comment.