|
1 | | -# ------------------------------------------------------------ |
2 | | -# Workflow: Continuous Integration (CI) |
3 | | -# ------------------------------------------------------------ |
4 | | -# Purpose: |
5 | | -# This workflow validates the health of the Magic2U monorepo |
6 | | -# on every pull request and every push to the main branch. |
7 | | -# |
8 | | -# Why this matters: |
9 | | -# - Prevents broken builds from entering main |
10 | | -# - Ensures TypeScript, linting, and tests stay green |
11 | | -# - Guarantees that all packages in the monorepo compile |
12 | | -# - Creates a predictable, stable development experience |
13 | | -# |
14 | | -# Trigger: |
15 | | -# - Runs on all pull requests (quality gate before merging) |
16 | | -# - Runs on pushes to main (protects production branch) |
17 | | -# ------------------------------------------------------------ |
18 | | - |
19 | 1 | name: CI |
20 | 2 |
|
21 | 3 | on: |
22 | | - pull_request: # Validate all incoming PRs |
23 | 4 | push: |
24 | | - branches: [main] # Re-run CI when main is updated |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
25 | 11 |
|
26 | 12 | jobs: |
27 | 13 | build: |
28 | | - runs-on: ubuntu-latest # GitHub-hosted Linux runner |
| 14 | + runs-on: ubuntu-latest |
29 | 15 |
|
30 | 16 | steps: |
31 | | - # -------------------------------------------------------- |
32 | | - # Step 1: Checkout repository |
33 | | - # -------------------------------------------------------- |
34 | | - # Pulls down the repository code so the workflow can run |
35 | | - # builds, tests, and linting against the actual source. |
36 | | - - uses: actions/checkout@v3 |
| 17 | + - name: Check out repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Install pnpm |
| 21 | + uses: pnpm/action-setup@v4 |
37 | 22 |
|
38 | | - # -------------------------------------------------------- |
39 | | - # Step 2: Install pnpm |
40 | | - # -------------------------------------------------------- |
41 | | - # Magic2U uses pnpm as the monorepo package manager. |
42 | | - # This step ensures the correct version is installed. |
43 | | - - uses: pnpm/action-setup@v2 |
| 23 | + - name: Install Node.js |
| 24 | + uses: actions/setup-node@v4 |
44 | 25 | with: |
45 | | - version: 8 |
| 26 | + node-version: 22 |
| 27 | + cache: pnpm |
46 | 28 |
|
47 | | - # -------------------------------------------------------- |
48 | | - # Step 3: Install dependencies |
49 | | - # -------------------------------------------------------- |
50 | | - # Installs all workspace dependencies using pnpm. |
51 | | - # Benefits: |
52 | | - # - deterministic lockfile |
53 | | - # - fast, cached installs |
54 | | - # - efficient monorepo linking |
55 | | - - run: pnpm install |
| 29 | + - name: Install dependencies |
| 30 | + run: pnpm install --frozen-lockfile |
56 | 31 |
|
57 | | - # -------------------------------------------------------- |
58 | | - # Step 4: Build the monorepo |
59 | | - # -------------------------------------------------------- |
60 | | - # Runs "pnpm build", which triggers Turbo to: |
61 | | - # - build all packages in dependency order |
62 | | - # - cache build outputs |
63 | | - # - ensure no package has a broken build |
64 | | - - run: pnpm build |
| 32 | + - name: Build product |
| 33 | + run: pnpm build |
65 | 34 |
|
66 | | - # -------------------------------------------------------- |
67 | | - # Step 5: Lint the codebase |
68 | | - # -------------------------------------------------------- |
69 | | - # Ensures code quality and consistency across: |
70 | | - # - apps |
71 | | - # - packages |
72 | | - # - tooling |
73 | | - # |
74 | | - # Prevents stylistic drift and catches common errors early. |
75 | | - - run: pnpm lint |
| 35 | + - name: Run lint checks |
| 36 | + run: pnpm lint |
76 | 37 |
|
77 | | - # -------------------------------------------------------- |
78 | | - # Step 6: Run test suite |
79 | | - # -------------------------------------------------------- |
80 | | - # Executes all unit tests across the monorepo. |
81 | | - # Ensures: |
82 | | - # - components behave correctly |
83 | | - # - utilities remain stable |
84 | | - # - regressions are caught before merging |
85 | | - - run: pnpm test |
| 38 | + - name: Run tests when available |
| 39 | + run: pnpm run --if-present test |
0 commit comments