From 52cf05b9920308e95fa7a21be8898fe0868c6704 Mon Sep 17 00:00:00 2001 From: Jaleel Bennett Date: Thu, 22 Aug 2024 22:33:43 -0400 Subject: [PATCH] cicd(workflow): added deploy step and conditional steps for each job --- .github/workflows/{cc.yml => ci.yml} | 40 ++++++++- components/ui/select.tsx | 58 ++++++------ components/ui/switch.tsx | 18 ++-- components/ui/tooltip.tsx | 22 ++--- tests/parser.test.ts | 126 --------------------------- 5 files changed, 86 insertions(+), 178 deletions(-) rename .github/workflows/{cc.yml => ci.yml} (79%) delete mode 100644 tests/parser.test.ts diff --git a/.github/workflows/cc.yml b/.github/workflows/ci.yml similarity index 79% rename from .github/workflows/cc.yml rename to .github/workflows/ci.yml index 0143828..ec6c6bf 100644 --- a/.github/workflows/cc.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,4 @@ -name: Code check - +name: CI on: pull_request: branches: ["*"] @@ -44,6 +43,7 @@ jobs: - run: pnpm lint format: + needs: lint runs-on: ubuntu-latest name: Format steps: @@ -79,9 +79,10 @@ jobs: - name: Install dependencies run: pnpm install - - run: pnpm format:check + - run: pnpm format:write tsc: + needs: format runs-on: ubuntu-latest name: Typecheck steps: @@ -105,6 +106,7 @@ jobs: id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 name: Setup pnpm cache with: @@ -112,7 +114,39 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- + - name: Install dependencies run: pnpm install - run: pnpm typecheck + + deploy: + needs: tsc + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v3.0.0 + name: Install pnpm + id: pnpm-install + with: + version: 8.6.1 + run_install: false + + - name: Install packages + run: pnpm install --frozen-lockfile + + - name: Install Railway + run: pnpm add -g @railway/cli + + - name: Deploy + run: railway up + env: + RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} diff --git a/components/ui/select.tsx b/components/ui/select.tsx index cbe5a36..9218f68 100644 --- a/components/ui/select.tsx +++ b/components/ui/select.tsx @@ -1,16 +1,16 @@ -"use client" +"use client"; -import * as React from "react" -import * as SelectPrimitive from "@radix-ui/react-select" -import { Check, ChevronDown, ChevronUp } from "lucide-react" +import * as React from "react"; +import * as SelectPrimitive from "@radix-ui/react-select"; +import { Check, ChevronDown, ChevronUp } from "lucide-react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const Select = SelectPrimitive.Root +const Select = SelectPrimitive.Root; -const SelectGroup = SelectPrimitive.Group +const SelectGroup = SelectPrimitive.Group; -const SelectValue = SelectPrimitive.Value +const SelectValue = SelectPrimitive.Value; const SelectTrigger = React.forwardRef< React.ElementRef, @@ -20,7 +20,7 @@ const SelectTrigger = React.forwardRef< ref={ref} className={cn( "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", - className + className, )} {...props} > @@ -29,8 +29,8 @@ const SelectTrigger = React.forwardRef< -)) -SelectTrigger.displayName = SelectPrimitive.Trigger.displayName +)); +SelectTrigger.displayName = SelectPrimitive.Trigger.displayName; const SelectScrollUpButton = React.forwardRef< React.ElementRef, @@ -40,14 +40,14 @@ const SelectScrollUpButton = React.forwardRef< ref={ref} className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > -)) -SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName +)); +SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName; const SelectScrollDownButton = React.forwardRef< React.ElementRef, @@ -57,15 +57,15 @@ const SelectScrollDownButton = React.forwardRef< ref={ref} className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > -)) +)); SelectScrollDownButton.displayName = - SelectPrimitive.ScrollDownButton.displayName + SelectPrimitive.ScrollDownButton.displayName; const SelectContent = React.forwardRef< React.ElementRef, @@ -78,7 +78,7 @@ const SelectContent = React.forwardRef< "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", - className + className, )} position={position} {...props} @@ -88,7 +88,7 @@ const SelectContent = React.forwardRef< className={cn( "p-1", position === "popper" && - "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]" + "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]", )} > {children} @@ -96,8 +96,8 @@ const SelectContent = React.forwardRef< -)) -SelectContent.displayName = SelectPrimitive.Content.displayName +)); +SelectContent.displayName = SelectPrimitive.Content.displayName; const SelectLabel = React.forwardRef< React.ElementRef, @@ -108,8 +108,8 @@ const SelectLabel = React.forwardRef< className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)} {...props} /> -)) -SelectLabel.displayName = SelectPrimitive.Label.displayName +)); +SelectLabel.displayName = SelectPrimitive.Label.displayName; const SelectItem = React.forwardRef< React.ElementRef, @@ -119,7 +119,7 @@ const SelectItem = React.forwardRef< ref={ref} className={cn( "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", - className + className, )} {...props} > @@ -131,8 +131,8 @@ const SelectItem = React.forwardRef< {children} -)) -SelectItem.displayName = SelectPrimitive.Item.displayName +)); +SelectItem.displayName = SelectPrimitive.Item.displayName; const SelectSeparator = React.forwardRef< React.ElementRef, @@ -143,8 +143,8 @@ const SelectSeparator = React.forwardRef< className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} /> -)) -SelectSeparator.displayName = SelectPrimitive.Separator.displayName +)); +SelectSeparator.displayName = SelectPrimitive.Separator.displayName; export { Select, @@ -157,4 +157,4 @@ export { SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, -} +}; diff --git a/components/ui/switch.tsx b/components/ui/switch.tsx index bc69cf2..b73edee 100644 --- a/components/ui/switch.tsx +++ b/components/ui/switch.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; -import * as React from "react" -import * as SwitchPrimitives from "@radix-ui/react-switch" +import * as React from "react"; +import * as SwitchPrimitives from "@radix-ui/react-switch"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Switch = React.forwardRef< React.ElementRef, @@ -12,18 +12,18 @@ const Switch = React.forwardRef< -)) -Switch.displayName = SwitchPrimitives.Root.displayName +)); +Switch.displayName = SwitchPrimitives.Root.displayName; -export { Switch } +export { Switch }; diff --git a/components/ui/tooltip.tsx b/components/ui/tooltip.tsx index 30fc44d..2c42a2c 100644 --- a/components/ui/tooltip.tsx +++ b/components/ui/tooltip.tsx @@ -1,15 +1,15 @@ -"use client" +"use client"; -import * as React from "react" -import * as TooltipPrimitive from "@radix-ui/react-tooltip" +import * as React from "react"; +import * as TooltipPrimitive from "@radix-ui/react-tooltip"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const TooltipProvider = TooltipPrimitive.Provider +const TooltipProvider = TooltipPrimitive.Provider; -const Tooltip = TooltipPrimitive.Root +const Tooltip = TooltipPrimitive.Root; -const TooltipTrigger = TooltipPrimitive.Trigger +const TooltipTrigger = TooltipPrimitive.Trigger; const TooltipContent = React.forwardRef< React.ElementRef, @@ -20,11 +20,11 @@ const TooltipContent = React.forwardRef< sideOffset={sideOffset} className={cn( "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", - className + className, )} {...props} /> -)) -TooltipContent.displayName = TooltipPrimitive.Content.displayName +)); +TooltipContent.displayName = TooltipPrimitive.Content.displayName; -export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } +export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }; diff --git a/tests/parser.test.ts b/tests/parser.test.ts deleted file mode 100644 index 8157537..0000000 --- a/tests/parser.test.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { MediumArticleProcessor } from "../lib/parser"; -import { describe, it, expect } from "vitest"; - -describe("MediumArticleProcessor", () => { - const processor = new MediumArticleProcessor(); - - describe("processArticle", () => { - it("should process a simple article with correct classes and attributes", () => { - const simpleHtml = ` -
-

