Skip to content

Commit

Permalink
mono
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Ziaei committed Mar 30, 2024
1 parent 8d312c4 commit 0ffd5e0
Show file tree
Hide file tree
Showing 35 changed files with 330 additions and 117 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/deploy.app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: 🚀 Deploy App
on:
workflow_call:

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

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔬 Lint
run: bun lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔎 Type check
run: bun typecheck
working-directory: apps/app

playwright:
name: 🎭 Playwright
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🏄 Copy test env vars
run: cp .env.example .env

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 📥 Install Playwright Browsers
run: bun test:e2e:install
working-directory: apps/app

- name: 🎭 Playwright tests
run: bun test:e2e:run
working-directory: apps/app
env:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
IG_USERNAME: ${{ secrets.IG_USERNAME }}
IG_PASSWORD: ${{ secrets.IG_PASSWORD }}
IG_THREAD_ID: ${{ secrets.IG_THREAD_ID }}

- name: 📊 Upload report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: apps/app/playwright-report/
retention-days: 30

deploy:
name: 🚀 Deploy
runs-on: ubuntu-22.04
needs: [lint, typecheck, playwright]

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy
if: ${{ github.ref == 'refs/heads/main' }}
working-directory: apps/app
run: fly deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
61 changes: 61 additions & 0 deletions .github/workflows/deploy.scheduler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 🚀 Deploy Scheduler
on:
workflow_call:

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

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔬 Lint
run: bun lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔎 Type check
run: bun typecheck
working-directory: apps/scheduler

deploy:
name: 🚀 Deploy
runs-on: ubuntu-22.04
needs: [lint, typecheck]

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🚀 Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: 'apps/scheduler'
101 changes: 16 additions & 85 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,98 +14,29 @@ permissions:
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔬 Lint
run: bun lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-22.04
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 🔎 Type check
run: bun typecheck

playwright:
name: 🎭 Playwright
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🏄 Copy test env vars
run: cp .env.example .env

- name: 🍞 Setup Bun
uses: oven-sh/setup-bun@v1

- name: 📥 Download deps
run: bun install --frozenLockfile

- name: 📥 Install Playwright Browsers
run: bun test:e2e:install

- name: 🎭 Playwright tests
run: bunx playwright test
env:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
IG_USERNAME: ${{ secrets.IG_USERNAME }}
IG_PASSWORD: ${{ secrets.IG_PASSWORD }}
IG_THREAD_ID: ${{ secrets.IG_THREAD_ID }}

- name: 📊 Upload report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

deploy:
name: 🚀 Deploy
runs-on: ubuntu-22.04
needs: [lint, typecheck, playwright]
# only build/deploy branches on pushes
if: ${{ github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy
if: ${{ github.ref == 'refs/heads/main' }}
run:
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: 🧮 Determine Changes
id: changed-files
run: |
echo "::set-output name=changed-files::$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})"
- name: 🚀 Deploy Scheduler
uses: ./.github/workflows/deploy.scheduler.yml
if:
${{ contains(steps.changed-files.outputs.changed-files,
'apps/scheduler/') }}

- name: 🚀 Deploy App
uses: ./.github/workflows/deploy.app.yml
if:
${{ contains(steps.changed-files.outputs.changed-files, 'apps/app/')
}}
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ node_modules
mnt
.env

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/trace
# Playwright
test-results/
playwright-report/
blob-report/
playwright/.cache/
trace
*.zip

# Wrangler
.wrangler
.dev.vars
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@daily-dad-jokes-ig/app",
"private": true,
"type": "module",
"module": "src/entry.ts",
"scripts": {
"dev": "bun --watch .",
"start": "bun .",
"deploy": "fly deploy --remote-only",
"typecheck": "tsc",
"test:e2e:dev": "playwright test --ui",
"test:e2e:run": "cross-env CI=true playwright test",
"test:e2e:install": "npx playwright install --with-deps chromium"
},
"dependencies": {
"@playwright/test": "^1.42.1",
"cheerio": "^1.0.0-rc.12",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
"devDependencies": {
"typescript": "^5.4.3"
}
}
50 changes: 50 additions & 0 deletions apps/app/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var test_1 = require("@playwright/test");
require("dotenv/config");
require("./src/env");
var PORT = process.env.PORT;
exports.default = (0, test_1.defineConfig)({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
locale: 'en-US',
timezoneId: 'Europe/Vilnius',
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
},
projects: [
{ name: 'setup', testMatch: /.*\.setup\.ts/ },
{
name: 'chromium',
use: __assign(__assign({}, test_1.devices['Desktop Chrome']), { storageState: 'mnt/auth.json' }),
dependencies: ['setup'],
},
],
webServer: {
command: 'bun start',
url: "http://localhost:".concat(PORT, "/healthcheck"),
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
env: {
PORT: PORT,
},
},
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions apps/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.base.json",
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
15 changes: 15 additions & 0 deletions apps/scheduler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@daily-dad-jokes-ig/scheduler",
"private": true,
"scripts": {
"dev": "wrangler dev",
"start": "wrangler dev",
"deploy": "wrangler deploy",
"typecheck": "tsc"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240329.0",
"typescript": "^5.4.3",
"wrangler": "^3.0.0"
}
}
Loading

0 comments on commit 0ffd5e0

Please sign in to comment.