diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..2cb2036d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + pull_request: + branches: ["main"] + push: + branches: ["main"] + +jobs: + lint-and-build: + name: Lint, Type Check, and Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Check formatting (non-blocking) + run: npm run format + continue-on-error: true + + - name: Type check + run: npm run typecheck + + - name: Astro check + run: npm run check + + - name: Build + run: npm run build + diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 000000000..9075af860 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,6 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +# Run lint-staged for staged files +npx --no-install lint-staged + diff --git a/Readme.md b/Readme.md index 9e72452e0..127963983 100644 --- a/Readme.md +++ b/Readme.md @@ -55,6 +55,17 @@ To run the repository locally and explore the website on your machine, follow th 5. **Open Your Browser:** Visit [http://localhost:4321](http://localhost:4321) to view the Akash Network website locally. +### Developer Scripts + +The following scripts are available for development and quality checks: + +- **`npm run check`** - Run Astro type and content checks +- **`npm run typecheck`** - Run TypeScript type checking (no emit) +- **`npm run format`** - Check code formatting with Prettier +- **`npm run format:write`** - Format code with Prettier (writes changes) + +These scripts are also run automatically in CI on pull requests and pushes to main. + ## Contribution Guidelines Before contributing to the project, please adhere to the following guidelines to ensure the project's integrity and maintainability. @@ -123,6 +134,19 @@ Each commit message should carry a meaningful structure, commencing with a type - Utilize the imperative mood (e.g., "add," "fix," "update") in the description. - Provide context in the description when necessary.. +### Developer Scripts + +Run local checks and formatting: + +```bash +npm run check # Astro type and content validation +npm run typecheck # TypeScript type checks (no emit) +npm run format # Prettier format check (read-only) +npm run format:write # Prettier format and fix files +``` + +These scripts are automatically run in CI on pull requests. Always run `npm run format:write` before committing to ensure consistent code style. + ### How to Contribute to the Akash Website ## How to write a blog diff --git a/astro.config.mjs b/astro.config.mjs index 67288fc13..7145b5ae1 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -18,9 +18,7 @@ export default defineConfig({ }, integrations: [ tailwind(), - sitemap({ - lastmod: new Date("2024-06-27"), - }), + sitemap(), react(), astroExpressiveCode({ themes: ["light-plus", "dark-plus"], diff --git a/package.json b/package.json index 3bdf76acb..ab32f836f 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,16 @@ "start": "astro dev", "build": "astro build", "preview": "astro preview", - "astro": "astro" + "astro": "astro", + "check": "astro check", + "typecheck": "tsc --noEmit", + "format": "prettier --check .", + "format:write": "prettier --write .", + "prepare": "husky" }, "dependencies": { "@astrojs/check": "^0.9.4", "@astrojs/mdx": "^2.0.2", - "@astrojs/partytown": "^2.0.4", "@astrojs/react": "^3.0.8", "@astrojs/rss": "^4.0.11", "@astrojs/sitemap": "^3.1.4", @@ -42,12 +46,8 @@ "@tailwindcss/typography": "^0.5.10", "@tanstack/react-query": "^4.29.7", "@tanstack/react-query-devtools": "^4.32.6", - "@types/lodash": "^4.17.7", - "@types/react": "^18.0.21", - "@types/react-dom": "^18.0.6", "astro": "^4.0.7", "astro-expressive-code": "^0.30.1", - "astro-robots-txt": "^1.0.0", "axios": "^1.6.0", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", @@ -82,9 +82,17 @@ "zustand": "^4.5.2" }, "devDependencies": { + "husky": "^9.1.6", + "lint-staged": "^15.2.7", + "@types/lodash": "^4.17.7", + "@types/react": "^18.0.21", + "@types/react-dom": "^18.0.6", "@types/react-simple-maps": "^3.0.4", "prettier": "^3.0.3", "prettier-plugin-astro": "^0.12.0", "prettier-plugin-tailwindcss": "^0.5.4" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx,astro,css,md,mdx,json,yml,yaml}": "prettier --write" } }