Test Header

-

This is a test paragraph.

-
- `; - const result = processor.processArticleContent(simpleHtml); - expect(result).toContain( - '

Test Header

', - ); - expect(result).toContain( - '

This is a test paragraph.

', - ); - }); - - it("should handle various paragraph types with correct attributes", () => { - const complexHtml = ` -
-

Main Header

-

Sub Header

-

Normal paragraph

-
  • List item
-
  1. Ordered list item
-
Code block
-
Blockquote
-
Test image
-
- `; - const result = processor.processArticleContent(complexHtml); - expect(result).toContain( - '

Main Header

', - ); - expect(result).toContain( - '

Sub Header

', - ); - expect(result).toContain( - '

Normal paragraph

', - ); - expect(result).toContain( - '
  • List item
', - ); - expect(result).toContain( - '
  1. Ordered list item
', - ); - expect(result).toContain( - '
Code block
', - ); - expect(result).toContain( - '

Blockquote

', - ); - expect(result).toContain( - '
Test image
', - ); - }); - - it("should handle text markups with correct tags and attributes", () => { - const markupHtml = ` -
-

This is bold and italic text with a link.

-
- `; - const result = processor.processArticleContent(markupHtml); - expect(result).toContain("bold"); - expect(result).toContain("italic"); - expect(result).toContain( - 'link', - ); - }); - - it("should handle empty sections", () => { - const emptyHtml = "
"; - const result = processor.processArticleContent(emptyHtml); - expect(result).toBe(""); - }); - - // it("should handle mixtape embeds with correct structure and classes", () => { - // const mixtapeHtml = ` - //
- // - //
- // `; - // const result = processor.processArticle(mixtapeHtml); - // expect(result).toContain( - // '