Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 89 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- run:
name: Run Ruff linter and formatter
command: |
ruff check . --fix
ruff format .
ruff check .
ruff format --check .
- run:
name: Run MyPy type checker
command: mypy . || echo "MyPy found issues but continuing"
Expand All @@ -29,27 +29,107 @@ jobs:
steps:
- checkout
- run:
name: Install dependencies
name: Install pnpm
command: sudo npm install -g pnpm
- run:
name: Install root dependencies
command: pnpm install --frozen-lockfile
- run:
name: Install functions dependencies
command: |
sudo npm install -g pnpm
pnpm install --frozen-lockfile
cd functions
npm install
- run:
name: Run linting
command: |
cd functions
npm run lint -- --max-warnings 0
- run:
name: TypeScript type check
name: TypeScript type check (functions)
command: |
cd functions
npx tsc --noEmit
node_modules/.bin/tsc --noEmit
- run:
name: Quality GC check
command: npx quality-gc run || echo "Quality GC issues found"
name: TypeScript type check (root)
command: node_modules/.bin/tsc --noEmit

build-worker:
docker:
- image: cimg/node:20.18
steps:
- checkout
- run:
name: Install pnpm
command: sudo npm install -g pnpm
- run:
name: Install root dependencies
command: pnpm install --frozen-lockfile
- run:
name: Type-check YouTube worker
command: node_modules/.bin/tsc --noEmit --allowJs --skipLibCheck --module ESNext --moduleResolution Bundler --target ES2022 src/youtube-worker.ts || echo "Worker type check done"
- run:
name: Build worker bundle (dry-run)
command: |
node_modules/.bin/esbuild src/youtube-worker.ts \
--bundle \
--platform=browser \
--format=esm \
--outfile=/tmp/youtube-worker-bundle.js \
--external:node:* \
&& echo "Worker bundle built successfully"

deploy-worker:
docker:
- image: cimg/node:20.18
steps:
- checkout
- run:
name: Install pnpm
command: sudo npm install -g pnpm
- run:
name: Install root dependencies
command: pnpm install --frozen-lockfile
- run:
name: Deploy YouTube Worker to Cloudflare
command: |
node_modules/.bin/wrangler deploy src/youtube-worker.ts \
--name ytstudio \
--compatibility-date 2025-01-01 \
--compatibility-flags nodejs_compat
environment:
CLOUDFLARE_API_TOKEN: $CLOUDFLARE_API_TOKEN
CLOUDFLARE_ACCOUNT_ID: $CLOUDFLARE_ACCOUNT_ID

workflows:
version: 2

validate:
jobs:
- python-checks
- node-checks
- build-worker:
requires:
- node-checks

deploy:
jobs:
- python-checks:
filters:
branches:
only: main
- node-checks:
filters:
branches:
only: main
- build-worker:
requires:
- node-checks
filters:
branches:
only: main
- deploy-worker:
requires:
- build-worker
filters:
branches:
only: main
Binary file added .coverage
Binary file not shown.
4 changes: 2 additions & 2 deletions app/wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "<WORKER_NAME>",
"name": "yt-studio-worker",
"main": "src/index.ts",
"compatibility_date": "<COMPATIBILITY_DATE>",
"compatibility_date": "2025-01-01",
"observability": {
"enabled": true,
},
Expand Down
17 changes: 10 additions & 7 deletions fix_app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import sys
from pathlib import Path

filepath = 'js/app.js'
with open(filepath, 'r') as f:
filepath = Path("js/app.js")
with filepath.open() as f:
lines = f.readlines()

# Part 1: DOM elements
for i, line in enumerate(lines):
if "themeMenu: document.getElementById('themeMenu')," in line:
lines.insert(i + 1, " episodesNavBtn: document.querySelector('[data-action=\"scroll-to-episodes\"]'),\n")
lines.insert(
i + 1,
" episodesNavBtn: document.querySelector('[data-action=\"scroll-to-episodes\"]'),\n",
)
lines.insert(i + 2, " episodesSection: document.getElementById('episodesSection'),\n")
break

Expand All @@ -20,16 +23,16 @@
" DOM.episodesNavBtn.addEventListener('click', () => {\n",
" DOM.episodesSection.scrollIntoView({ behavior: 'smooth' });\n",
" if (document.body.classList.contains('mobile-nav-active')) {\n",
" document.body.classList.remove('mobile-nav-active');\n",
" document.body.classList.remove('mobile-nav-active');\n",
" if (DOM.menuToggle) DOM.menuToggle.setAttribute('aria-expanded', 'false');\n",
" }\n",
" });\n",
" }\n",
"\n"
"\n",
]
for idx, new_line in enumerate(scroll_listener):
lines.insert(i + idx, new_line)
break

with open(filepath, 'w') as f:
with filepath.open("w") as f:
f.writelines(lines)
10 changes: 5 additions & 5 deletions fix_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# Maybe the CI is running against a different state of the PR?

# Let's just make sure trigger-circleci-pipeline and circletui are in package.json if they are in the lockfile.
if 'dependencies' not in pkg:
pkg['dependencies'] = {}
if "dependencies" not in pkg:
pkg["dependencies"] = {}

pkg['dependencies']['trigger-circleci-pipeline'] = '^1.12.1'
pkg['dependencies']['circletui'] = '^1.0.3'
pkg['dependencies']['@circleci/circleci-config-sdk'] = '^0.12.5'
pkg["dependencies"]["trigger-circleci-pipeline"] = "^1.12.1"
pkg["dependencies"]["circletui"] = "^1.0.3"
pkg["dependencies"]["@circleci/circleci-config-sdk"] = "^0.12.5"

with Path("package.json").open("w") as f:
json.dump(pkg, f, indent=2)
Expand Down
11 changes: 7 additions & 4 deletions fix_index.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
with open('index.html', 'r') as f:
from pathlib import Path

index_path = Path("index.html")
with index_path.open() as f:
content = f.read()

# Add title attribute to search button
old_search = '<button class=\"nav-link\" id=\"searchToggleBtn\" aria-controls=\"searchSection\" aria-expanded=\"false\">'
new_search = '<button class=\"nav-link\" id=\"searchToggleBtn\" aria-controls=\"searchSection\" aria-expanded=\"false\" title=\"Search (/)\">'
old_search = '<button class="nav-link" id="searchToggleBtn" aria-controls="searchSection" aria-expanded="false">'
new_search = '<button class="nav-link" id="searchToggleBtn" aria-controls="searchSection" aria-expanded="false" title="Search (/)">'
content = content.replace(old_search, new_search)

with open('index.html', 'w') as f:
with index_path.open("w") as f:
f.write(content)
28 changes: 27 additions & 1 deletion functions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
module.exports={root:!0,env:{es6:!0,node:!0},extends:["eslint:recommended","plugin:import/errors","plugin:import/warnings","plugin:import/typescript","google","plugin:@typescript-eslint/recommended"],parser:"@typescript-eslint/parser",parserOptions:{project:["tsconfig.json","tsconfig.dev.json"],sourceType:"module"},ignorePatterns:["/lib/**/*","/generated/**/*"],plugins:["@typescript-eslint","import"],rules:{quotes:["error","double"],"import/no-unresolved":0,indent:["error",2]}};
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: ["/lib/**/*", "/generated/**/*"],
plugins: ["@typescript-eslint", "import"],
rules: {
"quotes": ["error", "double"],
"import/no-unresolved": 0,
"indent": ["error", 2],
},
};
Loading
Loading