From b8f44ca2279cc1e4fde0d8d33e80e1c8f2f53efd Mon Sep 17 00:00:00 2001 From: Aaron McAdam Date: Thu, 1 Aug 2024 14:37:07 +0100 Subject: [PATCH] ci: set up pipeline (#2) * ci: set up pipeline * use newer actions * prettier fixes --- .github/workflows/lint.yml | 45 ++++++++++++++++++++++++++++++++ .github/workflows/typescript.yml | 42 +++++++++++++++++++++++++++++ package.json | 6 ++++- pnpm-lock.yaml | 9 +++++++ src/app/globals.css | 2 +- src/components/ui/button.tsx | 26 +++++++++--------- src/lib/utils.ts | 6 ++--- 7 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/typescript.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a96d592 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,45 @@ +name: Lint + +on: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Run lints + run: pnpm lint + + - name: Run prettier + run: pnpm prettier diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml new file mode 100644 index 0000000..80f53b1 --- /dev/null +++ b/.github/workflows/typescript.yml @@ -0,0 +1,42 @@ +name: TypeScript + +on: + pull_request: + +jobs: + typecheck: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v4.0.0 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Check types + run: pnpm typecheck diff --git a/package.json b/package.json index acba050..d8a530e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,10 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "prettier": "prettier --check 'src/**/*.{ts,tsx,js,jsx,html,css}'", + "prettier:fix": "prettier --check --write 'src/**/*.{ts,tsx,js,jsx,html,css}'", + "typecheck": "tsc --noEmit" }, "dependencies": { "@radix-ui/react-slot": "^1.1.0", @@ -26,6 +29,7 @@ "eslint": "^8", "eslint-config-next": "14.2.5", "postcss": "^8", + "prettier": "3.3.3", "tailwindcss": "^3.4.1", "typescript": "^5" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index feee362..c57aef5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,6 +52,9 @@ devDependencies: postcss: specifier: ^8 version: 8.4.40 + prettier: + specifier: 3.3.3 + version: 3.3.3 tailwindcss: specifier: ^3.4.1 version: 3.4.7 @@ -2238,6 +2241,12 @@ packages: engines: {node: '>= 0.8.0'} dev: true + /prettier@3.3.3: + resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} + engines: {node: '>=14'} + hasBin: true + dev: true + /prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} dependencies: diff --git a/src/app/globals.css b/src/app/globals.css index 7958df2..8703dce 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -71,6 +71,6 @@ @layer base { .font-sans { /** Configure Satoshi's alternate "t" to better match TT Norms. */ - font-feature-settings: 'ss03' on; + font-feature-settings: "ss03" on; } } diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 0ba4277..57c9fe4 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", @@ -30,27 +30,27 @@ const buttonVariants = cva( variant: "default", size: "default", }, - } -) + }, +); export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { - asChild?: boolean + asChild?: boolean; } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button" + const Comp = asChild ? Slot : "button"; return ( - ) - } -) -Button.displayName = "Button" + ); + }, +); +Button.displayName = "Button"; -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d084cca..365058c 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,6 @@ -import { type ClassValue, clsx } from "clsx" -import { twMerge } from "tailwind-merge" +import { type ClassValue, clsx } from "clsx"; +import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)) + return twMerge(clsx(inputs)); }