From 7e567e07238f04c6162700c2579be6c77e6ae043 Mon Sep 17 00:00:00 2001 From: YimingIsCOLD Date: Thu, 29 May 2025 07:57:56 +0800 Subject: [PATCH 1/3] ci: setup GitHub Actions to format, lint and test --- .github/workflows/ci.yaml | 116 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..20d9cf8c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,116 @@ +name: CI + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: ['main'] + paths-ignore: + - .gitignore + - LICENSE + - README.md + pull_request: + branches: ['*'] + paths-ignore: + - .gitignore + - LICENSE + - README.md + +jobs: + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PNPM + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Format + run: pnpm format + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PNPM + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Lint + run: pnpm lint + + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PNPM + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Check + run: pnpm -r check + + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PNPM + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Test + run: pnpm -r test From 6908f4b5e615fbc7d9ff150efe4bf905f3ec2f56 Mon Sep 17 00:00:00 2001 From: YimingIsCOLD Date: Fri, 30 May 2025 04:30:48 +0800 Subject: [PATCH 2/3] chore: rename `bootstrap.sh` to `setup.sh` --- README.md | 7 ++++--- apps/learner/Dockerfile | 2 +- package.json | 1 + bootstrap.sh => setup.sh | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) rename bootstrap.sh => setup.sh (80%) diff --git a/README.md b/README.md index f673ce1e..0443e428 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ brew install pnpm pnpm install ``` -3. Bootstrap the project: +3. Sets up the project: ```sh -./bootstrap.sh +./setup.sh ``` 4. Start local services: @@ -44,6 +44,7 @@ All commands are run from the root of the project, from a terminal: | :------------------- | :-------------------------------- | | `pnpm learner:dev` | Starts the `learner` dev server | | `pnpm learner:build` | Builds the `learner` application | -| `pnpm auth:build` | Builds the `@onward/auth` library | +| `pnpm auth:build` | Builds the `@onward/auth` package | +| `pnpm bootstrap` | Builds all internal dependencies | | `pnpm format` | Format the entrie codebase | | `pnpm lint` | Lint the entire codebase | diff --git a/apps/learner/Dockerfile b/apps/learner/Dockerfile index 0c711c54..5b3fd302 100644 --- a/apps/learner/Dockerfile +++ b/apps/learner/Dockerfile @@ -33,7 +33,7 @@ COPY . . RUN pnpm install --offline # Build internal dependencies. -RUN pnpm --filter="@onward/auth" build +RUN pnpm bootstrap # Build learner app. RUN pnpm --filter="learner" build diff --git a/package.json b/package.json index 86a5ce61..3869e3d3 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "learner:dev": "pnpm --filter=\"learner\" dev", "learner:build": "pnpm --filter=\"learner\" build", "auth:build": "pnpm --filter=\"auth\" build", + "bootstrap": "pnpm --filter=\"./packages/*\" build", "format": "prettier --check \"**/*.{svelte,js,ts,md,html,css,json}\"", "lint": "eslint \"**/*.{svelte,js,ts}\"", "prepare": "husky" diff --git a/bootstrap.sh b/setup.sh similarity index 80% rename from bootstrap.sh rename to setup.sh index 47799e86..a18db167 100755 --- a/bootstrap.sh +++ b/setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Bootstraps the project by: +# Sets up the project by: # 1. Copies the `.env.example` file to `.env` if it doesn't already exist. # 2. Creates symlinks to `.env` in the apps that require it. # 3. Builds all packages for apps to use. @@ -9,4 +9,4 @@ cp -n .env.example .env ln -sf "$(pwd)/.env" ./apps/learner/.env -pnpm --filter="./packages/*" build +pnpm bootstrap From b732da7de7b1e65fa0dc28295437ed9d3b9298b2 Mon Sep 17 00:00:00 2001 From: YimingIsCOLD Date: Fri, 30 May 2025 04:33:46 +0800 Subject: [PATCH 3/3] ci(check): run `pnpm bootstrap` to build internal dependencies before checks --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 20d9cf8c..68f7f199 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -88,6 +88,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Bootstrap + run: pnpm bootstrap + - name: Check run: pnpm -r check